diff options
| author | bors <bors@rust-lang.org> | 2022-10-05 14:48:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-10-05 14:48:17 +0000 |
| commit | 24ac6a26bcf5be1ac841e7fe969bd992b3461f9d (patch) | |
| tree | e3445397f4accfe91104d99a1866c034943b75cf /src | |
| parent | 8c71b67159e1a3d0863caf28b7cefee0160cb927 (diff) | |
| parent | 4c644cdbf6b0ab4cd4c6861682212c1e53cb5b57 (diff) | |
| download | rust-24ac6a26bcf5be1ac841e7fe969bd992b3461f9d.tar.gz rust-24ac6a26bcf5be1ac841e7fe969bd992b3461f9d.zip | |
Auto merge of #102704 - Dylan-DPC:rollup-66ff8sm, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #100986 (Stop suggesting adding generic args for turbofish) - #101061 (panic-on-uninit: adjust checks to 0x01-filling) - #102440 (Only export `__tls_*` on wasm32-unknown-unknown.) - #102496 (Suggest `.into()` when all other coercion suggestions fail) - #102699 (Fix hamburger button color) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
18 files changed, 332 insertions, 164 deletions
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 96876a30a4e..140ce3ba9fc 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1826,6 +1826,7 @@ in storage.js plus the media query with (min-width: 701px) as an icon, it's okay to specify its sizes in pixels. */ font-size: 32px; border: none; + color: var(--main-color); } .sidebar-elems { diff --git a/src/test/rustdoc-gui/sidebar-mobile.goml b/src/test/rustdoc-gui/sidebar-mobile.goml index 033c6578349..04dcb532504 100644 --- a/src/test/rustdoc-gui/sidebar-mobile.goml +++ b/src/test/rustdoc-gui/sidebar-mobile.goml @@ -42,23 +42,24 @@ scroll-to: ".block.keyword li:nth-child(1)" compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543}) // Now checking the background color of the sidebar. +show-text: true local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"} reload: // Open the sidebar menu. click: ".sidebar-menu-toggle" -assert-css: (".sidebar", {"background-color": "rgb(80, 80, 80)"}) +assert-css: (".sidebar", {"background-color": "rgb(80, 80, 80)", "color": "rgb(221, 221, 221)"}) local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "ayu"} reload: // Open the sidebar menu. click: ".sidebar-menu-toggle" -assert-css: (".sidebar", {"background-color": "rgb(20, 25, 31)"}) +assert-css: (".sidebar", {"background-color": "rgb(20, 25, 31)", "color": "rgb(197, 197, 197)"}) local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "light"} reload: // Open the sidebar menu. click: ".sidebar-menu-toggle" -assert-css: (".sidebar", {"background-color": "rgb(245, 245, 245)"}) +assert-css: (".sidebar", {"background-color": "rgb(245, 245, 245)", "color": "rgb(0, 0, 0)"}) diff --git a/src/test/ui/consts/assert-type-intrinsics.rs b/src/test/ui/consts/assert-type-intrinsics.rs index 3ce3e1bdbac..6b5612dda90 100644 --- a/src/test/ui/consts/assert-type-intrinsics.rs +++ b/src/test/ui/consts/assert-type-intrinsics.rs @@ -11,12 +11,15 @@ fn main() { use std::mem::MaybeUninit; const _BAD1: () = unsafe { - MaybeUninit::<!>::uninit().assume_init(); + intrinsics::assert_inhabited::<!>(); //~ERROR: any use of this value will cause an error + //~^WARN: previously accepted }; const _BAD2: () = { - intrinsics::assert_uninit_valid::<bool>(); + intrinsics::assert_uninit_valid::<!>(); //~ERROR: any use of this value will cause an error + //~^WARN: previously accepted }; const _BAD3: () = { - intrinsics::assert_zero_valid::<&'static i32>(); + intrinsics::assert_zero_valid::<&'static i32>(); //~ERROR: any use of this value will cause an error + //~^WARN: previously accepted }; } diff --git a/src/test/ui/consts/assert-type-intrinsics.stderr b/src/test/ui/consts/assert-type-intrinsics.stderr index a183856dff8..9f97d836705 100644 --- a/src/test/ui/consts/assert-type-intrinsics.stderr +++ b/src/test/ui/consts/assert-type-intrinsics.stderr @@ -3,26 +3,26 @@ error: any use of this value will cause an error | LL | const _BAD1: () = unsafe { | --------------- -LL | MaybeUninit::<!>::uninit().assume_init(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` +LL | intrinsics::assert_inhabited::<!>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: `#[deny(const_err)]` on by default error: any use of this value will cause an error - --> $DIR/assert-type-intrinsics.rs:17:9 + --> $DIR/assert-type-intrinsics.rs:18:9 | LL | const _BAD2: () = { | --------------- -LL | intrinsics::assert_uninit_valid::<bool>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `bool` uninitialized, which is invalid +LL | intrinsics::assert_uninit_valid::<!>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> error: any use of this value will cause an error - --> $DIR/assert-type-intrinsics.rs:20:9 + --> $DIR/assert-type-intrinsics.rs:22:9 | LL | const _BAD3: () = { | --------------- @@ -40,8 +40,8 @@ error: any use of this value will cause an error | LL | const _BAD1: () = unsafe { | --------------- -LL | MaybeUninit::<!>::uninit().assume_init(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` +LL | intrinsics::assert_inhabited::<!>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> @@ -49,12 +49,12 @@ LL | MaybeUninit::<!>::uninit().assume_init(); Future breakage diagnostic: error: any use of this value will cause an error - --> $DIR/assert-type-intrinsics.rs:17:9 + --> $DIR/assert-type-intrinsics.rs:18:9 | LL | const _BAD2: () = { | --------------- -LL | intrinsics::assert_uninit_valid::<bool>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `bool` uninitialized, which is invalid +LL | intrinsics::assert_uninit_valid::<!>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> @@ -62,7 +62,7 @@ LL | intrinsics::assert_uninit_valid::<bool>(); Future breakage diagnostic: error: any use of this value will cause an error - --> $DIR/assert-type-intrinsics.rs:20:9 + --> $DIR/assert-type-intrinsics.rs:22:9 | LL | const _BAD3: () = { | --------------- diff --git a/src/test/ui/inference/need_type_info/concrete-impl.stderr b/src/test/ui/inference/need_type_info/concrete-impl.stderr index b79d34affa2..aa32969950d 100644 --- a/src/test/ui/inference/need_type_info/concrete-impl.stderr +++ b/src/test/ui/inference/need_type_info/concrete-impl.stderr @@ -3,11 +3,6 @@ error[E0282]: type annotations needed | LL | <Struct as Ambiguous<_>>::method(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous` - | -help: consider specifying the generic argument - | -LL | <Struct as Ambiguous::<_>>::method(); - | ~~~~~ error[E0283]: type annotations needed --> $DIR/concrete-impl.rs:13:5 @@ -22,10 +17,6 @@ LL | impl Ambiguous<One> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | impl Ambiguous<Two> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: consider specifying the generic argument - | -LL | <Struct as Ambiguous::<_>>::method(); - | ~~~~~ error: aborting due to 2 previous errors diff --git a/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.rs b/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.rs new file mode 100644 index 00000000000..3084f6eac67 --- /dev/null +++ b/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.rs @@ -0,0 +1,11 @@ +enum OhNo<T, U> { + A(T), + B(U), + C, +} + +fn uwu() { + OhNo::C::<u32, _>; //~ ERROR type annotations needed +} + +fn main() {} diff --git a/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.stderr b/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.stderr new file mode 100644 index 00000000000..2ad35ab039f --- /dev/null +++ b/src/test/ui/inference/need_type_info/do-not-suggest-generic-arguments-for-turbofish.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/do-not-suggest-generic-arguments-for-turbofish.rs:8:5 + | +LL | OhNo::C::<u32, _>; + | ^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the enum `OhNo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs b/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs index 4aa869cca35..ae44ffd29bd 100644 --- a/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs +++ b/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs @@ -34,6 +34,12 @@ enum OneVariant_NonZero { DeadVariant(Bar), } +#[allow(dead_code, non_camel_case_types)] +enum OneVariant_Ref { + Variant(&'static i32), + DeadVariant(Bar), +} + // An `Aggregate` abi enum where 0 is not a valid discriminant. #[allow(dead_code)] #[repr(i32)] @@ -63,6 +69,7 @@ enum ZeroIsValid { One(NonNull<()>) = 1, } +#[track_caller] fn test_panic_msg<T>(op: impl (FnOnce() -> T) + panic::UnwindSafe, msg: &str) { let err = panic::catch_unwind(op).err(); assert_eq!( @@ -71,6 +78,15 @@ fn test_panic_msg<T>(op: impl (FnOnce() -> T) + panic::UnwindSafe, msg: &str) { ); } +#[track_caller] +fn test_panic_msg_only_if_strict<T>(op: impl (FnOnce() -> T) + panic::UnwindSafe, msg: &str) { + let err = panic::catch_unwind(op).err(); + assert_eq!( + err.as_ref().and_then(|a| a.downcast_ref::<&str>()), + if cfg!(strict) { Some(&msg) } else { None }, + ); +} + fn main() { unsafe { // Uninhabited types @@ -139,92 +155,216 @@ fn main() { "attempted to instantiate uninhabited type `[Bar; 2]`" ); - // Types that do not like zero-initialziation + // Types that don't allow either. test_panic_msg( - || mem::uninitialized::<fn()>(), - "attempted to leave type `fn()` uninitialized, which is invalid" + || mem::zeroed::<&i32>(), + "attempted to zero-initialize type `&i32`, which is invalid" ); test_panic_msg( - || mem::zeroed::<fn()>(), - "attempted to zero-initialize type `fn()`, which is invalid" + || mem::uninitialized::<&i32>(), + "attempted to leave type `&i32` uninitialized, which is invalid" ); test_panic_msg( - || mem::uninitialized::<*const dyn Send>(), - "attempted to leave type `*const dyn core::marker::Send` uninitialized, which is invalid" + || mem::zeroed::<Box<[i32; 0]>>(), + "attempted to zero-initialize type `alloc::boxed::Box<[i32; 0]>`, which is invalid" + ); + test_panic_msg( + || mem::uninitialized::<Box<[i32; 0]>>(), + "attempted to leave type `alloc::boxed::Box<[i32; 0]>` uninitialized, which is invalid" + ); + + test_panic_msg( + || mem::zeroed::<Box<u8>>(), + "attempted to zero-initialize type `alloc::boxed::Box<u8>`, which is invalid" ); test_panic_msg( + || mem::uninitialized::<Box<u8>>(), + "attempted to leave type `alloc::boxed::Box<u8>` uninitialized, which is invalid" + ); + + test_panic_msg( + || mem::zeroed::<&[i32]>(), + "attempted to zero-initialize type `&[i32]`, which is invalid" + ); + test_panic_msg( + || mem::uninitialized::<&[i32]>(), + "attempted to leave type `&[i32]` uninitialized, which is invalid" + ); + + test_panic_msg( + || mem::zeroed::<&(u8, [u8])>(), + "attempted to zero-initialize type `&(u8, [u8])`, which is invalid" + ); + test_panic_msg( + || mem::uninitialized::<&(u8, [u8])>(), + "attempted to leave type `&(u8, [u8])` uninitialized, which is invalid" + ); + + test_panic_msg( + || mem::zeroed::<&dyn Send>(), + "attempted to zero-initialize type `&dyn core::marker::Send`, which is invalid" + ); + test_panic_msg( + || mem::uninitialized::<&dyn Send>(), + "attempted to leave type `&dyn core::marker::Send` uninitialized, which is invalid" + ); + + test_panic_msg( || mem::zeroed::<*const dyn Send>(), "attempted to zero-initialize type `*const dyn core::marker::Send`, which is invalid" ); + test_panic_msg( + || mem::uninitialized::<*const dyn Send>(), + "attempted to leave type `*const dyn core::marker::Send` uninitialized, which is invalid" + ); test_panic_msg( - || mem::uninitialized::<(NonNull<u32>, u32, u32)>(), - "attempted to leave type `(core::ptr::non_null::NonNull<u32>, u32, u32)` uninitialized, \ + || mem::uninitialized::<NoNullVariant>(), + "attempted to leave type `NoNullVariant` uninitialized, \ + which is invalid" + ); + test_panic_msg( + || mem::zeroed::<NoNullVariant>(), + "attempted to zero-initialize type `NoNullVariant`, \ which is invalid" ); test_panic_msg( - || mem::zeroed::<(NonNull<u32>, u32, u32)>(), - "attempted to zero-initialize type `(core::ptr::non_null::NonNull<u32>, u32, u32)`, \ + || mem::zeroed::<OneVariant_Ref>(), + "attempted to zero-initialize type `OneVariant_Ref`, \ which is invalid" ); + test_panic_msg( + || mem::uninitialized::<OneVariant_Ref>(), + "attempted to leave type `OneVariant_Ref` uninitialized, which is invalid" + ); + // Types where both are invalid, but we allow uninit since the 0x01-filling is not LLVM UB. test_panic_msg( - || mem::uninitialized::<OneVariant_NonZero>(), - "attempted to leave type `OneVariant_NonZero` uninitialized, \ + || mem::zeroed::<fn()>(), + "attempted to zero-initialize type `fn()`, which is invalid" + ); + test_panic_msg_only_if_strict( + || mem::uninitialized::<fn()>(), + "attempted to leave type `fn()` uninitialized, which is invalid" + ); + + test_panic_msg( + || mem::zeroed::<&()>(), + "attempted to zero-initialize type `&()`, which is invalid" + ); + test_panic_msg_only_if_strict( + || mem::uninitialized::<&()>(), + "attempted to leave type `&()` uninitialized, which is invalid" + ); + + test_panic_msg( + || mem::zeroed::<&[u8]>(), + "attempted to zero-initialize type `&[u8]`, which is invalid" + ); + test_panic_msg_only_if_strict( + || mem::uninitialized::<&[u8]>(), + "attempted to leave type `&[u8]` uninitialized, which is invalid" + ); + + test_panic_msg( + || mem::zeroed::<&str>(), + "attempted to zero-initialize type `&str`, which is invalid" + ); + test_panic_msg_only_if_strict( + || mem::uninitialized::<&str>(), + "attempted to leave type `&str` uninitialized, which is invalid" + ); + + test_panic_msg( + || mem::zeroed::<(NonNull<u32>, u32, u32)>(), + "attempted to zero-initialize type `(core::ptr::non_null::NonNull<u32>, u32, u32)`, \ which is invalid" ); + test_panic_msg_only_if_strict( + || mem::uninitialized::<(NonNull<u32>, u32, u32)>(), + "attempted to leave type `(core::ptr::non_null::NonNull<u32>, u32, u32)` uninitialized, which is invalid" + ); + test_panic_msg( || mem::zeroed::<OneVariant_NonZero>(), "attempted to zero-initialize type `OneVariant_NonZero`, \ which is invalid" ); + test_panic_msg_only_if_strict( + || mem::uninitialized::<OneVariant_NonZero>(), + "attempted to leave type `OneVariant_NonZero` uninitialized, which is invalid" + ); + // Types where both are invalid but we allow the zeroed form since it is not LLVM UB. + test_panic_msg_only_if_strict( + || mem::zeroed::<LR_NonZero>(), + "attempted to zero-initialize type `LR_NonZero`, which is invalid" + ); test_panic_msg( || mem::uninitialized::<LR_NonZero>(), "attempted to leave type `LR_NonZero` uninitialized, which is invalid" ); + test_panic_msg_only_if_strict( + || mem::zeroed::<ManuallyDrop<LR_NonZero>>(), + "attempted to zero-initialize type `core::mem::manually_drop::ManuallyDrop<LR_NonZero>`, \ + which is invalid" + ); test_panic_msg( || mem::uninitialized::<ManuallyDrop<LR_NonZero>>(), "attempted to leave type `core::mem::manually_drop::ManuallyDrop<LR_NonZero>` uninitialized, \ which is invalid" ); - test_panic_msg( - || mem::uninitialized::<NoNullVariant>(), - "attempted to leave type `NoNullVariant` uninitialized, \ - which is invalid" + // Some strict-only things + test_panic_msg_only_if_strict( + || mem::uninitialized::<i32>(), + "attempted to leave type `i32` uninitialized, which is invalid" ); - test_panic_msg( - || mem::zeroed::<NoNullVariant>(), - "attempted to zero-initialize type `NoNullVariant`, \ - which is invalid" + test_panic_msg_only_if_strict( + || mem::uninitialized::<*const ()>(), + "attempted to leave type `*const ()` uninitialized, which is invalid" ); - // Types that can be zero, but not uninit. - test_panic_msg( - || mem::uninitialized::<bool>(), - "attempted to leave type `bool` uninitialized, which is invalid" + test_panic_msg_only_if_strict( + || mem::uninitialized::<[i32; 1]>(), + "attempted to leave type `[i32; 1]` uninitialized, which is invalid" ); + test_panic_msg_only_if_strict( + || mem::zeroed::<[NonNull<()>; 1]>(), + "attempted to zero-initialize type `[core::ptr::non_null::NonNull<()>; 1]`, which is invalid" + ); + + // Types that can be zero, but not uninit (though some are mitigated). + let _val = mem::zeroed::<LR>(); test_panic_msg( || mem::uninitialized::<LR>(), "attempted to leave type `LR` uninitialized, which is invalid" ); + let _val = mem::zeroed::<ManuallyDrop<LR>>(); test_panic_msg( || mem::uninitialized::<ManuallyDrop<LR>>(), "attempted to leave type `core::mem::manually_drop::ManuallyDrop<LR>` uninitialized, which is invalid" ); - // Some things that should work. let _val = mem::zeroed::<bool>(); - let _val = mem::zeroed::<LR>(); - let _val = mem::zeroed::<ManuallyDrop<LR>>(); + test_panic_msg_only_if_strict( + || mem::uninitialized::<bool>(), + "attempted to leave type `bool` uninitialized, which is invalid" + ); + let _val = mem::zeroed::<OneVariant>(); + test_panic_msg_only_if_strict( + || mem::uninitialized::<OneVariant>(), + "attempted to leave type `OneVariant` uninitialized, which is invalid" + ); + + // Some things that are actually allowed. let _val = mem::zeroed::<Option<&'static i32>>(); let _val = mem::zeroed::<MaybeUninit<NonNull<u32>>>(); let _val = mem::zeroed::<[!; 0]>(); @@ -233,59 +373,5 @@ fn main() { let _val = mem::uninitialized::<[!; 0]>(); let _val = mem::uninitialized::<()>(); let _val = mem::uninitialized::<ZeroSized>(); - - if cfg!(strict) { - test_panic_msg( - || mem::uninitialized::<i32>(), - "attempted to leave type `i32` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::uninitialized::<*const ()>(), - "attempted to leave type `*const ()` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::uninitialized::<[i32; 1]>(), - "attempted to leave type `[i32; 1]` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<NonNull<()>>(), - "attempted to zero-initialize type `core::ptr::non_null::NonNull<()>`, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<[NonNull<()>; 1]>(), - "attempted to zero-initialize type `[core::ptr::non_null::NonNull<()>; 1]`, which is invalid" - ); - - // FIXME(#66151) we conservatively do not error here yet (by default). - test_panic_msg( - || mem::zeroed::<LR_NonZero>(), - "attempted to zero-initialize type `LR_NonZero`, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<ManuallyDrop<LR_NonZero>>(), - "attempted to zero-initialize type `core::mem::manually_drop::ManuallyDrop<LR_NonZero>`, \ - which is invalid" - ); - } else { - // These are UB because they have not been officially blessed, but we await the resolution - // of <https://github.com/rust-lang/unsafe-code-guidelines/issues/71> before doing - // anything about that. - let _val = mem::uninitialized::<i32>(); - let _val = mem::uninitialized::<*const ()>(); - - // These are UB, but best to test them to ensure we don't become unintentionally - // stricter. - - // It's currently unchecked to create invalid enums and values inside arrays. - let _val = mem::zeroed::<LR_NonZero>(); - let _val = mem::zeroed::<[LR_NonZero; 1]>(); - let _val = mem::zeroed::<[NonNull<()>; 1]>(); - let _val = mem::uninitialized::<[NonNull<()>; 1]>(); - } } } diff --git a/src/test/ui/issues/issue-24013.stderr b/src/test/ui/issues/issue-24013.stderr index 995dce552e3..72102f460e0 100644 --- a/src/test/ui/issues/issue-24013.stderr +++ b/src/test/ui/issues/issue-24013.stderr @@ -3,11 +3,6 @@ error[E0282]: type annotations needed | LL | unsafe {swap::<&mut _>(transmute(&a), transmute(&b))}; | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `swap` - | -help: consider specifying the generic argument - | -LL | unsafe {swap::<&mut _>(transmute(&a), transmute(&b))}; - | ~~~~~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-47486.stderr b/src/test/ui/issues/issue-47486.stderr index b45f57b7b84..2bd24f08c1e 100644 --- a/src/test/ui/issues/issue-47486.stderr +++ b/src/test/ui/issues/issue-47486.stderr @@ -9,11 +9,6 @@ error[E0282]: type annotations needed | LL | [0u8; std::mem::size_of::<_>()]; | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `size_of` - | -help: consider specifying the generic argument - | -LL | [0u8; std::mem::size_of::<_>()]; - | ~~~~~ error: aborting due to 2 previous errors diff --git a/src/test/ui/lint/invalid_value.rs b/src/test/ui/lint/invalid_value.rs index 51edb2b7baf..946a0e38861 100644 --- a/src/test/ui/lint/invalid_value.rs +++ b/src/test/ui/lint/invalid_value.rs @@ -88,6 +88,9 @@ fn main() { let _val: NonNull<i32> = mem::zeroed(); //~ ERROR: does not permit zero-initialization let _val: NonNull<i32> = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized + let _val: (NonZeroU32, i32) = mem::zeroed(); //~ ERROR: does not permit zero-initialization + let _val: (NonZeroU32, i32) = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized + let _val: *const dyn Send = mem::zeroed(); //~ ERROR: does not permit zero-initialization let _val: *const dyn Send = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized @@ -133,7 +136,7 @@ fn main() { let _val: Result<i32, i32> = mem::zeroed(); let _val: Result<i32, i32> = mem::uninitialized(); //~ ERROR: does not permit being left uninitialized - // Some things that happen to work due to rustc implementation details, + // Some things that happen to be UB-free due to rustc implementation details, // but are not guaranteed to keep working. let _val: OneFruit = mem::zeroed(); let _val: OneFruit = mem::uninitialized(); diff --git a/src/test/ui/lint/invalid_value.stderr b/src/test/ui/lint/invalid_value.stderr index f0dcf53dfee..3901692001a 100644 --- a/src/test/ui/lint/invalid_value.stderr +++ b/src/test/ui/lint/invalid_value.stderr @@ -315,8 +315,30 @@ LL | let _val: NonNull<i32> = mem::uninitialized(); | = note: `std::ptr::NonNull<i32>` must be non-null +error: the type `(NonZeroU32, i32)` does not permit zero-initialization + --> $DIR/invalid_value.rs:91:39 + | +LL | let _val: (NonZeroU32, i32) = mem::zeroed(); + | ^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done + | + = note: `std::num::NonZeroU32` must be non-null + +error: the type `(NonZeroU32, i32)` does not permit being left uninitialized + --> $DIR/invalid_value.rs:92:39 + | +LL | let _val: (NonZeroU32, i32) = mem::uninitialized(); + | ^^^^^^^^^^^^^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done + | + = note: `std::num::NonZeroU32` must be non-null + error: the type `*const dyn Send` does not permit zero-initialization - --> $DIR/invalid_value.rs:91:37 + --> $DIR/invalid_value.rs:94:37 | LL | let _val: *const dyn Send = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -327,7 +349,7 @@ LL | let _val: *const dyn Send = mem::zeroed(); = note: the vtable of a wide raw pointer must be non-null error: the type `*const dyn Send` does not permit being left uninitialized - --> $DIR/invalid_value.rs:92:37 + --> $DIR/invalid_value.rs:95:37 | LL | let _val: *const dyn Send = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -338,7 +360,7 @@ LL | let _val: *const dyn Send = mem::uninitialized(); = note: the vtable of a wide raw pointer must be non-null error: the type `[fn(); 2]` does not permit zero-initialization - --> $DIR/invalid_value.rs:94:31 + --> $DIR/invalid_value.rs:97:31 | LL | let _val: [fn(); 2] = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -349,7 +371,7 @@ LL | let _val: [fn(); 2] = mem::zeroed(); = note: function pointers must be non-null error: the type `[fn(); 2]` does not permit being left uninitialized - --> $DIR/invalid_value.rs:95:31 + --> $DIR/invalid_value.rs:98:31 | LL | let _val: [fn(); 2] = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -360,7 +382,7 @@ LL | let _val: [fn(); 2] = mem::uninitialized(); = note: function pointers must be non-null error: the type `TwoUninhabited` does not permit zero-initialization - --> $DIR/invalid_value.rs:97:36 + --> $DIR/invalid_value.rs:100:36 | LL | let _val: TwoUninhabited = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -375,7 +397,7 @@ LL | enum TwoUninhabited { | ^^^^^^^^^^^^^^^^^^^ error: the type `TwoUninhabited` does not permit being left uninitialized - --> $DIR/invalid_value.rs:98:36 + --> $DIR/invalid_value.rs:101:36 | LL | let _val: TwoUninhabited = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -390,7 +412,7 @@ LL | enum TwoUninhabited { | ^^^^^^^^^^^^^^^^^^^ error: the type `OneFruitNonZero` does not permit zero-initialization - --> $DIR/invalid_value.rs:100:37 + --> $DIR/invalid_value.rs:103:37 | LL | let _val: OneFruitNonZero = mem::zeroed(); | ^^^^^^^^^^^^^ @@ -405,7 +427,7 @@ LL | Banana(NonZeroU32), | ^^^^^^^^^^ error: the type `OneFruitNonZero` does not permit being left uninitialized - --> $DIR/invalid_value.rs:101:37 + --> $DIR/invalid_value.rs:104:37 | LL | let _val: OneFruitNonZero = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -420,7 +442,7 @@ LL | Banana(NonZeroU32), | ^^^^^^^^^^ error: the type `bool` does not permit being left uninitialized - --> $DIR/invalid_value.rs:105:26 + --> $DIR/invalid_value.rs:108:26 | LL | let _val: bool = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -431,7 +453,7 @@ LL | let _val: bool = mem::uninitialized(); = note: booleans must be either `true` or `false` error: the type `Wrap<char>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:108:32 + --> $DIR/invalid_value.rs:111:32 | LL | let _val: Wrap<char> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -446,7 +468,7 @@ LL | struct Wrap<T> { wrapped: T } | ^^^^^^^^^^ error: the type `NonBig` does not permit being left uninitialized - --> $DIR/invalid_value.rs:111:28 + --> $DIR/invalid_value.rs:114:28 | LL | let _val: NonBig = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -457,7 +479,7 @@ LL | let _val: NonBig = mem::uninitialized(); = note: `NonBig` must be initialized inside its custom valid range error: the type `Fruit` does not permit being left uninitialized - --> $DIR/invalid_value.rs:114:27 + --> $DIR/invalid_value.rs:117:27 | LL | let _val: Fruit = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -472,7 +494,7 @@ LL | enum Fruit { | ^^^^^^^^^^ error: the type `[bool; 2]` does not permit being left uninitialized - --> $DIR/invalid_value.rs:117:31 + --> $DIR/invalid_value.rs:120:31 | LL | let _val: [bool; 2] = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -483,7 +505,7 @@ LL | let _val: [bool; 2] = mem::uninitialized(); = note: booleans must be either `true` or `false` error: the type `i32` does not permit being left uninitialized - --> $DIR/invalid_value.rs:120:25 + --> $DIR/invalid_value.rs:123:25 | LL | let _val: i32 = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -494,7 +516,7 @@ LL | let _val: i32 = mem::uninitialized(); = note: integers must not be uninitialized error: the type `f32` does not permit being left uninitialized - --> $DIR/invalid_value.rs:123:25 + --> $DIR/invalid_value.rs:126:25 | LL | let _val: f32 = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -505,7 +527,7 @@ LL | let _val: f32 = mem::uninitialized(); = note: floats must not be uninitialized error: the type `*const ()` does not permit being left uninitialized - --> $DIR/invalid_value.rs:126:31 + --> $DIR/invalid_value.rs:129:31 | LL | let _val: *const () = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -516,7 +538,7 @@ LL | let _val: *const () = mem::uninitialized(); = note: raw pointers must not be uninitialized error: the type `*const [()]` does not permit being left uninitialized - --> $DIR/invalid_value.rs:129:33 + --> $DIR/invalid_value.rs:132:33 | LL | let _val: *const [()] = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -527,7 +549,7 @@ LL | let _val: *const [()] = mem::uninitialized(); = note: raw pointers must not be uninitialized error: the type `Result<i32, i32>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:134:38 + --> $DIR/invalid_value.rs:137:38 | LL | let _val: Result<i32, i32> = mem::uninitialized(); | ^^^^^^^^^^^^^^^^^^^^ @@ -542,7 +564,7 @@ LL | pub enum Result<T, E> { | ^^^^^^^^^^^^^^^^^^^^^ error: the type `&i32` does not permit zero-initialization - --> $DIR/invalid_value.rs:142:34 + --> $DIR/invalid_value.rs:145:34 | LL | let _val: &'static i32 = mem::transmute(0usize); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -553,7 +575,7 @@ LL | let _val: &'static i32 = mem::transmute(0usize); = note: references must be non-null error: the type `&[i32]` does not permit zero-initialization - --> $DIR/invalid_value.rs:143:36 + --> $DIR/invalid_value.rs:146:36 | LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -564,7 +586,7 @@ LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize)); = note: references must be non-null error: the type `NonZeroU32` does not permit zero-initialization - --> $DIR/invalid_value.rs:144:32 + --> $DIR/invalid_value.rs:147:32 | LL | let _val: NonZeroU32 = mem::transmute(0); | ^^^^^^^^^^^^^^^^^ @@ -575,7 +597,7 @@ LL | let _val: NonZeroU32 = mem::transmute(0); = note: `std::num::NonZeroU32` must be non-null error: the type `NonNull<i32>` does not permit zero-initialization - --> $DIR/invalid_value.rs:147:34 + --> $DIR/invalid_value.rs:150:34 | LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -586,7 +608,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init(); = note: `std::ptr::NonNull<i32>` must be non-null error: the type `NonNull<i32>` does not permit being left uninitialized - --> $DIR/invalid_value.rs:148:34 + --> $DIR/invalid_value.rs:151:34 | LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -597,7 +619,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init(); = note: `std::ptr::NonNull<i32>` must be non-null error: the type `bool` does not permit being left uninitialized - --> $DIR/invalid_value.rs:149:26 + --> $DIR/invalid_value.rs:152:26 | LL | let _val: bool = MaybeUninit::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -607,5 +629,5 @@ LL | let _val: bool = MaybeUninit::uninit().assume_init(); | = note: booleans must be either `true` or `false` -error: aborting due to 48 previous errors +error: aborting due to 50 previous errors diff --git a/src/test/ui/parser/expr-as-stmt-2.stderr b/src/test/ui/parser/expr-as-stmt-2.stderr index 9b939f05e02..2b6314c38ce 100644 --- a/src/test/ui/parser/expr-as-stmt-2.stderr +++ b/src/test/ui/parser/expr-as-stmt-2.stderr @@ -36,11 +36,6 @@ LL | / && LL | | if let Some(y) = a { true } else { false } | |______________________________________________^ expected `bool`, found `&&bool` | -help: consider removing the `&&` - | -LL - && -LL + if let Some(y) = a { true } else { false } - | help: parentheses are required to parse this as an expression | LL | (if let Some(x) = a { true } else { false }) diff --git a/src/test/ui/parser/expr-as-stmt.stderr b/src/test/ui/parser/expr-as-stmt.stderr index 858b4e8db05..6da4ac34067 100644 --- a/src/test/ui/parser/expr-as-stmt.stderr +++ b/src/test/ui/parser/expr-as-stmt.stderr @@ -170,11 +170,6 @@ LL | fn revenge_from_mars() -> bool { LL | { true } && { true } | ^^^^^^^^^^^ expected `bool`, found `&&bool` | -help: consider removing the `&&` - | -LL - { true } && { true } -LL + { true } { true } - | help: parentheses are required to parse this as an expression | LL | ({ true }) && { true } @@ -201,10 +196,6 @@ LL | { true } || { true } | = note: expected type `bool` found closure `[closure@$DIR/expr-as-stmt.rs:51:14: 51:16]` -help: use parentheses to call this closure - | -LL | { true } (|| { true })() - | + +++ help: parentheses are required to parse this as an expression | LL | ({ true }) || { true } diff --git a/src/test/ui/suggestions/boxed-variant-field.rs b/src/test/ui/suggestions/boxed-variant-field.rs index e79be2f6127..6050963c4ee 100644 --- a/src/test/ui/suggestions/boxed-variant-field.rs +++ b/src/test/ui/suggestions/boxed-variant-field.rs @@ -9,7 +9,6 @@ fn foo(x: Ty) -> Ty { Ty::List(elem) => foo(elem), //~^ ERROR mismatched types //~| HELP consider unboxing the value - //~| HELP try wrapping } } diff --git a/src/test/ui/suggestions/boxed-variant-field.stderr b/src/test/ui/suggestions/boxed-variant-field.stderr index 6dfb73480a2..9ae36a06a71 100644 --- a/src/test/ui/suggestions/boxed-variant-field.stderr +++ b/src/test/ui/suggestions/boxed-variant-field.stderr @@ -17,10 +17,6 @@ help: consider unboxing the value | LL | Ty::List(elem) => foo(*elem), | + -help: try wrapping the expression in `Ty::List` - | -LL | Ty::List(elem) => foo(Ty::List(elem)), - | +++++++++ + error: aborting due to previous error diff --git a/src/test/ui/suggestions/into-convert.rs b/src/test/ui/suggestions/into-convert.rs new file mode 100644 index 00000000000..1c9a9e0aaf5 --- /dev/null +++ b/src/test/ui/suggestions/into-convert.rs @@ -0,0 +1,26 @@ +use std::path::{Path, PathBuf}; +use std::sync::atomic::AtomicU32; +use std::sync::Arc; + +fn main() { + let x: A = B; + //~^ ERROR mismatched types + //~| HELP call `Into::into` on this expression to convert `B` into `A` + + let y: Arc<Path> = PathBuf::new(); + //~^ ERROR mismatched types + //~| HELP call `Into::into` on this expression to convert `PathBuf` into `Arc<Path>` + + let z: AtomicU32 = 1; + //~^ ERROR mismatched types + //~| HELP call `Into::into` on this expression to convert `{integer}` into `AtomicU32` +} + +struct A; +struct B; + +impl From<B> for A { + fn from(_: B) -> Self { + A + } +} diff --git a/src/test/ui/suggestions/into-convert.stderr b/src/test/ui/suggestions/into-convert.stderr new file mode 100644 index 00000000000..d43104a2172 --- /dev/null +++ b/src/test/ui/suggestions/into-convert.stderr @@ -0,0 +1,44 @@ +error[E0308]: mismatched types + --> $DIR/into-convert.rs:6:16 + | +LL | let x: A = B; + | - ^ expected struct `A`, found struct `B` + | | + | expected due to this + | +help: call `Into::into` on this expression to convert `B` into `A` + | +LL | let x: A = B.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/into-convert.rs:10:24 + | +LL | let y: Arc<Path> = PathBuf::new(); + | --------- ^^^^^^^^^^^^^^ expected struct `Arc`, found struct `PathBuf` + | | + | expected due to this + | + = note: expected struct `Arc<Path>` + found struct `PathBuf` +help: call `Into::into` on this expression to convert `PathBuf` into `Arc<Path>` + | +LL | let y: Arc<Path> = PathBuf::new().into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/into-convert.rs:14:24 + | +LL | let z: AtomicU32 = 1; + | --------- ^ expected struct `AtomicU32`, found integer + | | + | expected due to this + | +help: call `Into::into` on this expression to convert `{integer}` into `AtomicU32` + | +LL | let z: AtomicU32 = 1.into(); + | +++++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. |
