diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-03 15:30:52 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-25 08:12:16 +0000 |
| commit | fcb1f1874f8c1b40b2ba5228a905c7875b21ce88 (patch) | |
| tree | 8ac3347f36b9131db4a463c8e10e73cccd8842ed | |
| parent | 2e79f5f9f8b16444e86cb611d1f819023317d974 (diff) | |
| download | rust-fcb1f1874f8c1b40b2ba5228a905c7875b21ce88.tar.gz rust-fcb1f1874f8c1b40b2ba5228a905c7875b21ce88.zip | |
Don't show fields from other crates
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/lint/invalid_value.stderr | 38 |
2 files changed, 7 insertions, 35 deletions
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 2f3a2dcb819..4bde57881f0 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2499,7 +2499,9 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { ) -> Option<InitError> { let field_err = variant.fields.iter().find_map(|field| { ty_find_init_error(cx, field.ty(cx.tcx, substs), init).map(|mut err| { - if err.span.is_none() { + if !field.did.is_local() { + err + } else if err.span.is_none() { err.span = Some(cx.tcx.def_span(field.did)); write!(&mut err.message, " (in this {descr})").unwrap(); err diff --git a/src/test/ui/lint/invalid_value.stderr b/src/test/ui/lint/invalid_value.stderr index e9449605e35..9f0f51f4d97 100644 --- a/src/test/ui/lint/invalid_value.stderr +++ b/src/test/ui/lint/invalid_value.stderr @@ -332,11 +332,7 @@ LL | let _val: NonNull<i32> = mem::uninitialized(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `std::ptr::NonNull<i32>` must be non-null -note: raw pointers must not be uninitialized (in this struct field) - --> $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - | -LL | pointer: *const T, - | ^^^^^^^^^^^^^^^^^ + = note: raw pointers must not be uninitialized error: the type `(NonZeroU32, i32)` does not permit zero-initialization --> $DIR/invalid_value.rs:95:39 @@ -359,18 +355,7 @@ LL | let _val: (NonZeroU32, i32) = mem::uninitialized(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `std::num::NonZeroU32` must be non-null -note: integers must not be uninitialized (in this struct field) - --> $SRC_DIR/core/src/num/nonzero.rs:LL:COL - | -LL | / nonzero_integers! { -LL | | #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8); -LL | | #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16); -LL | | #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32); -... | -LL | | #[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIs... -LL | | } - | |_^ - = note: this error originates in the macro `nonzero_integers` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: integers must not be uninitialized error: the type `*const dyn Send` does not permit zero-initialization --> $DIR/invalid_value.rs:98:37 @@ -477,18 +462,7 @@ note: `std::num::NonZeroU32` must be non-null (in this field of the only potenti | LL | Banana(NonZeroU32), | ^^^^^^^^^^ -note: integers must not be uninitialized (in this struct field) - --> $SRC_DIR/core/src/num/nonzero.rs:LL:COL - | -LL | / nonzero_integers! { -LL | | #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8); -LL | | #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16); -LL | | #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32); -... | -LL | | #[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIs... -LL | | } - | |_^ - = note: this error originates in the macro `nonzero_integers` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: integers must not be uninitialized error: the type `bool` does not permit being left uninitialized --> $DIR/invalid_value.rs:112:26 @@ -688,11 +662,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `std::ptr::NonNull<i32>` must be non-null -note: raw pointers must not be uninitialized (in this struct field) - --> $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - | -LL | pointer: *const T, - | ^^^^^^^^^^^^^^^^^ + = note: raw pointers must not be uninitialized error: the type `bool` does not permit being left uninitialized --> $DIR/invalid_value.rs:159:26 |
