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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 23 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 14 additions & 2 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

0 commit comments

Comments
 (0)