Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
obeis committed May 11, 2024
1 parent d97f0a1 commit 6467ccd
Show file tree
Hide file tree
Showing 38 changed files with 401 additions and 71 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_driver_impl/src/signal_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ macro raw_errln($tokens:tt) {
}

/// Signal handler installed for SIGSEGV
// FIXME(obeis): Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[allow(static_mut_refs)]
extern "C" fn print_stack_trace(_: libc::c_int) {
const MAX_FRAMES: usize = 256;
// Reserve data segment so we don't have to malloc in a signal handler, which might fail
Expand Down
2 changes: 2 additions & 0 deletions library/alloc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,8 @@ fn test_from_iter_specialization_panic_during_iteration_drops() {

#[test]
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
// FIXME(obeis): Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
#[cfg_attr(not(bootstrap), allow(static_mut_refs))]
fn test_from_iter_specialization_panic_during_drop_doesnt_leak() {
static mut DROP_COUNTER_OLD: [usize; 5] = [0; 5];
static mut DROP_COUNTER_NEW: [usize; 2] = [0; 2];
Expand Down
2 changes: 2 additions & 0 deletions library/core/tests/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ fn static_init() {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ fn issue11371() {
static mut X: Option<i32> = Some(123);
unsafe {
if X.is_some() {
//~^ ERROR: creating a shared reference to mutable static is discouraged
X = None;
X.unwrap();
//~^ ERROR: creating a shared reference to mutable static is discouraged
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
error: creating a shared reference to mutable static is discouraged
--> tests/ui/checked_unwrap/simple_conditionals.rs:175:12
|
LL | if X.is_some() {
| ^^^^^^^^^^^ shared reference to mutable static
|
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
= note: this will be a hard error in the 2024 edition
= 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
= note: `-D static-mut-refs` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(static_mut_refs)]`

error: creating a shared reference to mutable static is discouraged
--> tests/ui/checked_unwrap/simple_conditionals.rs:178:13
|
LL | X.unwrap();
| ^^^^^^^^^^ shared reference to mutable static
|
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
= note: this will be a hard error in the 2024 edition
= 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

error: called `unwrap` on `x` after checking its variant with `is_some`
--> tests/ui/checked_unwrap/simple_conditionals.rs:47:9
|
Expand Down Expand Up @@ -236,5 +258,5 @@ LL | if result.is_ok() {
LL | result.as_mut().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 25 previous errors
error: aborting due to 27 previous errors

2 changes: 2 additions & 0 deletions src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(unused)]
// FIXME(obeis): Do not allow `static_mut_refs` lint, it's UB
#![allow(static_mut_refs)]

#[derive(Debug)]
struct Foo;
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/tests/ui/redundant_static_lifetimes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(unused)]
// FIXME(obeis): Do not allow `static_mut_refs` lint, it's UB
#![allow(static_mut_refs)]

#[derive(Debug)]
struct Foo;
Expand Down
36 changes: 18 additions & 18 deletions src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: constants have by default a `'static` lifetime
--> tests/ui/redundant_static_lifetimes.rs:6:17
--> tests/ui/redundant_static_lifetimes.rs:8:17
|
LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removing 'static.
| -^^^^^^^---- help: consider removing `'static`: `&str`
Expand All @@ -8,103 +8,103 @@ LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removi
= help: to override `-D warnings` add `#[allow(clippy::redundant_static_lifetimes)]`

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

error: statics have by default a `'static` lifetime
--> tests/ui/redundant_static_lifetimes.rs:40:31
--> tests/ui/redundant_static_lifetimes.rs:42:31
|
LL | static mut STATIC_MUT_SLICE: &'static mut [u32] = &mut [0];
| -^^^^^^^---------- help: consider removing `'static`: `&mut [u32]`

error: statics have by default a `'static` lifetime
--> tests/ui/redundant_static_lifetimes.rs:69:16
--> tests/ui/redundant_static_lifetimes.rs:71:16
|
LL | static V: &'static u8 = &17;
| -^^^^^^^--- help: consider removing `'static`: `&u8`
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/tests/ui/useless_conversion.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![deny(clippy::useless_conversion)]
#![allow(clippy::needless_if, clippy::unnecessary_wraps)]
// FIXME(obeis): Do not allow `static_mut_refs` lint, it's UB
#![allow(static_mut_refs)]

fn test_generic<T: Copy>(val: T) -> T {
let _ = val;
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/tests/ui/useless_conversion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![deny(clippy::useless_conversion)]
#![allow(clippy::needless_if, clippy::unnecessary_wraps)]
// FIXME(obeis): Do not allow `static_mut_refs` lint, it's UB
#![allow(static_mut_refs)]

fn test_generic<T: Copy>(val: T) -> T {
let _ = T::from(val);
Expand Down
Loading

0 comments on commit 6467ccd

Please sign in to comment.