Skip to content

Commit abfd0a0

Browse files
committed
Update test
1 parent d97f0a1 commit abfd0a0

40 files changed

+408
-71
lines changed

Diff for: 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

Diff for: 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];

Diff for: 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

Diff for: 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
}

Diff for: 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

Diff for: src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![allow(unused)]
2+
// FIXME(obeis): Do not allow `static_mut_refs` lint, it's UB
3+
#![allow(static_mut_refs)]
24

35
#[derive(Debug)]
46
struct Foo;

Diff for: src/tools/clippy/tests/ui/redundant_static_lifetimes.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![allow(unused)]
2+
// FIXME(obeis): Do not allow `static_mut_refs` lint, it's UB
3+
#![allow(static_mut_refs)]
24

35
#[derive(Debug)]
46
struct Foo;

Diff for: src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: constants have by default a `'static` lifetime
2-
--> tests/ui/redundant_static_lifetimes.rs:6:17
2+
--> tests/ui/redundant_static_lifetimes.rs:8:17
33
|
44
LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removing 'static.
55
| -^^^^^^^---- help: consider removing `'static`: `&str`
@@ -8,103 +8,103 @@ LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removi
88
= help: to override `-D warnings` add `#[allow(clippy::redundant_static_lifetimes)]`
99

1010
error: constants have by default a `'static` lifetime
11-
--> tests/ui/redundant_static_lifetimes.rs:10:21
11+
--> tests/ui/redundant_static_lifetimes.rs:12:21
1212
|
1313
LL | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static
1414
| -^^^^^^^---- help: consider removing `'static`: `&str`
1515

1616
error: constants have by default a `'static` lifetime
17-
--> tests/ui/redundant_static_lifetimes.rs:12:32
17+
--> tests/ui/redundant_static_lifetimes.rs:14:32
1818
|
1919
LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static
2020
| -^^^^^^^---- help: consider removing `'static`: `&str`
2121

2222
error: constants have by default a `'static` lifetime
23-
--> tests/ui/redundant_static_lifetimes.rs:12:47
23+
--> tests/ui/redundant_static_lifetimes.rs:14:47
2424
|
2525
LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static
2626
| -^^^^^^^---- help: consider removing `'static`: `&str`
2727

2828
error: constants have by default a `'static` lifetime
29-
--> tests/ui/redundant_static_lifetimes.rs:14:17
29+
--> tests/ui/redundant_static_lifetimes.rs:16:17
3030
|
3131
LL | const VAR_SIX: &'static u8 = &5;
3232
| -^^^^^^^--- help: consider removing `'static`: `&u8`
3333

3434
error: constants have by default a `'static` lifetime
35-
--> tests/ui/redundant_static_lifetimes.rs:16:20
35+
--> tests/ui/redundant_static_lifetimes.rs:18:20
3636
|
3737
LL | const VAR_HEIGHT: &'static Foo = &Foo {};
3838
| -^^^^^^^---- help: consider removing `'static`: `&Foo`
3939

4040
error: constants have by default a `'static` lifetime
41-
--> tests/ui/redundant_static_lifetimes.rs:18:19
41+
--> tests/ui/redundant_static_lifetimes.rs:20:19
4242
|
4343
LL | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR: Consider removing 'static.
4444
| -^^^^^^^----- help: consider removing `'static`: `&[u8]`
4545

4646
error: constants have by default a `'static` lifetime
47-
--> tests/ui/redundant_static_lifetimes.rs:20:19
47+
--> tests/ui/redundant_static_lifetimes.rs:22:19
4848
|
4949
LL | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static.
5050
| -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)`
5151

5252
error: constants have by default a `'static` lifetime
53-
--> tests/ui/redundant_static_lifetimes.rs:22:19
53+
--> tests/ui/redundant_static_lifetimes.rs:24:19
5454
|
5555
LL | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static.
5656
| -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]`
5757

5858
error: statics have by default a `'static` lifetime
59-
--> tests/ui/redundant_static_lifetimes.rs:24:25
59+
--> tests/ui/redundant_static_lifetimes.rs:26:25
6060
|
6161
LL | static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR: Consider removing 'static.
6262
| -^^^^^^^---- help: consider removing `'static`: `&str`
6363

6464
error: statics have by default a `'static` lifetime
65-
--> tests/ui/redundant_static_lifetimes.rs:28:29
65+
--> tests/ui/redundant_static_lifetimes.rs:30:29
6666
|
6767
LL | static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static
6868
| -^^^^^^^---- help: consider removing `'static`: `&str`
6969

7070
error: statics have by default a `'static` lifetime
71-
--> tests/ui/redundant_static_lifetimes.rs:30:25
71+
--> tests/ui/redundant_static_lifetimes.rs:32:25
7272
|
7373
LL | static STATIC_VAR_SIX: &'static u8 = &5;
7474
| -^^^^^^^--- help: consider removing `'static`: `&u8`
7575

7676
error: statics have by default a `'static` lifetime
77-
--> tests/ui/redundant_static_lifetimes.rs:32:28
77+
--> tests/ui/redundant_static_lifetimes.rs:34:28
7878
|
7979
LL | static STATIC_VAR_HEIGHT: &'static Foo = &Foo {};
8080
| -^^^^^^^---- help: consider removing `'static`: `&Foo`
8181

8282
error: statics have by default a `'static` lifetime
83-
--> tests/ui/redundant_static_lifetimes.rs:34:27
83+
--> tests/ui/redundant_static_lifetimes.rs:36:27
8484
|
8585
LL | static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR: Consider removing 'static.
8686
| -^^^^^^^----- help: consider removing `'static`: `&[u8]`
8787

8888
error: statics have by default a `'static` lifetime
89-
--> tests/ui/redundant_static_lifetimes.rs:36:27
89+
--> tests/ui/redundant_static_lifetimes.rs:38:27
9090
|
9191
LL | static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static.
9292
| -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)`
9393

9494
error: statics have by default a `'static` lifetime
95-
--> tests/ui/redundant_static_lifetimes.rs:38:27
95+
--> tests/ui/redundant_static_lifetimes.rs:40:27
9696
|
9797
LL | static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static.
9898
| -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]`
9999

100100
error: statics have by default a `'static` lifetime
101-
--> tests/ui/redundant_static_lifetimes.rs:40:31
101+
--> tests/ui/redundant_static_lifetimes.rs:42:31
102102
|
103103
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:71:16
108108
|
109109
LL | static V: &'static u8 = &17;
110110
| -^^^^^^^--- help: consider removing `'static`: `&u8`

Diff for: src/tools/clippy/tests/ui/useless_conversion.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![deny(clippy::useless_conversion)]
22
#![allow(clippy::needless_if, clippy::unnecessary_wraps)]
3+
// FIXME(obeis): Do not allow `static_mut_refs` lint, it's UB
4+
#![allow(static_mut_refs)]
35

46
fn test_generic<T: Copy>(val: T) -> T {
57
let _ = val;

Diff for: src/tools/clippy/tests/ui/useless_conversion.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![deny(clippy::useless_conversion)]
22
#![allow(clippy::needless_if, clippy::unnecessary_wraps)]
3+
// FIXME(obeis): Do not allow `static_mut_refs` lint, it's UB
4+
#![allow(static_mut_refs)]
35

46
fn test_generic<T: Copy>(val: T) -> T {
57
let _ = T::from(val);

0 commit comments

Comments
 (0)