Skip to content

Commit 72b1c9b

Browse files
committed
Update test
1 parent d97f0a1 commit 72b1c9b

38 files changed

+434
-48
lines changed

compiler/rustc_driver_impl/src/signal_handler.rs

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ macro raw_errln($tokens:tt) {
3434
}
3535

3636
/// Signal handler installed for SIGSEGV
37+
// FIXME(obeis): Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
38+
#[allow(static_mut_refs)]
3739
extern "C" fn print_stack_trace(_: libc::c_int) {
3840
const MAX_FRAMES: usize = 256;
3941
// Reserve data segment so we don't have to malloc in a signal handler, which might fail

library/alloc/tests/vec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,8 @@ fn test_from_iter_specialization_panic_during_iteration_drops() {
12851285

12861286
#[test]
12871287
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
1288+
// FIXME(obeis): Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
1289+
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
12881290
fn test_from_iter_specialization_panic_during_drop_doesnt_leak() {
12891291
static mut DROP_COUNTER_OLD: [usize; 5] = [0; 5];
12901292
static mut DROP_COUNTER_NEW: [usize; 2] = [0; 2];

library/core/tests/atomic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ fn static_init() {
228228
}
229229

230230
#[test]
231+
// FIXME(obeis): Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
232+
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
231233
fn atomic_access_bool() {
232234
static mut ATOMIC: AtomicBool = AtomicBool::new(false);
233235

src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.rs

+2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ fn issue11371() {
173173
static mut X: Option<i32> = Some(123);
174174
unsafe {
175175
if X.is_some() {
176+
//~^ ERROR: creating a shared reference to mutable static is discouraged
176177
X = None;
177178
X.unwrap();
179+
//~^ ERROR: creating a shared reference to mutable static is discouraged
178180
}
179181
}
180182
}

src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
error: creating a shared reference to mutable static is discouraged
2+
--> tests/ui/checked_unwrap/simple_conditionals.rs:175:12
3+
|
4+
LL | if X.is_some() {
5+
| ^^^^^^^^^^^ shared reference to mutable static
6+
|
7+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
8+
= note: this will be a hard error in the 2024 edition
9+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
10+
= note: `-D static-mut-refs` implied by `-D warnings`
11+
= help: to override `-D warnings` add `#[allow(static_mut_refs)]`
12+
13+
error: creating a shared reference to mutable static is discouraged
14+
--> tests/ui/checked_unwrap/simple_conditionals.rs:178:13
15+
|
16+
LL | X.unwrap();
17+
| ^^^^^^^^^^ shared reference to mutable static
18+
|
19+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
20+
= note: this will be a hard error in the 2024 edition
21+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
22+
123
error: called `unwrap` on `x` after checking its variant with `is_some`
224
--> tests/ui/checked_unwrap/simple_conditionals.rs:47:9
325
|
@@ -236,5 +258,5 @@ LL | if result.is_ok() {
236258
LL | result.as_mut().unwrap();
237259
| ^^^^^^^^^^^^^^^^^^^^^^^^
238260

239-
error: aborting due to 25 previous errors
261+
error: aborting due to 27 previous errors
240262

src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fn main() {
4444

4545
unsafe {
4646
STATIC_MUT_SLICE[0] = 0;
47+
//~^ ERROR: creating a shared reference to mutable static is discouraged
4748
}
4849
}
4950

src/tools/clippy/tests/ui/redundant_static_lifetimes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fn main() {
4444

4545
unsafe {
4646
STATIC_MUT_SLICE[0] = 0;
47+
//~^ ERROR: creating a shared reference to mutable static is discouraged
4748
}
4849
}
4950

src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr

+14-2
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,22 @@ LL | static mut STATIC_MUT_SLICE: &'static mut [u32] = &mut [0];
104104
| -^^^^^^^---------- help: consider removing `'static`: `&mut [u32]`
105105

106106
error: statics have by default a `'static` lifetime
107-
--> tests/ui/redundant_static_lifetimes.rs:69:16
107+
--> tests/ui/redundant_static_lifetimes.rs:70:16
108108
|
109109
LL | static V: &'static u8 = &17;
110110
| -^^^^^^^--- help: consider removing `'static`: `&u8`
111111

112-
error: aborting due to 18 previous errors
112+
error: creating a shared reference to mutable static is discouraged
113+
--> tests/ui/redundant_static_lifetimes.rs:46:9
114+
|
115+
LL | STATIC_MUT_SLICE[0] = 0;
116+
| ^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
117+
|
118+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
119+
= note: this will be a hard error in the 2024 edition
120+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
121+
= note: `-D static-mut-refs` implied by `-D warnings`
122+
= help: to override `-D warnings` add `#[allow(static_mut_refs)]`
123+
124+
error: aborting due to 19 previous errors
113125

src/tools/clippy/tests/ui/useless_conversion.fixed

+4
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@ fn dont_lint_into_iter_on_static_copy_iter() {
9797
static mut C: CopiableCounter = CopiableCounter { counter: 0 };
9898
unsafe {
9999
assert_eq!(C.into_iter().next(), Some(1));
100+
//~^ ERROR: creating a shared reference to mutable static is discouraged
100101
assert_eq!(C.into_iter().next(), Some(1));
102+
//~^ ERROR: creating a shared reference to mutable static is discouraged
101103
assert_eq!(C.next(), Some(1));
104+
//~^ ERROR: creating a shared reference to mutable static is discouraged
102105
assert_eq!(C.next(), Some(2));
106+
//~^ ERROR: creating a shared reference to mutable static is discouraged
103107
}
104108
}
105109

src/tools/clippy/tests/ui/useless_conversion.rs

+4
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@ fn dont_lint_into_iter_on_static_copy_iter() {
9797
static mut C: CopiableCounter = CopiableCounter { counter: 0 };
9898
unsafe {
9999
assert_eq!(C.into_iter().next(), Some(1));
100+
//~^ ERROR: creating a shared reference to mutable static is discouraged
100101
assert_eq!(C.into_iter().next(), Some(1));
102+
//~^ ERROR: creating a shared reference to mutable static is discouraged
101103
assert_eq!(C.next(), Some(1));
104+
//~^ ERROR: creating a shared reference to mutable static is discouraged
102105
assert_eq!(C.next(), Some(2));
106+
//~^ ERROR: creating a shared reference to mutable static is discouraged
103107
}
104108
}
105109

src/tools/clippy/tests/ui/useless_conversion.stderr

+72-30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
error: creating a shared reference to mutable static is discouraged
2+
--> tests/ui/useless_conversion.rs:99:20
3+
|
4+
LL | assert_eq!(C.into_iter().next(), Some(1));
5+
| ^^^^^^^^^^^^^ shared reference to mutable static
6+
|
7+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
8+
= note: this will be a hard error in the 2024 edition
9+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
10+
= note: `-D static-mut-refs` implied by `-D warnings`
11+
= help: to override `-D warnings` add `#[allow(static_mut_refs)]`
12+
13+
error: creating a shared reference to mutable static is discouraged
14+
--> tests/ui/useless_conversion.rs:101:20
15+
|
16+
LL | assert_eq!(C.into_iter().next(), Some(1));
17+
| ^^^^^^^^^^^^^ shared reference to mutable static
18+
|
19+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
20+
= note: this will be a hard error in the 2024 edition
21+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
22+
23+
error: creating a shared reference to mutable static is discouraged
24+
--> tests/ui/useless_conversion.rs:103:20
25+
|
26+
LL | assert_eq!(C.next(), Some(1));
27+
| ^^^^^^^^ shared reference to mutable static
28+
|
29+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
30+
= note: this will be a hard error in the 2024 edition
31+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
32+
33+
error: creating a shared reference to mutable static is discouraged
34+
--> tests/ui/useless_conversion.rs:105:20
35+
|
36+
LL | assert_eq!(C.next(), Some(2));
37+
| ^^^^^^^^ shared reference to mutable static
38+
|
39+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
40+
= note: this will be a hard error in the 2024 edition
41+
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
42+
143
error: useless conversion to the same type: `T`
244
--> tests/ui/useless_conversion.rs:5:13
345
|
@@ -53,178 +95,178 @@ LL | let mut n = NUMBERS.into_iter();
5395
| ^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `NUMBERS`
5496

5597
error: useless conversion to the same type: `std::string::String`
56-
--> tests/ui/useless_conversion.rs:132:21
98+
--> tests/ui/useless_conversion.rs:136:21
5799
|
58100
LL | let _: String = "foo".to_string().into();
59101
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()`
60102

61103
error: useless conversion to the same type: `std::string::String`
62-
--> tests/ui/useless_conversion.rs:133:21
104+
--> tests/ui/useless_conversion.rs:137:21
63105
|
64106
LL | let _: String = From::from("foo".to_string());
65107
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()`
66108

67109
error: useless conversion to the same type: `std::string::String`
68-
--> tests/ui/useless_conversion.rs:134:13
110+
--> tests/ui/useless_conversion.rs:138:13
69111
|
70112
LL | let _ = String::from("foo".to_string());
71113
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()`
72114

73115
error: useless conversion to the same type: `std::string::String`
74-
--> tests/ui/useless_conversion.rs:135:13
116+
--> tests/ui/useless_conversion.rs:139:13
75117
|
76118
LL | let _ = String::from(format!("A: {:04}", 123));
77119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)`
78120

79121
error: useless conversion to the same type: `std::str::Lines<'_>`
80-
--> tests/ui/useless_conversion.rs:136:13
122+
--> tests/ui/useless_conversion.rs:140:13
81123
|
82124
LL | let _ = "".lines().into_iter();
83125
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()`
84126

85127
error: useless conversion to the same type: `std::vec::IntoIter<i32>`
86-
--> tests/ui/useless_conversion.rs:137:13
128+
--> tests/ui/useless_conversion.rs:141:13
87129
|
88130
LL | let _ = vec![1, 2, 3].into_iter().into_iter();
89131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()`
90132

91133
error: useless conversion to the same type: `std::string::String`
92-
--> tests/ui/useless_conversion.rs:138:21
134+
--> tests/ui/useless_conversion.rs:142:21
93135
|
94136
LL | let _: String = format!("Hello {}", "world").into();
95137
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")`
96138

97139
error: useless conversion to the same type: `i32`
98-
--> tests/ui/useless_conversion.rs:143:13
140+
--> tests/ui/useless_conversion.rs:147:13
99141
|
100142
LL | let _ = i32::from(a + b) * 3;
101143
| ^^^^^^^^^^^^^^^^ help: consider removing `i32::from()`: `(a + b)`
102144

103145
error: useless conversion to the same type: `Foo<'a'>`
104-
--> tests/ui/useless_conversion.rs:149:23
146+
--> tests/ui/useless_conversion.rs:153:23
105147
|
106148
LL | let _: Foo<'a'> = s2.into();
107149
| ^^^^^^^^^ help: consider removing `.into()`: `s2`
108150

109151
error: useless conversion to the same type: `Foo<'a'>`
110-
--> tests/ui/useless_conversion.rs:151:13
152+
--> tests/ui/useless_conversion.rs:155:13
111153
|
112154
LL | let _ = Foo::<'a'>::from(s3);
113155
| ^^^^^^^^^^^^^^^^^^^^ help: consider removing `Foo::<'a'>::from()`: `s3`
114156

115157
error: useless conversion to the same type: `std::vec::IntoIter<Foo<'a'>>`
116-
--> tests/ui/useless_conversion.rs:153:13
158+
--> tests/ui/useless_conversion.rs:157:13
117159
|
118160
LL | let _ = vec![s4, s4, s4].into_iter().into_iter();
119161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![s4, s4, s4].into_iter()`
120162

121163
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
122-
--> tests/ui/useless_conversion.rs:185:7
164+
--> tests/ui/useless_conversion.rs:189:7
123165
|
124166
LL | b(vec![1, 2].into_iter());
125167
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]`
126168
|
127169
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
128-
--> tests/ui/useless_conversion.rs:175:13
170+
--> tests/ui/useless_conversion.rs:179:13
129171
|
130172
LL | fn b<T: IntoIterator<Item = i32>>(_: T) {}
131173
| ^^^^^^^^^^^^^^^^^^^^^^^^
132174

133175
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
134-
--> tests/ui/useless_conversion.rs:186:7
176+
--> tests/ui/useless_conversion.rs:190:7
135177
|
136178
LL | c(vec![1, 2].into_iter());
137179
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]`
138180
|
139181
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
140-
--> tests/ui/useless_conversion.rs:176:18
182+
--> tests/ui/useless_conversion.rs:180:18
141183
|
142184
LL | fn c(_: impl IntoIterator<Item = i32>) {}
143185
| ^^^^^^^^^^^^^^^^^^^^^^^^
144186

145187
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
146-
--> tests/ui/useless_conversion.rs:187:7
188+
--> tests/ui/useless_conversion.rs:191:7
147189
|
148190
LL | d(vec![1, 2].into_iter());
149191
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]`
150192
|
151193
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
152-
--> tests/ui/useless_conversion.rs:179:12
194+
--> tests/ui/useless_conversion.rs:183:12
153195
|
154196
LL | T: IntoIterator<Item = i32>,
155197
| ^^^^^^^^^^^^^^^^^^^^^^^^
156198

157199
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
158-
--> tests/ui/useless_conversion.rs:190:7
200+
--> tests/ui/useless_conversion.rs:194:7
159201
|
160202
LL | b(vec![1, 2].into_iter().into_iter());
161203
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]`
162204
|
163205
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
164-
--> tests/ui/useless_conversion.rs:175:13
206+
--> tests/ui/useless_conversion.rs:179:13
165207
|
166208
LL | fn b<T: IntoIterator<Item = i32>>(_: T) {}
167209
| ^^^^^^^^^^^^^^^^^^^^^^^^
168210

169211
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
170-
--> tests/ui/useless_conversion.rs:191:7
212+
--> tests/ui/useless_conversion.rs:195:7
171213
|
172214
LL | b(vec![1, 2].into_iter().into_iter().into_iter());
173215
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]`
174216
|
175217
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
176-
--> tests/ui/useless_conversion.rs:175:13
218+
--> tests/ui/useless_conversion.rs:179:13
177219
|
178220
LL | fn b<T: IntoIterator<Item = i32>>(_: T) {}
179221
| ^^^^^^^^^^^^^^^^^^^^^^^^
180222

181223
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
182-
--> tests/ui/useless_conversion.rs:237:24
224+
--> tests/ui/useless_conversion.rs:241:24
183225
|
184226
LL | foo2::<i32, _>([1, 2, 3].into_iter());
185227
| ^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2, 3]`
186228
|
187229
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
188-
--> tests/ui/useless_conversion.rs:216:12
230+
--> tests/ui/useless_conversion.rs:220:12
189231
|
190232
LL | I: IntoIterator<Item = i32> + Helper<X>,
191233
| ^^^^^^^^^^^^^^^^^^^^^^^^
192234

193235
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
194-
--> tests/ui/useless_conversion.rs:245:14
236+
--> tests/ui/useless_conversion.rs:249:14
195237
|
196238
LL | foo3([1, 2, 3].into_iter());
197239
| ^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2, 3]`
198240
|
199241
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
200-
--> tests/ui/useless_conversion.rs:225:12
242+
--> tests/ui/useless_conversion.rs:229:12
201243
|
202244
LL | I: IntoIterator<Item = i32>,
203245
| ^^^^^^^^^^^^^^^^^^^^^^^^
204246

205247
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
206-
--> tests/ui/useless_conversion.rs:254:16
248+
--> tests/ui/useless_conversion.rs:258:16
207249
|
208250
LL | S1.foo([1, 2].into_iter());
209251
| ^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2]`
210252
|
211253
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
212-
--> tests/ui/useless_conversion.rs:251:27
254+
--> tests/ui/useless_conversion.rs:255:27
213255
|
214256
LL | pub fn foo<I: IntoIterator>(&self, _: I) {}
215257
| ^^^^^^^^^^^^
216258

217259
error: explicit call to `.into_iter()` in function argument accepting `IntoIterator`
218-
--> tests/ui/useless_conversion.rs:273:44
260+
--> tests/ui/useless_conversion.rs:277:44
219261
|
220262
LL | v0.into_iter().interleave_shortest(v1.into_iter());
221263
| ^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `v1`
222264
|
223265
note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()`
224-
--> tests/ui/useless_conversion.rs:260:20
266+
--> tests/ui/useless_conversion.rs:264:20
225267
|
226268
LL | J: IntoIterator,
227269
| ^^^^^^^^^^^^
228270

229-
error: aborting due to 28 previous errors
271+
error: aborting due to 32 previous errors
230272

0 commit comments

Comments
 (0)