diff options
Diffstat (limited to 'tests/ui/lint')
36 files changed, 739 insertions, 307 deletions
diff --git a/tests/ui/lint/ambiguous_wide_pointer_comparisons_suggestions.stderr b/tests/ui/lint/ambiguous_wide_pointer_comparisons_suggestions.stderr index d9190dbb813..30d7683ef4b 100644 --- a/tests/ui/lint/ambiguous_wide_pointer_comparisons_suggestions.stderr +++ b/tests/ui/lint/ambiguous_wide_pointer_comparisons_suggestions.stderr @@ -7,12 +7,14 @@ LL | let _ = a == b; = note: `#[warn(ambiguous_wide_pointer_comparisons)]` on by default help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(a, b); - | ++++++++++++++++++ ~ + +LL - let _ = a == b; +LL + let _ = std::ptr::addr_eq(a, b); + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | let _ = std::ptr::eq(a, b); - | +++++++++++++ ~ + +LL - let _ = a == b; +LL + let _ = std::ptr::eq(a, b); + | warning: 1 warning emitted diff --git a/tests/ui/lint/clashing-extern-fn.rs b/tests/ui/lint/clashing-extern-fn.rs index 9bbb20246df..e4477c96202 100644 --- a/tests/ui/lint/clashing-extern-fn.rs +++ b/tests/ui/lint/clashing-extern-fn.rs @@ -1,7 +1,7 @@ //@ check-pass //@ aux-build:external_extern_fn.rs #![crate_type = "lib"] - +#![feature(pattern_type_macro, pattern_types)] mod redeclared_different_signature { mod a { extern "C" { @@ -490,3 +490,33 @@ mod hidden_niche { } } } + +mod pattern_types { + mod a { + use std::pat::pattern_type; + #[repr(transparent)] + struct NonZeroUsize(pattern_type!(usize is 1..)); + extern "C" { + fn pt_non_zero_usize() -> pattern_type!(usize is 1..); + fn pt_non_zero_usize_opt() -> Option<pattern_type!(usize is 1..)>; + fn pt_non_zero_usize_opt_full_range() -> Option<pattern_type!(usize is 0..)>; + //~^ WARN not FFI-safe + fn pt_non_null_ptr() -> pattern_type!(usize is 1..); + fn pt_non_zero_usize_wrapper() -> NonZeroUsize; + fn pt_non_zero_usize_wrapper_opt() -> Option<NonZeroUsize>; + } + } + mod b { + extern "C" { + // If there's a clash in either of these cases you're either gaining an incorrect + // invariant that the value is non-zero, or you're missing out on that invariant. Both + // cases are warning for, from both a caller-convenience and optimisation perspective. + fn pt_non_zero_usize() -> usize; + fn pt_non_zero_usize_opt() -> usize; + fn pt_non_null_ptr() -> *const (); + //~^ WARN `pt_non_null_ptr` redeclared with a different signature + fn pt_non_zero_usize_wrapper() -> usize; + fn pt_non_zero_usize_wrapper_opt() -> usize; + } + } +} diff --git a/tests/ui/lint/clashing-extern-fn.stderr b/tests/ui/lint/clashing-extern-fn.stderr index 48dd1adbc1f..118b18b224c 100644 --- a/tests/ui/lint/clashing-extern-fn.stderr +++ b/tests/ui/lint/clashing-extern-fn.stderr @@ -17,6 +17,15 @@ LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZero<usiz = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint +warning: `extern` block uses type `Option<(usize) is 0..=>`, which is not FFI-safe + --> $DIR/clashing-extern-fn.rs:502:54 + | +LL | fn pt_non_zero_usize_opt_full_range() -> Option<pattern_type!(usize is 0..)>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum + = note: enum has no representation hint + warning: `clash` redeclared with a different signature --> $DIR/clashing-extern-fn.rs:13:13 | @@ -258,5 +267,17 @@ LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZero<usiz = note: expected `unsafe extern "C" fn() -> usize` found `unsafe extern "C" fn() -> Option<UnsafeCell<NonZero<usize>>>` -warning: 22 warnings emitted +warning: `pt_non_null_ptr` redeclared with a different signature + --> $DIR/clashing-extern-fn.rs:516:13 + | +LL | fn pt_non_null_ptr() -> pattern_type!(usize is 1..); + | ---------------------------------------------------- `pt_non_null_ptr` previously declared here +... +LL | fn pt_non_null_ptr() -> *const (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration + | + = note: expected `unsafe extern "C" fn() -> (usize) is 1..=` + found `unsafe extern "C" fn() -> *const ()` + +warning: 24 warnings emitted diff --git a/tests/ui/lint/cli-lint-override.forbid_warn.stderr b/tests/ui/lint/cli-lint-override.forbid_warn.stderr index 169be997b48..fb8779ad4f1 100644 --- a/tests/ui/lint/cli-lint-override.forbid_warn.stderr +++ b/tests/ui/lint/cli-lint-override.forbid_warn.stderr @@ -2,7 +2,7 @@ error: extern declarations without an explicit ABI are deprecated --> $DIR/cli-lint-override.rs:12:1 | LL | extern fn foo() {} - | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` | = note: requested on the command line with `-F missing-abi` diff --git a/tests/ui/lint/cli-lint-override.force_warn_deny.stderr b/tests/ui/lint/cli-lint-override.force_warn_deny.stderr index 574f2ca66a4..10fc13e3f52 100644 --- a/tests/ui/lint/cli-lint-override.force_warn_deny.stderr +++ b/tests/ui/lint/cli-lint-override.force_warn_deny.stderr @@ -2,7 +2,7 @@ warning: extern declarations without an explicit ABI are deprecated --> $DIR/cli-lint-override.rs:12:1 | LL | extern fn foo() {} - | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` | = note: requested on the command line with `--force-warn missing-abi` diff --git a/tests/ui/lint/cli-lint-override.warn_deny.stderr b/tests/ui/lint/cli-lint-override.warn_deny.stderr index bfec37ada95..979ca22324f 100644 --- a/tests/ui/lint/cli-lint-override.warn_deny.stderr +++ b/tests/ui/lint/cli-lint-override.warn_deny.stderr @@ -2,7 +2,7 @@ error: extern declarations without an explicit ABI are deprecated --> $DIR/cli-lint-override.rs:12:1 | LL | extern fn foo() {} - | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` | = note: requested on the command line with `-D missing-abi` diff --git a/tests/ui/lint/dead-code/tuple-struct-field.stderr b/tests/ui/lint/dead-code/tuple-struct-field.stderr index 434554d7ae5..3e1d4e77274 100644 --- a/tests/ui/lint/dead-code/tuple-struct-field.stderr +++ b/tests/ui/lint/dead-code/tuple-struct-field.stderr @@ -33,8 +33,9 @@ LL | struct UnusedInTheMiddle(i32, f32, String, u8, u32); | help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields | -LL | struct UnusedInTheMiddle(i32, (), (), u8, ()); - | ~~ ~~ ~~ +LL - struct UnusedInTheMiddle(i32, f32, String, u8, u32); +LL + struct UnusedInTheMiddle(i32, (), (), u8, ()); + | error: aborting due to 3 previous errors diff --git a/tests/ui/lint/elided-named-lifetimes/static.stderr b/tests/ui/lint/elided-named-lifetimes/static.stderr index fa2a2d3460f..7ad08dbf04b 100644 --- a/tests/ui/lint/elided-named-lifetimes/static.stderr +++ b/tests/ui/lint/elided-named-lifetimes/static.stderr @@ -44,8 +44,9 @@ LL | fn underscore(x: &'static u8) -> &'_ u8 { | help: consider specifying it explicitly | -LL | fn underscore(x: &'static u8) -> &'static u8 { - | ~~~~~~~ +LL - fn underscore(x: &'static u8) -> &'_ u8 { +LL + fn underscore(x: &'static u8) -> &'static u8 { + | error: aborting due to 4 previous errors diff --git a/tests/ui/lint/fn-ptr-comparisons.stderr b/tests/ui/lint/fn-ptr-comparisons.stderr index eaba23a461a..e6993323898 100644 --- a/tests/ui/lint/fn-ptr-comparisons.stderr +++ b/tests/ui/lint/fn-ptr-comparisons.stderr @@ -10,8 +10,9 @@ LL | let _ = f == a; = note: `#[warn(unpredictable_function_pointer_comparisons)]` on by default help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(f, a as fn()); - | +++++++++++++++++++++ ~ ++++++++ +LL - let _ = f == a; +LL + let _ = std::ptr::fn_addr_eq(f, a as fn()); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:28:13 @@ -24,8 +25,9 @@ LL | let _ = f != a; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = !std::ptr::fn_addr_eq(f, a as fn()); - | ++++++++++++++++++++++ ~ ++++++++ +LL - let _ = f != a; +LL + let _ = !std::ptr::fn_addr_eq(f, a as fn()); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:30:13 @@ -38,8 +40,9 @@ LL | let _ = f == g; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(f, g); - | +++++++++++++++++++++ ~ + +LL - let _ = f == g; +LL + let _ = std::ptr::fn_addr_eq(f, g); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:32:13 @@ -52,8 +55,9 @@ LL | let _ = f == f; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(f, f); - | +++++++++++++++++++++ ~ + +LL - let _ = f == f; +LL + let _ = std::ptr::fn_addr_eq(f, f); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:34:13 @@ -66,8 +70,9 @@ LL | let _ = g == g; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(g, g); - | +++++++++++++++++++++ ~ + +LL - let _ = g == g; +LL + let _ = std::ptr::fn_addr_eq(g, g); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:36:13 @@ -80,8 +85,9 @@ LL | let _ = g == g; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(g, g); - | +++++++++++++++++++++ ~ + +LL - let _ = g == g; +LL + let _ = std::ptr::fn_addr_eq(g, g); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:38:13 @@ -94,8 +100,9 @@ LL | let _ = &g == &g; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(g, g); - | ~~~~~~~~~~~~~~~~~~~~~ ~ + +LL - let _ = &g == &g; +LL + let _ = std::ptr::fn_addr_eq(g, g); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:40:13 @@ -108,8 +115,9 @@ LL | let _ = a as fn() == g; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(a as fn(), g); - | +++++++++++++++++++++ ~ + +LL - let _ = a as fn() == g; +LL + let _ = std::ptr::fn_addr_eq(a as fn(), g); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:44:13 @@ -122,8 +130,9 @@ LL | let _ = cfn == c; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(cfn, c as extern "C" fn()); - | +++++++++++++++++++++ ~ +++++++++++++++++++ +LL - let _ = cfn == c; +LL + let _ = std::ptr::fn_addr_eq(cfn, c as extern "C" fn()); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:48:13 @@ -136,8 +145,9 @@ LL | let _ = argsfn == args; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(argsfn, args as extern "C" fn(i32) -> i32); - | +++++++++++++++++++++ ~ +++++++++++++++++++++++++++++ +LL - let _ = argsfn == args; +LL + let _ = std::ptr::fn_addr_eq(argsfn, args as extern "C" fn(i32) -> i32); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:52:13 @@ -150,8 +160,9 @@ LL | let _ = t == test; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(t, test as unsafe extern "C" fn()); - | +++++++++++++++++++++ ~ ++++++++++++++++++++++++++ +LL - let _ = t == test; +LL + let _ = std::ptr::fn_addr_eq(t, test as unsafe extern "C" fn()); + | warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique --> $DIR/fn-ptr-comparisons.rs:56:13 @@ -164,8 +175,9 @@ LL | let _ = a1.f == a2.f; = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html> help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint | -LL | let _ = std::ptr::fn_addr_eq(a1.f, a2.f); - | +++++++++++++++++++++ ~ + +LL - let _ = a1.f == a2.f; +LL + let _ = std::ptr::fn_addr_eq(a1.f, a2.f); + | warning: 12 warnings emitted diff --git a/tests/ui/lint/for_loop_over_fallibles.stderr b/tests/ui/lint/for_loop_over_fallibles.stderr index f695de08257..dae5e6428c8 100644 --- a/tests/ui/lint/for_loop_over_fallibles.stderr +++ b/tests/ui/lint/for_loop_over_fallibles.stderr @@ -7,12 +7,14 @@ LL | for _ in Some(1) {} = note: `#[warn(for_loops_over_fallibles)]` on by default help: to check pattern in a loop use `while let` | -LL | while let Some(_) = Some(1) {} - | ~~~~~~~~~~~~~~~ ~~~ +LL - for _ in Some(1) {} +LL + while let Some(_) = Some(1) {} + | help: consider using `if let` to clear intent | -LL | if let Some(_) = Some(1) {} - | ~~~~~~~~~~~~ ~~~ +LL - for _ in Some(1) {} +LL + if let Some(_) = Some(1) {} + | warning: for loop over a `Result`. This is more readably written as an `if let` statement --> $DIR/for_loop_over_fallibles.rs:9:14 @@ -22,12 +24,14 @@ LL | for _ in Ok::<_, ()>(1) {} | help: to check pattern in a loop use `while let` | -LL | while let Ok(_) = Ok::<_, ()>(1) {} - | ~~~~~~~~~~~~~ ~~~ +LL - for _ in Ok::<_, ()>(1) {} +LL + while let Ok(_) = Ok::<_, ()>(1) {} + | help: consider using `if let` to clear intent | -LL | if let Ok(_) = Ok::<_, ()>(1) {} - | ~~~~~~~~~~ ~~~ +LL - for _ in Ok::<_, ()>(1) {} +LL + if let Ok(_) = Ok::<_, ()>(1) {} + | warning: for loop over an `Option`. This is more readably written as an `if let` statement --> $DIR/for_loop_over_fallibles.rs:15:14 @@ -37,12 +41,14 @@ LL | for _ in [0; 0].iter().next() {} | help: to iterate over `[0; 0].iter()` remove the call to `next` | -LL | for _ in [0; 0].iter().by_ref() {} - | ~~~~~~~~~ +LL - for _ in [0; 0].iter().next() {} +LL + for _ in [0; 0].iter().by_ref() {} + | help: consider using `if let` to clear intent | -LL | if let Some(_) = [0; 0].iter().next() {} - | ~~~~~~~~~~~~ ~~~ +LL - for _ in [0; 0].iter().next() {} +LL + if let Some(_) = [0; 0].iter().next() {} + | warning: for loop over a `Result`. This is more readably written as an `if let` statement --> $DIR/for_loop_over_fallibles.rs:21:14 @@ -52,12 +58,14 @@ LL | for _ in Ok::<_, ()>([0; 0].iter()) {} | help: to check pattern in a loop use `while let` | -LL | while let Ok(_) = Ok::<_, ()>([0; 0].iter()) {} - | ~~~~~~~~~~~~~ ~~~ +LL - for _ in Ok::<_, ()>([0; 0].iter()) {} +LL + while let Ok(_) = Ok::<_, ()>([0; 0].iter()) {} + | help: consider using `if let` to clear intent | -LL | if let Ok(_) = Ok::<_, ()>([0; 0].iter()) {} - | ~~~~~~~~~~ ~~~ +LL - for _ in Ok::<_, ()>([0; 0].iter()) {} +LL + if let Ok(_) = Ok::<_, ()>([0; 0].iter()) {} + | warning: for loop over a `Result`. This is more readably written as an `if let` statement --> $DIR/for_loop_over_fallibles.rs:29:14 @@ -67,16 +75,18 @@ LL | for _ in Ok::<_, ()>([0; 0].iter()) {} | help: to check pattern in a loop use `while let` | -LL | while let Ok(_) = Ok::<_, ()>([0; 0].iter()) {} - | ~~~~~~~~~~~~~ ~~~ +LL - for _ in Ok::<_, ()>([0; 0].iter()) {} +LL + while let Ok(_) = Ok::<_, ()>([0; 0].iter()) {} + | help: consider unwrapping the `Result` with `?` to iterate over its contents | LL | for _ in Ok::<_, ()>([0; 0].iter())? {} | + help: consider using `if let` to clear intent | -LL | if let Ok(_) = Ok::<_, ()>([0; 0].iter()) {} - | ~~~~~~~~~~ ~~~ +LL - for _ in Ok::<_, ()>([0; 0].iter()) {} +LL + if let Ok(_) = Ok::<_, ()>([0; 0].iter()) {} + | warning: for loop over a `Result`. This is more readably written as an `if let` statement --> $DIR/for_loop_over_fallibles.rs:36:14 @@ -86,16 +96,18 @@ LL | for _ in Ok::<_, ()>([0; 0]) {} | help: to check pattern in a loop use `while let` | -LL | while let Ok(_) = Ok::<_, ()>([0; 0]) {} - | ~~~~~~~~~~~~~ ~~~ +LL - for _ in Ok::<_, ()>([0; 0]) {} +LL + while let Ok(_) = Ok::<_, ()>([0; 0]) {} + | help: consider unwrapping the `Result` with `?` to iterate over its contents | LL | for _ in Ok::<_, ()>([0; 0])? {} | + help: consider using `if let` to clear intent | -LL | if let Ok(_) = Ok::<_, ()>([0; 0]) {} - | ~~~~~~~~~~ ~~~ +LL - for _ in Ok::<_, ()>([0; 0]) {} +LL + if let Ok(_) = Ok::<_, ()>([0; 0]) {} + | warning: for loop over a `&Option`. This is more readably written as an `if let` statement --> $DIR/for_loop_over_fallibles.rs:47:14 @@ -105,12 +117,14 @@ LL | for _ in &Some(1) {} | help: to check pattern in a loop use `while let` | -LL | while let Some(_) = &Some(1) {} - | ~~~~~~~~~~~~~~~ ~~~ +LL - for _ in &Some(1) {} +LL + while let Some(_) = &Some(1) {} + | help: consider using `if let` to clear intent | -LL | if let Some(_) = &Some(1) {} - | ~~~~~~~~~~~~ ~~~ +LL - for _ in &Some(1) {} +LL + if let Some(_) = &Some(1) {} + | warning: for loop over a `&Result`. This is more readably written as an `if let` statement --> $DIR/for_loop_over_fallibles.rs:51:14 @@ -120,12 +134,14 @@ LL | for _ in &Ok::<_, ()>(1) {} | help: to check pattern in a loop use `while let` | -LL | while let Ok(_) = &Ok::<_, ()>(1) {} - | ~~~~~~~~~~~~~ ~~~ +LL - for _ in &Ok::<_, ()>(1) {} +LL + while let Ok(_) = &Ok::<_, ()>(1) {} + | help: consider using `if let` to clear intent | -LL | if let Ok(_) = &Ok::<_, ()>(1) {} - | ~~~~~~~~~~ ~~~ +LL - for _ in &Ok::<_, ()>(1) {} +LL + if let Ok(_) = &Ok::<_, ()>(1) {} + | warning: for loop over a `&mut Option`. This is more readably written as an `if let` statement --> $DIR/for_loop_over_fallibles.rs:57:14 @@ -135,12 +151,14 @@ LL | for _ in &mut Some(1) {} | help: to check pattern in a loop use `while let` | -LL | while let Some(_) = &mut Some(1) {} - | ~~~~~~~~~~~~~~~ ~~~ +LL - for _ in &mut Some(1) {} +LL + while let Some(_) = &mut Some(1) {} + | help: consider using `if let` to clear intent | -LL | if let Some(_) = &mut Some(1) {} - | ~~~~~~~~~~~~ ~~~ +LL - for _ in &mut Some(1) {} +LL + if let Some(_) = &mut Some(1) {} + | warning: for loop over a `&mut Result`. This is more readably written as an `if let` statement --> $DIR/for_loop_over_fallibles.rs:61:14 @@ -150,12 +168,14 @@ LL | for _ in &mut Ok::<_, ()>(1) {} | help: to check pattern in a loop use `while let` | -LL | while let Ok(_) = &mut Ok::<_, ()>(1) {} - | ~~~~~~~~~~~~~ ~~~ +LL - for _ in &mut Ok::<_, ()>(1) {} +LL + while let Ok(_) = &mut Ok::<_, ()>(1) {} + | help: consider using `if let` to clear intent | -LL | if let Ok(_) = &mut Ok::<_, ()>(1) {} - | ~~~~~~~~~~ ~~~ +LL - for _ in &mut Ok::<_, ()>(1) {} +LL + if let Ok(_) = &mut Ok::<_, ()>(1) {} + | warning: 10 warnings emitted diff --git a/tests/ui/lint/invalid_from_utf8.rs b/tests/ui/lint/invalid_from_utf8.rs index 2d1822a54ac..87a906761c0 100644 --- a/tests/ui/lint/invalid_from_utf8.rs +++ b/tests/ui/lint/invalid_from_utf8.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(concat_bytes)] - #![warn(invalid_from_utf8_unchecked)] #![warn(invalid_from_utf8)] @@ -9,7 +8,9 @@ pub fn from_utf8_unchecked_mut() { // Valid unsafe { std::str::from_utf8_unchecked_mut(&mut [99, 108, 105, 112, 112, 121]); + str::from_utf8_unchecked_mut(&mut [99, 108, 105, 112, 112, 121]); std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']); + str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']); let x = 0xA0; std::str::from_utf8_unchecked_mut(&mut [0xC0, x]); @@ -19,8 +20,12 @@ pub fn from_utf8_unchecked_mut() { unsafe { std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]); //~^ WARN calls to `std::str::from_utf8_unchecked_mut` + str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]); + //~^ WARN calls to `str::from_utf8_unchecked_mut` std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); //~^ WARN calls to `std::str::from_utf8_unchecked_mut` + str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + //~^ WARN calls to `str::from_utf8_unchecked_mut` } } @@ -28,23 +33,35 @@ pub fn from_utf8_unchecked() { // Valid unsafe { std::str::from_utf8_unchecked(&[99, 108, 105, 112, 112, 121]); + str::from_utf8_unchecked(&[99, 108, 105, 112, 112, 121]); std::str::from_utf8_unchecked(&[b'c', b'l', b'i', b'p', b'p', b'y']); + str::from_utf8_unchecked(&[b'c', b'l', b'i', b'p', b'p', b'y']); std::str::from_utf8_unchecked(b"clippy"); + str::from_utf8_unchecked(b"clippy"); let x = 0xA0; std::str::from_utf8_unchecked(&[0xC0, x]); + str::from_utf8_unchecked(&[0xC0, x]); } // Invalid unsafe { std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]); //~^ WARN calls to `std::str::from_utf8_unchecked` + str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]); + //~^ WARN calls to `str::from_utf8_unchecked` std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); //~^ WARN calls to `std::str::from_utf8_unchecked` + str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + //~^ WARN calls to `str::from_utf8_unchecked` std::str::from_utf8_unchecked(b"cl\x82ippy"); //~^ WARN calls to `std::str::from_utf8_unchecked` + str::from_utf8_unchecked(b"cl\x82ippy"); + //~^ WARN calls to `str::from_utf8_unchecked` std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy")); //~^ WARN calls to `std::str::from_utf8_unchecked` + str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy")); + //~^ WARN calls to `str::from_utf8_unchecked` } } @@ -52,18 +69,25 @@ pub fn from_utf8_mut() { // Valid { std::str::from_utf8_mut(&mut [99, 108, 105, 112, 112, 121]); + str::from_utf8_mut(&mut [99, 108, 105, 112, 112, 121]); std::str::from_utf8_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']); + str::from_utf8_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']); let x = 0xa0; std::str::from_utf8_mut(&mut [0xc0, x]); + str::from_utf8_mut(&mut [0xc0, x]); } // Invalid { std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]); //~^ WARN calls to `std::str::from_utf8_mut` + str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]); + //~^ WARN calls to `str::from_utf8_mut` std::str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); //~^ WARN calls to `std::str::from_utf8_mut` + str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + //~^ WARN calls to `str::from_utf8_mut` } } @@ -71,23 +95,35 @@ pub fn from_utf8() { // Valid { std::str::from_utf8(&[99, 108, 105, 112, 112, 121]); + str::from_utf8(&[99, 108, 105, 112, 112, 121]); std::str::from_utf8(&[b'c', b'l', b'i', b'p', b'p', b'y']); + str::from_utf8(&[b'c', b'l', b'i', b'p', b'p', b'y']); std::str::from_utf8(b"clippy"); + str::from_utf8(b"clippy"); let x = 0xA0; std::str::from_utf8(&[0xC0, x]); + str::from_utf8(&[0xC0, x]); } // Invalid { std::str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]); //~^ WARN calls to `std::str::from_utf8` + str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]); + //~^ WARN calls to `str::from_utf8` std::str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); //~^ WARN calls to `std::str::from_utf8` + str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + //~^ WARN calls to `str::from_utf8` std::str::from_utf8(b"cl\x82ippy"); //~^ WARN calls to `std::str::from_utf8` + str::from_utf8(b"cl\x82ippy"); + //~^ WARN calls to `str::from_utf8` std::str::from_utf8(concat_bytes!(b"cl", b"\x82ippy")); //~^ WARN calls to `std::str::from_utf8` + str::from_utf8(concat_bytes!(b"cl", b"\x82ippy")); + //~^ WARN calls to `str::from_utf8` } } @@ -95,25 +131,39 @@ pub fn from_utf8_with_indirections() { let mut a = [99, 108, 130, 105, 112, 112, 121]; std::str::from_utf8_mut(&mut a); //~^ WARN calls to `std::str::from_utf8_mut` + str::from_utf8_mut(&mut a); + //~^ WARN calls to `str::from_utf8_mut` let mut b = &mut a; let mut c = b; std::str::from_utf8_mut(c); //~^ WARN calls to `std::str::from_utf8_mut` + str::from_utf8_mut(c); + //~^ WARN calls to `str::from_utf8_mut` let mut c = &[99, 108, 130, 105, 112, 112, 121]; std::str::from_utf8(c); //~^ WARN calls to `std::str::from_utf8` + str::from_utf8(c); + //~^ WARN calls to `str::from_utf8` const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121]; std::str::from_utf8(&INVALID_1); //~^ WARN calls to `std::str::from_utf8` + str::from_utf8(&INVALID_1); + //~^ WARN calls to `str::from_utf8` static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121]; std::str::from_utf8(&INVALID_2); //~^ WARN calls to `std::str::from_utf8` + str::from_utf8(&INVALID_2); + //~^ WARN calls to `str::from_utf8` const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121]; std::str::from_utf8(INVALID_3); //~^ WARN calls to `std::str::from_utf8` + str::from_utf8(INVALID_3); + //~^ WARN calls to `str::from_utf8` const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] }; std::str::from_utf8(INVALID_4); //~^ WARN calls to `std::str::from_utf8` + str::from_utf8(INVALID_4); + //~^ WARN calls to `str::from_utf8` } fn main() {} diff --git a/tests/ui/lint/invalid_from_utf8.stderr b/tests/ui/lint/invalid_from_utf8.stderr index 07616e11801..3cd4d227fc2 100644 --- a/tests/ui/lint/invalid_from_utf8.stderr +++ b/tests/ui/lint/invalid_from_utf8.stderr @@ -1,5 +1,5 @@ -warning: calls to `std::str::from_utf8_unchecked_mut` with a invalid literal are undefined behavior - --> $DIR/invalid_from_utf8.rs:20:9 +warning: calls to `std::str::from_utf8_unchecked_mut` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:21:9 | LL | std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^ @@ -7,115 +7,220 @@ LL | std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112 | the literal was valid UTF-8 up to the 2 bytes | note: the lint level is defined here - --> $DIR/invalid_from_utf8.rs:5:9 + --> $DIR/invalid_from_utf8.rs:4:9 | LL | #![warn(invalid_from_utf8_unchecked)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: calls to `std::str::from_utf8_unchecked_mut` with a invalid literal are undefined behavior - --> $DIR/invalid_from_utf8.rs:22:9 +warning: calls to `str::from_utf8_unchecked_mut` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:23:9 + | +LL | str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_unchecked_mut` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:25:9 | LL | std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior - --> $DIR/invalid_from_utf8.rs:40:9 +warning: calls to `str::from_utf8_unchecked_mut` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:27:9 + | +LL | str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_unchecked` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:49:9 | LL | std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior - --> $DIR/invalid_from_utf8.rs:42:9 +warning: calls to `str::from_utf8_unchecked` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:51:9 + | +LL | str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_unchecked` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:53:9 | LL | std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior - --> $DIR/invalid_from_utf8.rs:44:9 +warning: calls to `str::from_utf8_unchecked` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:55:9 + | +LL | str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_unchecked` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:57:9 | LL | std::str::from_utf8_unchecked(b"cl\x82ippy"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior - --> $DIR/invalid_from_utf8.rs:46:9 +warning: calls to `str::from_utf8_unchecked` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:59:9 + | +LL | str::from_utf8_unchecked(b"cl\x82ippy"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^-------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_unchecked` with an invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:61:9 | LL | std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error +warning: calls to `str::from_utf8_unchecked` with an invalid literal are undefined behavior --> $DIR/invalid_from_utf8.rs:63:9 | +LL | str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_mut` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:83:9 + | LL | std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^ | | | the literal was valid UTF-8 up to the 2 bytes | note: the lint level is defined here - --> $DIR/invalid_from_utf8.rs:6:9 + --> $DIR/invalid_from_utf8.rs:5:9 | LL | #![warn(invalid_from_utf8)] | ^^^^^^^^^^^^^^^^^ -warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:65:9 +warning: calls to `str::from_utf8_mut` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:85:9 + | +LL | str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]); + | ^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_mut` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:87:9 | LL | std::str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:83:9 +warning: calls to `str::from_utf8_mut` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:89:9 + | +LL | str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + | ^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:111:9 | LL | std::str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]); | ^^^^^^^^^^^^^^^^^^^^^----------------------------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:85:9 +warning: calls to `str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:113:9 + | +LL | str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]); + | ^^^^^^^^^^^^^^^^----------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:115:9 | LL | std::str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); | ^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:87:9 +warning: calls to `str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:117:9 + | +LL | str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + | ^^^^^^^^^^^^^^^^---------------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:119:9 | LL | std::str::from_utf8(b"cl\x82ippy"); | ^^^^^^^^^^^^^^^^^^^^-------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:89:9 +warning: calls to `str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:121:9 + | +LL | str::from_utf8(b"cl\x82ippy"); + | ^^^^^^^^^^^^^^^-------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:123:9 | LL | std::str::from_utf8(concat_bytes!(b"cl", b"\x82ippy")); | ^^^^^^^^^^^^^^^^^^^^---------------------------------^ | | | the literal was valid UTF-8 up to the 2 bytes -warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:96:5 +warning: calls to `str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:125:9 + | +LL | str::from_utf8(concat_bytes!(b"cl", b"\x82ippy")); + | ^^^^^^^^^^^^^^^---------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_mut` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:132:5 | LL | let mut a = [99, 108, 130, 105, 112, 112, 121]; | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes LL | std::str::from_utf8_mut(&mut a); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:100:5 +warning: calls to `str::from_utf8_mut` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:134:5 + | +LL | let mut a = [99, 108, 130, 105, 112, 112, 121]; + | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes +... +LL | str::from_utf8_mut(&mut a); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::str::from_utf8_mut` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:138:5 | LL | let mut a = [99, 108, 130, 105, 112, 112, 121]; | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes @@ -123,45 +228,99 @@ LL | let mut a = [99, 108, 130, 105, 112, 112, 121]; LL | std::str::from_utf8_mut(c); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: calls to `std::str::from_utf8` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:103:5 +warning: calls to `str::from_utf8_mut` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:140:5 + | +LL | let mut a = [99, 108, 130, 105, 112, 112, 121]; + | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes +... +LL | str::from_utf8_mut(c); + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:143:5 | LL | let mut c = &[99, 108, 130, 105, 112, 112, 121]; | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes LL | std::str::from_utf8(c); | ^^^^^^^^^^^^^^^^^^^^^^ -warning: calls to `std::str::from_utf8` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:106:5 +warning: calls to `str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:145:5 + | +LL | let mut c = &[99, 108, 130, 105, 112, 112, 121]; + | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes +... +LL | str::from_utf8(c); + | ^^^^^^^^^^^^^^^^^ + +warning: calls to `std::str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:148:5 | LL | const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121]; | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes LL | std::str::from_utf8(&INVALID_1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: calls to `std::str::from_utf8` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:109:5 +warning: calls to `str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:150:5 + | +LL | const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121]; + | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes +... +LL | str::from_utf8(&INVALID_1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:153:5 | LL | static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121]; | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes LL | std::str::from_utf8(&INVALID_2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: calls to `std::str::from_utf8` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:112:5 +warning: calls to `str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:155:5 + | +LL | static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121]; + | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes +... +LL | str::from_utf8(&INVALID_2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:158:5 | LL | const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121]; | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes LL | std::str::from_utf8(INVALID_3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: calls to `std::str::from_utf8` with a invalid literal always return an error - --> $DIR/invalid_from_utf8.rs:115:5 +warning: calls to `str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:160:5 + | +LL | const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121]; + | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes +... +LL | str::from_utf8(INVALID_3); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:163:5 | LL | const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] }; | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes LL | std::str::from_utf8(INVALID_4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: 19 warnings emitted +warning: calls to `str::from_utf8` with an invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:165:5 + | +LL | const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] }; + | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes +... +LL | str::from_utf8(INVALID_4); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 38 warnings emitted diff --git a/tests/ui/lint/issue-109152.stderr b/tests/ui/lint/issue-109152.stderr index a175964ccf6..01aa9068da5 100644 --- a/tests/ui/lint/issue-109152.stderr +++ b/tests/ui/lint/issue-109152.stderr @@ -16,8 +16,9 @@ LL | #![deny(map_unit_fn)] | ^^^^^^^^^^^ help: you might have meant to use `Iterator::for_each` | -LL | vec![42].iter().for_each(drop); - | ~~~~~~~~ +LL - vec![42].iter().map(drop); +LL + vec![42].iter().for_each(drop); + | error: aborting due to 1 previous error diff --git a/tests/ui/lint/issue-109529.stderr b/tests/ui/lint/issue-109529.stderr index 9e857d1b0ab..51b71cb1007 100644 --- a/tests/ui/lint/issue-109529.stderr +++ b/tests/ui/lint/issue-109529.stderr @@ -16,8 +16,9 @@ LL | for _ in 0..(256 as u8) {} | help: use an inclusive range instead | -LL | for _ in 0..=(255 as u8) {} - | + ~~~ +LL - for _ in 0..(256 as u8) {} +LL + for _ in 0..=(255 as u8) {} + | error: aborting due to 2 previous errors diff --git a/tests/ui/lint/issue-35075.stderr b/tests/ui/lint/issue-35075.stderr index 08bdaa72858..f02f9e678b4 100644 --- a/tests/ui/lint/issue-35075.stderr +++ b/tests/ui/lint/issue-35075.stderr @@ -6,8 +6,9 @@ LL | inner: Foo<T> | help: there is an enum variant `Baz::Foo`; try using the variant's enum | -LL | inner: Baz - | ~~~ +LL - inner: Foo<T> +LL + inner: Baz + | error[E0412]: cannot find type `Foo` in this scope --> $DIR/issue-35075.rs:6:9 @@ -17,8 +18,9 @@ LL | Foo(Foo<T>) | help: there is an enum variant `Baz::Foo`; try using the variant's enum | -LL | Foo(Baz) - | ~~~ +LL - Foo(Foo<T>) +LL + Foo(Baz) + | error: aborting due to 2 previous errors diff --git a/tests/ui/lint/let_underscore/issue-119696-err-on-fn.stderr b/tests/ui/lint/let_underscore/issue-119696-err-on-fn.stderr index 70f9979556a..105506968b1 100644 --- a/tests/ui/lint/let_underscore/issue-119696-err-on-fn.stderr +++ b/tests/ui/lint/let_underscore/issue-119696-err-on-fn.stderr @@ -12,11 +12,12 @@ LL | #![deny(let_underscore_drop)] help: consider binding to an unused variable to avoid immediately dropping the value | LL | let _unused = foo(); - | ~~~~~~~ + | ++++++ help: consider immediately dropping the value | -LL | drop(foo()); - | ~~~~~ + +LL - let _ = foo(); +LL + drop(foo()); + | error: aborting due to 1 previous error diff --git a/tests/ui/lint/let_underscore/issue-119697-extra-let.stderr b/tests/ui/lint/let_underscore/issue-119697-extra-let.stderr index e4b1872bba5..3ff57ab441d 100644 --- a/tests/ui/lint/let_underscore/issue-119697-extra-let.stderr +++ b/tests/ui/lint/let_underscore/issue-119697-extra-let.stderr @@ -11,12 +11,14 @@ LL | #![deny(let_underscore_drop)] | ^^^^^^^^^^^^^^^^^^^ help: consider binding to an unused variable to avoid immediately dropping the value | -LL | let _unused = field; - | ~~~~~~~~~~~ +LL - _ = field; +LL + let _unused = field; + | help: consider immediately dropping the value | -LL | drop(field); - | ~~~~~ + +LL - _ = field; +LL + drop(field); + | error: non-binding let on a type that has a destructor --> $DIR/issue-119697-extra-let.rs:17:5 @@ -27,11 +29,12 @@ LL | let _ = field; help: consider binding to an unused variable to avoid immediately dropping the value | LL | let _unused = field; - | ~~~~~~~ + | ++++++ help: consider immediately dropping the value | -LL | drop(field); - | ~~~~~ + +LL - let _ = field; +LL + drop(field); + | error: aborting due to 2 previous errors diff --git a/tests/ui/lint/let_underscore/let_underscore_drop.stderr b/tests/ui/lint/let_underscore/let_underscore_drop.stderr index 09f2587063b..001827b0d37 100644 --- a/tests/ui/lint/let_underscore/let_underscore_drop.stderr +++ b/tests/ui/lint/let_underscore/let_underscore_drop.stderr @@ -12,11 +12,12 @@ LL | #![warn(let_underscore_drop)] help: consider binding to an unused variable to avoid immediately dropping the value | LL | let _unused = NontrivialDrop; - | ~~~~~~~ + | ++++++ help: consider immediately dropping the value | -LL | drop(NontrivialDrop); - | ~~~~~ + +LL - let _ = NontrivialDrop; +LL + drop(NontrivialDrop); + | warning: 1 warning emitted diff --git a/tests/ui/lint/let_underscore/let_underscore_lock.stderr b/tests/ui/lint/let_underscore/let_underscore_lock.stderr index fb8b9ec2203..a54a23e364b 100644 --- a/tests/ui/lint/let_underscore/let_underscore_lock.stderr +++ b/tests/ui/lint/let_underscore/let_underscore_lock.stderr @@ -8,11 +8,12 @@ LL | let _ = data.lock().unwrap(); help: consider binding to an unused variable to avoid immediately dropping the value | LL | let _unused = data.lock().unwrap(); - | ~~~~~~~ + | ++++++ help: consider immediately dropping the value | -LL | drop(data.lock().unwrap()); - | ~~~~~ + +LL - let _ = data.lock().unwrap(); +LL + drop(data.lock().unwrap()); + | error: non-binding let on a synchronization lock --> $DIR/let_underscore_lock.rs:12:9 @@ -23,11 +24,12 @@ LL | let _ = data.lock(); help: consider binding to an unused variable to avoid immediately dropping the value | LL | let _unused = data.lock(); - | ~~~~~~~ + | ++++++ help: consider immediately dropping the value | -LL | drop(data.lock()); - | ~~~~~ + +LL - let _ = data.lock(); +LL + drop(data.lock()); + | error: non-binding let on a synchronization lock --> $DIR/let_underscore_lock.rs:14:10 @@ -39,7 +41,7 @@ LL | let (_, _) = (data.lock(), 1); help: consider binding to an unused variable to avoid immediately dropping the value | LL | let (_unused, _) = (data.lock(), 1); - | ~~~~~~~ + | ++++++ error: non-binding let on a synchronization lock --> $DIR/let_underscore_lock.rs:16:26 @@ -51,7 +53,7 @@ LL | let (_a, Struct { a: _ }) = (0, Struct { a: data.lock() }); help: consider binding to an unused variable to avoid immediately dropping the value | LL | let (_a, Struct { a: _unused }) = (0, Struct { a: data.lock() }); - | ~~~~~~~ + | ++++++ error: non-binding let on a synchronization lock --> $DIR/let_underscore_lock.rs:18:6 diff --git a/tests/ui/lint/lint-ctypes-enum.rs b/tests/ui/lint/lint-ctypes-enum.rs index 19af1de9576..0d19d5b5347 100644 --- a/tests/ui/lint/lint-ctypes-enum.rs +++ b/tests/ui/lint/lint-ctypes-enum.rs @@ -94,6 +94,7 @@ extern "C" { fn option_transparent_union(x: Option<TransparentUnion<num::NonZero<u8>>>); //~^ ERROR `extern` block uses type fn option_repr_rust(x: Option<Rust<num::NonZero<u8>>>); //~ ERROR `extern` block uses type + fn option_u8(x: Option<u8>); //~ ERROR `extern` block uses type fn result_ref_t(x: Result<&'static u8, ()>); fn result_fn_t(x: Result<extern "C" fn(), ()>); diff --git a/tests/ui/lint/lint-ctypes-enum.stderr b/tests/ui/lint/lint-ctypes-enum.stderr index 8e92e7e6946..a491bd19605 100644 --- a/tests/ui/lint/lint-ctypes-enum.stderr +++ b/tests/ui/lint/lint-ctypes-enum.stderr @@ -79,8 +79,17 @@ LL | fn option_repr_rust(x: Option<Rust<num::NonZero<u8>>>); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint +error: `extern` block uses type `Option<u8>`, which is not FFI-safe + --> $DIR/lint-ctypes-enum.rs:97:21 + | +LL | fn option_u8(x: Option<u8>); + | ^^^^^^^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum + = note: enum has no representation hint + error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:106:33 + --> $DIR/lint-ctypes-enum.rs:107:33 | LL | fn result_nonzero_u128_t(x: Result<num::NonZero<u128>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -88,7 +97,7 @@ LL | fn result_nonzero_u128_t(x: Result<num::NonZero<u128>, ()>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:113:33 + --> $DIR/lint-ctypes-enum.rs:114:33 | LL | fn result_nonzero_i128_t(x: Result<num::NonZero<i128>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -96,7 +105,7 @@ LL | fn result_nonzero_i128_t(x: Result<num::NonZero<i128>, ()>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `Result<TransparentUnion<NonZero<u8>>, ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:118:38 + --> $DIR/lint-ctypes-enum.rs:119:38 | LL | fn result_transparent_union_t(x: Result<TransparentUnion<num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -105,7 +114,7 @@ LL | fn result_transparent_union_t(x: Result<TransparentUnion<num::NonZero<u = note: enum has no representation hint error: `extern` block uses type `Result<Rust<NonZero<u8>>, ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:120:30 + --> $DIR/lint-ctypes-enum.rs:121:30 | LL | fn result_repr_rust_t(x: Result<Rust<num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -114,7 +123,7 @@ LL | fn result_repr_rust_t(x: Result<Rust<num::NonZero<u8>>, ()>); = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, U>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:124:51 + --> $DIR/lint-ctypes-enum.rs:125:51 | LL | fn result_1zst_exhaustive_single_variant_t(x: Result<num::NonZero<u8>, U>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -123,7 +132,7 @@ LL | fn result_1zst_exhaustive_single_variant_t(x: Result<num::NonZero<u8>, = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, B>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:126:53 + --> $DIR/lint-ctypes-enum.rs:127:53 | LL | fn result_1zst_exhaustive_multiple_variant_t(x: Result<num::NonZero<u8>, B>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -132,7 +141,7 @@ LL | fn result_1zst_exhaustive_multiple_variant_t(x: Result<num::NonZero<u8> = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, NonExhaustive>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:128:51 + --> $DIR/lint-ctypes-enum.rs:129:51 | LL | fn result_1zst_non_exhaustive_no_variant_t(x: Result<num::NonZero<u8>, NonExhaustive>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -141,7 +150,7 @@ LL | fn result_1zst_non_exhaustive_no_variant_t(x: Result<num::NonZero<u8>, = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, Field>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:131:49 + --> $DIR/lint-ctypes-enum.rs:132:49 | LL | fn result_1zst_exhaustive_single_field_t(x: Result<num::NonZero<u8>, Field>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -150,7 +159,7 @@ LL | fn result_1zst_exhaustive_single_field_t(x: Result<num::NonZero<u8>, Fi = note: enum has no representation hint error: `extern` block uses type `Result<Result<(), NonZero<u8>>, ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:133:30 + --> $DIR/lint-ctypes-enum.rs:134:30 | LL | fn result_cascading_t(x: Result<Result<(), num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -159,7 +168,7 @@ LL | fn result_cascading_t(x: Result<Result<(), num::NonZero<u8>>, ()>); = note: enum has no representation hint error: `extern` block uses type `u128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:144:33 + --> $DIR/lint-ctypes-enum.rs:145:33 | LL | fn result_nonzero_u128_e(x: Result<(), num::NonZero<u128>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -167,7 +176,7 @@ LL | fn result_nonzero_u128_e(x: Result<(), num::NonZero<u128>>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `i128`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:151:33 + --> $DIR/lint-ctypes-enum.rs:152:33 | LL | fn result_nonzero_i128_e(x: Result<(), num::NonZero<i128>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -175,7 +184,7 @@ LL | fn result_nonzero_i128_e(x: Result<(), num::NonZero<i128>>); = note: 128-bit integers don't currently have a known stable ABI error: `extern` block uses type `Result<(), TransparentUnion<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:156:38 + --> $DIR/lint-ctypes-enum.rs:157:38 | LL | fn result_transparent_union_e(x: Result<(), TransparentUnion<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -184,7 +193,7 @@ LL | fn result_transparent_union_e(x: Result<(), TransparentUnion<num::NonZe = note: enum has no representation hint error: `extern` block uses type `Result<(), Rust<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:158:30 + --> $DIR/lint-ctypes-enum.rs:159:30 | LL | fn result_repr_rust_e(x: Result<(), Rust<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -193,7 +202,7 @@ LL | fn result_repr_rust_e(x: Result<(), Rust<num::NonZero<u8>>>); = note: enum has no representation hint error: `extern` block uses type `Result<U, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:162:51 + --> $DIR/lint-ctypes-enum.rs:163:51 | LL | fn result_1zst_exhaustive_single_variant_e(x: Result<U, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -202,7 +211,7 @@ LL | fn result_1zst_exhaustive_single_variant_e(x: Result<U, num::NonZero<u8 = note: enum has no representation hint error: `extern` block uses type `Result<B, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:164:53 + --> $DIR/lint-ctypes-enum.rs:165:53 | LL | fn result_1zst_exhaustive_multiple_variant_e(x: Result<B, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -211,7 +220,7 @@ LL | fn result_1zst_exhaustive_multiple_variant_e(x: Result<B, num::NonZero< = note: enum has no representation hint error: `extern` block uses type `Result<NonExhaustive, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:166:51 + --> $DIR/lint-ctypes-enum.rs:167:51 | LL | fn result_1zst_non_exhaustive_no_variant_e(x: Result<NonExhaustive, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -220,7 +229,7 @@ LL | fn result_1zst_non_exhaustive_no_variant_e(x: Result<NonExhaustive, num = note: enum has no representation hint error: `extern` block uses type `Result<Field, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:169:49 + --> $DIR/lint-ctypes-enum.rs:170:49 | LL | fn result_1zst_exhaustive_single_field_e(x: Result<Field, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -229,7 +238,7 @@ LL | fn result_1zst_exhaustive_single_field_e(x: Result<Field, num::NonZero< = note: enum has no representation hint error: `extern` block uses type `Result<(), Result<(), NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:171:30 + --> $DIR/lint-ctypes-enum.rs:172:30 | LL | fn result_cascading_e(x: Result<(), Result<(), num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -238,7 +247,7 @@ LL | fn result_cascading_e(x: Result<(), Result<(), num::NonZero<u8>>>); = note: enum has no representation hint error: `extern` block uses type `Result<(), ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:173:27 + --> $DIR/lint-ctypes-enum.rs:174:27 | LL | fn result_unit_t_e(x: Result<(), ()>); | ^^^^^^^^^^^^^^ not FFI-safe @@ -246,5 +255,5 @@ LL | fn result_unit_t_e(x: Result<(), ()>); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint -error: aborting due to 26 previous errors +error: aborting due to 27 previous errors diff --git a/tests/ui/lint/lint-overflowing-int-136675.rs b/tests/ui/lint/lint-overflowing-int-136675.rs new file mode 100644 index 00000000000..616531519a6 --- /dev/null +++ b/tests/ui/lint/lint-overflowing-int-136675.rs @@ -0,0 +1,4 @@ +fn main() { + if let -129 = 0i8 {} //~ ERROR literal out of range for `i8` + let x: i8 = -129; //~ ERROR literal out of range for `i8` +} diff --git a/tests/ui/lint/lint-overflowing-int-136675.stderr b/tests/ui/lint/lint-overflowing-int-136675.stderr new file mode 100644 index 00000000000..3b67c663ac2 --- /dev/null +++ b/tests/ui/lint/lint-overflowing-int-136675.stderr @@ -0,0 +1,21 @@ +error: literal out of range for `i8` + --> $DIR/lint-overflowing-int-136675.rs:2:12 + | +LL | if let -129 = 0i8 {} + | ^^^^ + | + = note: the literal `-129` does not fit into the type `i8` whose range is `-128..=127` + = help: consider using the type `i16` instead + = note: `#[deny(overflowing_literals)]` on by default + +error: literal out of range for `i8` + --> $DIR/lint-overflowing-int-136675.rs:3:17 + | +LL | let x: i8 = -129; + | ^^^^ + | + = note: the literal `-129` does not fit into the type `i8` whose range is `-128..=127` + = help: consider using the type `i16` instead + +error: aborting due to 2 previous errors + diff --git a/tests/ui/lint/lint-strict-provenance-fuzzy-casts.stderr b/tests/ui/lint/lint-strict-provenance-fuzzy-casts.stderr index 24f2500abf8..f5eec6fc656 100644 --- a/tests/ui/lint/lint-strict-provenance-fuzzy-casts.stderr +++ b/tests/ui/lint/lint-strict-provenance-fuzzy-casts.stderr @@ -12,8 +12,9 @@ LL | #![deny(fuzzy_provenance_casts)] | ^^^^^^^^^^^^^^^^^^^^^^ help: use `.with_addr()` to adjust a valid pointer in the same allocation, to this address | -LL | let dangling = (...).with_addr(16_usize); - | ++++++++++++++++ ~ +LL - let dangling = 16_usize as *const u8; +LL + let dangling = (...).with_addr(16_usize); + | error: aborting due to 1 previous error diff --git a/tests/ui/lint/lint-strict-provenance-lossy-casts.stderr b/tests/ui/lint/lint-strict-provenance-lossy-casts.stderr index 390028b349e..bcef0ae424e 100644 --- a/tests/ui/lint/lint-strict-provenance-lossy-casts.stderr +++ b/tests/ui/lint/lint-strict-provenance-lossy-casts.stderr @@ -12,8 +12,9 @@ LL | #![deny(lossy_provenance_casts)] | ^^^^^^^^^^^^^^^^^^^^^^ help: use `.addr()` to obtain the address of a pointer | -LL | let addr: usize = (&x as *const u8).addr(); - | + ~~~~~~~~ +LL - let addr: usize = &x as *const u8 as usize; +LL + let addr: usize = (&x as *const u8).addr(); + | error: under strict provenance it is considered bad style to cast pointer `*const u8` to integer `u32` --> $DIR/lint-strict-provenance-lossy-casts.rs:9:22 @@ -25,7 +26,7 @@ LL | let addr_32bit = &x as *const u8 as u32; help: use `.addr()` to obtain the address of a pointer | LL | let addr_32bit = (&x as *const u8).addr() as u32; - | + ~~~~~~~~~~~~~~~ + | + ++++++++ error: under strict provenance it is considered bad style to cast pointer `*const u8` to integer `usize` --> $DIR/lint-strict-provenance-lossy-casts.rs:14:20 diff --git a/tests/ui/lint/lint_map_unit_fn.stderr b/tests/ui/lint/lint_map_unit_fn.stderr index fbf689c5421..91542af0f6d 100644 --- a/tests/ui/lint/lint_map_unit_fn.stderr +++ b/tests/ui/lint/lint_map_unit_fn.stderr @@ -18,8 +18,9 @@ LL | #![deny(map_unit_fn)] | ^^^^^^^^^^^ help: you might have meant to use `Iterator::for_each` | -LL | x.iter_mut().for_each(foo); - | ~~~~~~~~ +LL - x.iter_mut().map(foo); +LL + x.iter_mut().for_each(foo); + | error: `Iterator::map` call that discard the iterator's values --> $DIR/lint_map_unit_fn.rs:11:18 @@ -41,8 +42,9 @@ LL | | | }); = note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated help: you might have meant to use `Iterator::for_each` | -LL | x.iter_mut().for_each(|items| { - | ~~~~~~~~ +LL - x.iter_mut().map(|items| { +LL + x.iter_mut().for_each(|items| { + | error: `Iterator::map` call that discard the iterator's values --> $DIR/lint_map_unit_fn.rs:18:18 @@ -59,8 +61,9 @@ LL | x.iter_mut().map(f); = note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated help: you might have meant to use `Iterator::for_each` | -LL | x.iter_mut().for_each(f); - | ~~~~~~~~ +LL - x.iter_mut().map(f); +LL + x.iter_mut().for_each(f); + | error: aborting due to 3 previous errors diff --git a/tests/ui/lint/non-snake-case/lint-non-snake-case-identifiers-suggestion-reserved.stderr b/tests/ui/lint/non-snake-case/lint-non-snake-case-identifiers-suggestion-reserved.stderr index 2841815ecf2..ae2a00d3f90 100644 --- a/tests/ui/lint/non-snake-case/lint-non-snake-case-identifiers-suggestion-reserved.stderr +++ b/tests/ui/lint/non-snake-case/lint-non-snake-case-identifiers-suggestion-reserved.stderr @@ -30,8 +30,9 @@ LL | #![deny(non_snake_case)] | ^^^^^^^^^^^^^^ help: rename the identifier or convert it to a snake case raw identifier | -LL | mod r#impl {} - | ~~~~~~ +LL - mod Impl {} +LL + mod r#impl {} + | error: function `While` should have a snake case name --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:8:4 @@ -41,8 +42,9 @@ LL | fn While() {} | help: rename the identifier or convert it to a snake case raw identifier | -LL | fn r#while() {} - | ~~~~~~~ +LL - fn While() {} +LL + fn r#while() {} + | error: variable `Mod` should have a snake case name --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:12:9 @@ -52,8 +54,9 @@ LL | let Mod: usize = 0; | help: rename the identifier or convert it to a snake case raw identifier | -LL | let r#mod: usize = 0; - | ~~~~~ +LL - let Mod: usize = 0; +LL + let r#mod: usize = 0; + | error: variable `Super` should have a snake case name --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:16:9 diff --git a/tests/ui/lint/recommend-literal.stderr b/tests/ui/lint/recommend-literal.stderr index 424ecadd4b8..263071ca9a7 100644 --- a/tests/ui/lint/recommend-literal.stderr +++ b/tests/ui/lint/recommend-literal.stderr @@ -33,12 +33,14 @@ LL | let v2: Bool = true; | help: a builtin type with a similar name exists | -LL | let v2: bool = true; - | ~~~~ +LL - let v2: Bool = true; +LL + let v2: bool = true; + | help: perhaps you intended to use this type | -LL | let v2: bool = true; - | ~~~~ +LL - let v2: Bool = true; +LL + let v2: bool = true; + | error[E0412]: cannot find type `boolean` in this scope --> $DIR/recommend-literal.rs:19:9 @@ -75,8 +77,9 @@ LL | depth: Option<int>, | help: perhaps you intended to use this type | -LL | depth: Option<i32>, - | ~~~ +LL - depth: Option<int>, +LL + depth: Option<i32>, + | help: you might be missing a type parameter | LL | struct Data<int> { diff --git a/tests/ui/lint/static-mut-refs.e2021.stderr b/tests/ui/lint/static-mut-refs.e2021.stderr index 5a4e712b3c0..00a2ca99f24 100644 --- a/tests/ui/lint/static-mut-refs.e2021.stderr +++ b/tests/ui/lint/static-mut-refs.e2021.stderr @@ -10,7 +10,7 @@ LL | let _y = &X; help: use `&raw const` instead to create a raw pointer | LL | let _y = &raw const X; - | ~~~~~~~~~~ + | +++++++++ warning: creating a mutable reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:42:18 @@ -23,7 +23,7 @@ LL | let _y = &mut X; help: use `&raw mut` instead to create a raw pointer | LL | let _y = &raw mut X; - | ~~~~~~~~ + | +++ warning: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:50:22 @@ -45,7 +45,7 @@ LL | let (_b, _c) = (&X, &Y); help: use `&raw const` instead to create a raw pointer | LL | let (_b, _c) = (&raw const X, &Y); - | ~~~~~~~~~~ + | +++++++++ warning: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:54:29 @@ -58,7 +58,7 @@ LL | let (_b, _c) = (&X, &Y); help: use `&raw const` instead to create a raw pointer | LL | let (_b, _c) = (&X, &raw const Y); - | ~~~~~~~~~~ + | +++++++++ warning: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:60:13 @@ -71,7 +71,7 @@ LL | foo(&X); help: use `&raw const` instead to create a raw pointer | LL | foo(&raw const X); - | ~~~~~~~~~~ + | +++++++++ warning: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:66:17 @@ -102,7 +102,7 @@ LL | let _v = &A.value; help: use `&raw const` instead to create a raw pointer | LL | let _v = &raw const A.value; - | ~~~~~~~~~~ + | +++++++++ warning: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:80:18 @@ -115,7 +115,7 @@ LL | let _s = &A.s.value; help: use `&raw const` instead to create a raw pointer | LL | let _s = &raw const A.s.value; - | ~~~~~~~~~~ + | +++++++++ warning: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:84:22 diff --git a/tests/ui/lint/static-mut-refs.e2024.stderr b/tests/ui/lint/static-mut-refs.e2024.stderr index 1b549272bd5..ff41f316250 100644 --- a/tests/ui/lint/static-mut-refs.e2024.stderr +++ b/tests/ui/lint/static-mut-refs.e2024.stderr @@ -10,7 +10,7 @@ LL | let _y = &X; help: use `&raw const` instead to create a raw pointer | LL | let _y = &raw const X; - | ~~~~~~~~~~ + | +++++++++ error: creating a mutable reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:42:18 @@ -23,7 +23,7 @@ LL | let _y = &mut X; help: use `&raw mut` instead to create a raw pointer | LL | let _y = &raw mut X; - | ~~~~~~~~ + | +++ error: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:50:22 @@ -45,7 +45,7 @@ LL | let (_b, _c) = (&X, &Y); help: use `&raw const` instead to create a raw pointer | LL | let (_b, _c) = (&raw const X, &Y); - | ~~~~~~~~~~ + | +++++++++ error: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:54:29 @@ -58,7 +58,7 @@ LL | let (_b, _c) = (&X, &Y); help: use `&raw const` instead to create a raw pointer | LL | let (_b, _c) = (&X, &raw const Y); - | ~~~~~~~~~~ + | +++++++++ error: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:60:13 @@ -71,7 +71,7 @@ LL | foo(&X); help: use `&raw const` instead to create a raw pointer | LL | foo(&raw const X); - | ~~~~~~~~~~ + | +++++++++ error: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:66:17 @@ -102,7 +102,7 @@ LL | let _v = &A.value; help: use `&raw const` instead to create a raw pointer | LL | let _v = &raw const A.value; - | ~~~~~~~~~~ + | +++++++++ error: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:80:18 @@ -115,7 +115,7 @@ LL | let _s = &A.s.value; help: use `&raw const` instead to create a raw pointer | LL | let _s = &raw const A.s.value; - | ~~~~~~~~~~ + | +++++++++ error: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:84:22 diff --git a/tests/ui/lint/type-overflow.stderr b/tests/ui/lint/type-overflow.stderr index 9fdb05ed1c0..4d6403b1e7d 100644 --- a/tests/ui/lint/type-overflow.stderr +++ b/tests/ui/lint/type-overflow.stderr @@ -21,12 +21,13 @@ LL | let fail = 0b1000_0001i8; = note: the literal `0b1000_0001i8` (decimal `129`) does not fit into the type `i8` and will become `-127i8` help: consider using the type `u8` instead | -LL | let fail = 0b1000_0001u8; - | ~~~~~~~~~~~~~ +LL - let fail = 0b1000_0001i8; +LL + let fail = 0b1000_0001u8; + | help: to use as a negative number (decimal `-127`), consider using the type `u8` for the literal and cast it to `i8` | LL | let fail = 0b1000_0001u8 as i8; - | ~~~~~~~~~~~~~~~~~~~ + | +++++ warning: literal out of range for `i64` --> $DIR/type-overflow.rs:15:16 @@ -37,12 +38,13 @@ LL | let fail = 0x8000_0000_0000_0000i64; = note: the literal `0x8000_0000_0000_0000i64` (decimal `9223372036854775808`) does not fit into the type `i64` and will become `-9223372036854775808i64` help: consider using the type `u64` instead | -LL | let fail = 0x8000_0000_0000_0000u64; - | ~~~~~~~~~~~~~~~~~~~~~~~~ +LL - let fail = 0x8000_0000_0000_0000i64; +LL + let fail = 0x8000_0000_0000_0000u64; + | help: to use as a negative number (decimal `-9223372036854775808`), consider using the type `u64` for the literal and cast it to `i64` | LL | let fail = 0x8000_0000_0000_0000u64 as i64; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++ warning: literal out of range for `u32` --> $DIR/type-overflow.rs:19:16 @@ -63,7 +65,7 @@ LL | let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000; help: to use as a negative number (decimal `-170141183460469231731687303715884105728`), consider using the type `u128` for the literal and cast it to `i128` | LL | let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000u128 as i128; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++ warning: literal out of range for `i32` --> $DIR/type-overflow.rs:27:16 @@ -113,7 +115,7 @@ LL | let fail = 0x8FFF_FFFF_FFFF_FFFE; help: to use as a negative number (decimal `-2`), consider using the type `u32` for the literal and cast it to `i32` | LL | let fail = 0x8FFF_FFFF_FFFF_FFFEu32 as i32; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++ warning: literal out of range for `i8` --> $DIR/type-overflow.rs:46:17 diff --git a/tests/ui/lint/unaligned_references_fake_borrow.rs b/tests/ui/lint/unaligned_references_fake_borrow.rs new file mode 100644 index 00000000000..b0ef8b471ca --- /dev/null +++ b/tests/ui/lint/unaligned_references_fake_borrow.rs @@ -0,0 +1,27 @@ +//@ check-pass + +// Regression test for <https://github.com/rust-lang/rust/issues/137250>. + +// Ensure that we don't emit unaligned packed field reference errors for the fake +// borrows that we generate during match lowering. These fake borrows are there to +// ensure in *borrow-checking* that we don't modify the value being matched, but +// they are removed after the MIR is processed by `CleanupPostBorrowck`. + +#[repr(packed)] +pub struct Packed(i32); + +fn f(x: Packed) { + match &x { + Packed(4) => {}, + _ if true => {}, + _ => {} + } + + match x { + Packed(4) => {}, + _ if true => {}, + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/lint/unused/issue-67691-unused-field-in-or-pattern.stderr b/tests/ui/lint/unused/issue-67691-unused-field-in-or-pattern.stderr index 8fc2d1bc88f..2d43e612580 100644 --- a/tests/ui/lint/unused/issue-67691-unused-field-in-or-pattern.stderr +++ b/tests/ui/lint/unused/issue-67691-unused-field-in-or-pattern.stderr @@ -13,7 +13,7 @@ LL | #![deny(unused)] help: try ignoring the field | LL | A { i, j: _ } | B { i, j: _ } => { - | ~~~~ ~~~~ + | +++ +++ error: unused variable: `j` --> $DIR/issue-67691-unused-field-in-or-pattern.rs:30:16 @@ -23,8 +23,9 @@ LL | A { i, ref j } | B { i, ref j } => { | help: try ignoring the field | -LL | A { i, j: _ } | B { i, j: _ } => { - | ~~~~ ~~~~ +LL - A { i, ref j } | B { i, ref j } => { +LL + A { i, j: _ } | B { i, j: _ } => { + | error: unused variable: `j` --> $DIR/issue-67691-unused-field-in-or-pattern.rs:40:21 @@ -35,7 +36,7 @@ LL | Some(A { i, j } | B { i, j }) => { help: try ignoring the field | LL | Some(A { i, j: _ } | B { i, j: _ }) => { - | ~~~~ ~~~~ + | +++ +++ error: unused variable: `j` --> $DIR/issue-67691-unused-field-in-or-pattern.rs:52:21 @@ -45,8 +46,9 @@ LL | Some(A { i, ref j } | B { i, ref j }) => { | help: try ignoring the field | -LL | Some(A { i, j: _ } | B { i, j: _ }) => { - | ~~~~ ~~~~ +LL - Some(A { i, ref j } | B { i, ref j }) => { +LL + Some(A { i, j: _ } | B { i, j: _ }) => { + | error: unused variable: `i` --> $DIR/issue-67691-unused-field-in-or-pattern.rs:62:24 @@ -56,8 +58,9 @@ LL | MixedEnum::A { i } | MixedEnum::B(i) => { | help: try ignoring the field | -LL | MixedEnum::A { i: _ } | MixedEnum::B(_) => { - | ~~~~ ~ +LL - MixedEnum::A { i } | MixedEnum::B(i) => { +LL + MixedEnum::A { i: _ } | MixedEnum::B(_) => { + | error: unused variable: `i` --> $DIR/issue-67691-unused-field-in-or-pattern.rs:70:24 @@ -67,8 +70,9 @@ LL | MixedEnum::A { ref i } | MixedEnum::B(ref i) => { | help: try ignoring the field | -LL | MixedEnum::A { i: _ } | MixedEnum::B(_) => { - | ~~~~ ~ +LL - MixedEnum::A { ref i } | MixedEnum::B(ref i) => { +LL + MixedEnum::A { i: _ } | MixedEnum::B(_) => { + | error: aborting due to 6 previous errors diff --git a/tests/ui/lint/unused/unused_attributes-must_use.rs b/tests/ui/lint/unused/unused_attributes-must_use.rs index 51f868706b6..860fc5046d1 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.rs +++ b/tests/ui/lint/unused/unused_attributes-must_use.rs @@ -79,6 +79,11 @@ trait Use { #[must_use] //~ ERROR `#[must_use]` has no effect impl Use for () { type AssocTy = (); + + #[must_use] //~ ERROR `#[must_use]` has no effect + fn get_four(&self) -> usize { + 4 + } } #[must_use] //~ ERROR `#[must_use]` has no effect diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr index 9633767c442..28fd8eeb8cb 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.stderr +++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr @@ -76,43 +76,43 @@ LL | #[must_use] | ^^^^^^^^^^^ error: `#[must_use]` has no effect when applied to a trait alias - --> $DIR/unused_attributes-must_use.rs:84:1 + --> $DIR/unused_attributes-must_use.rs:89:1 | LL | #[must_use] | ^^^^^^^^^^^ error: `#[must_use]` has no effect when applied to a macro def - --> $DIR/unused_attributes-must_use.rs:87:1 + --> $DIR/unused_attributes-must_use.rs:92:1 | LL | #[must_use] | ^^^^^^^^^^^ error: `#[must_use]` has no effect when applied to a statement - --> $DIR/unused_attributes-must_use.rs:95:5 + --> $DIR/unused_attributes-must_use.rs:100:5 | LL | #[must_use] | ^^^^^^^^^^^ error: `#[must_use]` has no effect when applied to a closure - --> $DIR/unused_attributes-must_use.rs:99:13 + --> $DIR/unused_attributes-must_use.rs:104:13 | LL | let x = #[must_use] | ^^^^^^^^^^^ error: `#[must_use]` has no effect when applied to an match arm - --> $DIR/unused_attributes-must_use.rs:121:9 + --> $DIR/unused_attributes-must_use.rs:126:9 | LL | #[must_use] | ^^^^^^^^^^^ error: `#[must_use]` has no effect when applied to a struct field - --> $DIR/unused_attributes-must_use.rs:129:28 + --> $DIR/unused_attributes-must_use.rs:134:28 | LL | let s = PatternField { #[must_use] foo: 123 }; | ^^^^^^^^^^^ error: `#[must_use]` has no effect when applied to a pattern field - --> $DIR/unused_attributes-must_use.rs:130:24 + --> $DIR/unused_attributes-must_use.rs:135:24 | LL | let PatternField { #[must_use] foo } = s; | ^^^^^^^^^^^ @@ -129,6 +129,12 @@ error: `#[must_use]` has no effect when applied to an associated type LL | #[must_use] | ^^^^^^^^^^^ +error: `#[must_use]` has no effect when applied to a provided trait method + --> $DIR/unused_attributes-must_use.rs:83:5 + | +LL | #[must_use] + | ^^^^^^^^^^^ + error: `#[must_use]` has no effect when applied to a foreign static item --> $DIR/unused_attributes-must_use.rs:50:5 | @@ -136,7 +142,7 @@ LL | #[must_use] | ^^^^^^^^^^^ error: unused `X` that must be used - --> $DIR/unused_attributes-must_use.rs:103:5 + --> $DIR/unused_attributes-must_use.rs:108:5 | LL | X; | ^ @@ -152,7 +158,7 @@ LL | let _ = X; | +++++++ error: unused `Y` that must be used - --> $DIR/unused_attributes-must_use.rs:104:5 + --> $DIR/unused_attributes-must_use.rs:109:5 | LL | Y::Z; | ^^^^ @@ -163,7 +169,7 @@ LL | let _ = Y::Z; | +++++++ error: unused `U` that must be used - --> $DIR/unused_attributes-must_use.rs:105:5 + --> $DIR/unused_attributes-must_use.rs:110:5 | LL | U { unit: () }; | ^^^^^^^^^^^^^^ @@ -174,7 +180,7 @@ LL | let _ = U { unit: () }; | +++++++ error: unused return value of `U::method` that must be used - --> $DIR/unused_attributes-must_use.rs:106:5 + --> $DIR/unused_attributes-must_use.rs:111:5 | LL | U::method(); | ^^^^^^^^^^^ @@ -185,7 +191,7 @@ LL | let _ = U::method(); | +++++++ error: unused return value of `foo` that must be used - --> $DIR/unused_attributes-must_use.rs:107:5 + --> $DIR/unused_attributes-must_use.rs:112:5 | LL | foo(); | ^^^^^ @@ -196,7 +202,7 @@ LL | let _ = foo(); | +++++++ error: unused return value of `foreign_foo` that must be used - --> $DIR/unused_attributes-must_use.rs:110:9 + --> $DIR/unused_attributes-must_use.rs:115:9 | LL | foreign_foo(); | ^^^^^^^^^^^^^ @@ -207,7 +213,7 @@ LL | let _ = foreign_foo(); | +++++++ error: unused return value of `Use::get_four` that must be used - --> $DIR/unused_attributes-must_use.rs:118:5 + --> $DIR/unused_attributes-must_use.rs:123:5 | LL | ().get_four(); | ^^^^^^^^^^^^^ @@ -217,5 +223,5 @@ help: use `let _ = ...` to ignore the resulting value LL | let _ = ().get_four(); | +++++++ -error: aborting due to 28 previous errors +error: aborting due to 29 previous errors diff --git a/tests/ui/lint/wide_pointer_comparisons.stderr b/tests/ui/lint/wide_pointer_comparisons.stderr index 78548e308ed..5a0b914d832 100644 --- a/tests/ui/lint/wide_pointer_comparisons.stderr +++ b/tests/ui/lint/wide_pointer_comparisons.stderr @@ -7,8 +7,9 @@ LL | let _ = a == b; = note: `#[warn(ambiguous_wide_pointer_comparisons)]` on by default help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(a, b); - | ++++++++++++++++++ ~ + +LL - let _ = a == b; +LL + let _ = std::ptr::addr_eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:22:13 @@ -18,8 +19,9 @@ LL | let _ = a != b; | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(a, b); - | +++++++++++++++++++ ~ + +LL - let _ = a != b; +LL + let _ = !std::ptr::addr_eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:24:13 @@ -73,8 +75,9 @@ LL | let _ = PartialEq::eq(&a, &b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(a, b); - | ~~~~~~~~~~~~~~~~~~ ~ +LL - let _ = PartialEq::eq(&a, &b); +LL + let _ = std::ptr::addr_eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:35:13 @@ -84,8 +87,9 @@ LL | let _ = PartialEq::ne(&a, &b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(a, b); - | ~~~~~~~~~~~~~~~~~~~ ~ +LL - let _ = PartialEq::ne(&a, &b); +LL + let _ = !std::ptr::addr_eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:37:13 @@ -95,8 +99,9 @@ LL | let _ = a.eq(&b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(a, b); - | ++++++++++++++++++ ~ +LL - let _ = a.eq(&b); +LL + let _ = std::ptr::addr_eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:39:13 @@ -106,8 +111,9 @@ LL | let _ = a.ne(&b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(a, b); - | +++++++++++++++++++ ~ +LL - let _ = a.ne(&b); +LL + let _ = !std::ptr::addr_eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:41:13 @@ -183,8 +189,9 @@ LL | let _ = a == b; | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(a.as_ptr(), b.as_ptr()); - | ++++++++++++++++++ ~~~~~~~~~~ ++++++++++ +LL - let _ = a == b; +LL + let _ = std::ptr::addr_eq(a.as_ptr(), b.as_ptr()); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:59:17 @@ -205,8 +212,9 @@ LL | let _ = &a == &b; | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(a.as_ptr(), b.as_ptr()); - | ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ++++++++++ +LL - let _ = &a == &b; +LL + let _ = std::ptr::addr_eq(a.as_ptr(), b.as_ptr()); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:70:17 @@ -216,8 +224,9 @@ LL | let _ = a == b; | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(*a, *b); - | +++++++++++++++++++ ~~~ + +LL - let _ = a == b; +LL + let _ = std::ptr::addr_eq(*a, *b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:72:17 @@ -227,8 +236,9 @@ LL | let _ = a != b; | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(*a, *b); - | ++++++++++++++++++++ ~~~ + +LL - let _ = a != b; +LL + let _ = !std::ptr::addr_eq(*a, *b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:74:17 @@ -282,8 +292,9 @@ LL | let _ = PartialEq::eq(a, b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(*a, *b); - | ~~~~~~~~~~~~~~~~~~~ ~~~ +LL - let _ = PartialEq::eq(a, b); +LL + let _ = std::ptr::addr_eq(*a, *b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:85:17 @@ -293,8 +304,9 @@ LL | let _ = PartialEq::ne(a, b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(*a, *b); - | ~~~~~~~~~~~~~~~~~~~~ ~~~ +LL - let _ = PartialEq::ne(a, b); +LL + let _ = !std::ptr::addr_eq(*a, *b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:87:17 @@ -304,8 +316,9 @@ LL | let _ = PartialEq::eq(&a, &b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(*a, *b); - | ~~~~~~~~~~~~~~~~~~~ ~~~ +LL - let _ = PartialEq::eq(&a, &b); +LL + let _ = std::ptr::addr_eq(*a, *b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:89:17 @@ -315,8 +328,9 @@ LL | let _ = PartialEq::ne(&a, &b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(*a, *b); - | ~~~~~~~~~~~~~~~~~~~~ ~~~ +LL - let _ = PartialEq::ne(&a, &b); +LL + let _ = !std::ptr::addr_eq(*a, *b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:91:17 @@ -326,8 +340,9 @@ LL | let _ = a.eq(b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(*a, *b); - | +++++++++++++++++++ ~~~ +LL - let _ = a.eq(b); +LL + let _ = std::ptr::addr_eq(*a, *b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:93:17 @@ -337,8 +352,9 @@ LL | let _ = a.ne(b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(*a, *b); - | ++++++++++++++++++++ ~~~ +LL - let _ = a.ne(b); +LL + let _ = !std::ptr::addr_eq(*a, *b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:95:17 @@ -414,12 +430,14 @@ LL | let _ = s == s; | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(s, s); - | ++++++++++++++++++ ~ + +LL - let _ = s == s; +LL + let _ = std::ptr::addr_eq(s, s); + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | let _ = std::ptr::eq(s, s); - | +++++++++++++ ~ + +LL - let _ = s == s; +LL + let _ = std::ptr::eq(s, s); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:114:13 @@ -429,12 +447,14 @@ LL | let _ = s == s; | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(s, s); - | ++++++++++++++++++ ~ + +LL - let _ = s == s; +LL + let _ = std::ptr::addr_eq(s, s); + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | let _ = std::ptr::eq(s, s); - | +++++++++++++ ~ + +LL - let _ = s == s; +LL + let _ = std::ptr::eq(s, s); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:118:17 @@ -444,12 +464,14 @@ LL | let _ = a == b; | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(a, b); - | ++++++++++++++++++ ~ + +LL - let _ = a == b; +LL + let _ = std::ptr::addr_eq(a, b); + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | let _ = std::ptr::eq(a, b); - | +++++++++++++ ~ + +LL - let _ = a == b; +LL + let _ = std::ptr::eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:120:17 @@ -459,12 +481,14 @@ LL | let _ = a != b; | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(a, b); - | +++++++++++++++++++ ~ + +LL - let _ = a != b; +LL + let _ = !std::ptr::addr_eq(a, b); + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | let _ = !std::ptr::eq(a, b); - | ++++++++++++++ ~ + +LL - let _ = a != b; +LL + let _ = !std::ptr::eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:122:17 @@ -518,12 +542,14 @@ LL | let _ = PartialEq::eq(&a, &b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(a, b); - | ~~~~~~~~~~~~~~~~~~ ~ +LL - let _ = PartialEq::eq(&a, &b); +LL + let _ = std::ptr::addr_eq(a, b); + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | let _ = std::ptr::eq(a, b); - | ~~~~~~~~~~~~~ ~ +LL - let _ = PartialEq::eq(&a, &b); +LL + let _ = std::ptr::eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:133:17 @@ -533,12 +559,14 @@ LL | let _ = PartialEq::ne(&a, &b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(a, b); - | ~~~~~~~~~~~~~~~~~~~ ~ +LL - let _ = PartialEq::ne(&a, &b); +LL + let _ = !std::ptr::addr_eq(a, b); + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | let _ = !std::ptr::eq(a, b); - | ~~~~~~~~~~~~~~ ~ +LL - let _ = PartialEq::ne(&a, &b); +LL + let _ = !std::ptr::eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:135:17 @@ -548,12 +576,14 @@ LL | let _ = a.eq(&b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = std::ptr::addr_eq(a, b); - | ++++++++++++++++++ ~ +LL - let _ = a.eq(&b); +LL + let _ = std::ptr::addr_eq(a, b); + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | let _ = std::ptr::eq(a, b); - | +++++++++++++ ~ +LL - let _ = a.eq(&b); +LL + let _ = std::ptr::eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:137:17 @@ -563,12 +593,14 @@ LL | let _ = a.ne(&b); | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | let _ = !std::ptr::addr_eq(a, b); - | +++++++++++++++++++ ~ +LL - let _ = a.ne(&b); +LL + let _ = !std::ptr::addr_eq(a, b); + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | let _ = !std::ptr::eq(a, b); - | ++++++++++++++ ~ +LL - let _ = a.ne(&b); +LL + let _ = !std::ptr::eq(a, b); + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:142:9 @@ -578,12 +610,14 @@ LL | &*a == &*b | help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | std::ptr::addr_eq(*a, *b) - | ~~~~~~~~~~~~~~~~~~ ~ + +LL - &*a == &*b +LL + std::ptr::addr_eq(*a, *b) + | help: use explicit `std::ptr::eq` method to compare metadata and addresses | -LL | std::ptr::eq(*a, *b) - | ~~~~~~~~~~~~~ ~ + +LL - &*a == &*b +LL + std::ptr::eq(*a, *b) + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:153:14 @@ -608,8 +642,9 @@ LL | cmp!(a, b); = note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info) help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses | -LL | ($a:ident, $b:ident) => { std::ptr::addr_eq($a, $b) } - | ++++++++++++++++++ ~ + +LL - ($a:ident, $b:ident) => { $a == $b } +LL + ($a:ident, $b:ident) => { std::ptr::addr_eq($a, $b) } + | warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected --> $DIR/wide_pointer_comparisons.rs:169:37 |
