diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-07 10:52:48 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-25 08:40:27 +0000 |
| commit | 208bb933e7a6d8820646e3e367e2bf188d85e485 (patch) | |
| tree | 1f9481d85de4fe48e4dbc894b6e14ef1b6b2159d | |
| parent | 5446a52b4bcdca0938f6393732de6e0c13305d9b (diff) | |
| download | rust-208bb933e7a6d8820646e3e367e2bf188d85e485.tar.gz rust-208bb933e7a6d8820646e3e367e2bf188d85e485.zip | |
Use "must be init" instead of "must not be uninit" everywhere
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/lint/invalid_value.stderr | 22 |
2 files changed, 14 insertions, 16 deletions
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 3aee97e7908..5c9ea1234f1 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2568,13 +2568,11 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { Some("characters must be a valid Unicode codepoint".into()) } Int(_) | Uint(_) if init == InitKind::Uninit => { - Some("integers must not be uninitialized".into()) - } - Float(_) if init == InitKind::Uninit => { - Some("floats must not be uninitialized".into()) + Some("integers must be initialized".into()) } + Float(_) if init == InitKind::Uninit => Some("floats must be initialized".into()), RawPtr(_) if init == InitKind::Uninit => { - Some("raw pointers must not be uninitialized".into()) + Some("raw pointers must be initialized".into()) } // Recurse and checks for some compound types. (but not unions) Adt(adt_def, substs) if !adt_def.is_union() => { diff --git a/src/test/ui/lint/invalid_value.stderr b/src/test/ui/lint/invalid_value.stderr index afa09a074ec..5370660d6c1 100644 --- a/src/test/ui/lint/invalid_value.stderr +++ b/src/test/ui/lint/invalid_value.stderr @@ -99,7 +99,7 @@ LL | let _val: (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: integers must not be uninitialized + = note: integers must be initialized error: the type `Void` does not permit zero-initialization --> $DIR/invalid_value.rs:71:26 @@ -332,7 +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 + = note: raw pointers must be initialized error: the type `(NonZeroU32, i32)` does not permit zero-initialization --> $DIR/invalid_value.rs:95:39 @@ -355,7 +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 + = note: integers must be initialized error: the type `*const dyn Send` does not permit zero-initialization --> $DIR/invalid_value.rs:98:37 @@ -462,7 +462,7 @@ note: because `std::num::NonZeroU32` must be non-null (in this field of the only | LL | Banana(NonZeroU32), | ^^^^^^^^^^ - = note: integers must not be uninitialized + = note: integers must be initialized error: the type `bool` does not permit being left uninitialized --> $DIR/invalid_value.rs:112:26 @@ -501,7 +501,7 @@ LL | let _val: NonBig = mem::uninitialized(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `NonBig` must be initialized inside its custom valid range -note: integers must not be uninitialized (in this struct field) +note: integers must be initialized (in this struct field) --> $DIR/invalid_value.rs:23:26 | LL | pub(crate) struct NonBig(u64); @@ -542,7 +542,7 @@ LL | let _val: 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: integers must not be uninitialized + = note: integers must be initialized error: the type `f32` does not permit being left uninitialized --> $DIR/invalid_value.rs:130:25 @@ -553,7 +553,7 @@ LL | let _val: f32 = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: floats must not be uninitialized + = note: floats must be initialized error: the type `*const ()` does not permit being left uninitialized --> $DIR/invalid_value.rs:133:31 @@ -564,7 +564,7 @@ LL | let _val: *const () = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: raw pointers must not be uninitialized + = note: raw pointers must be initialized error: the type `*const [()]` does not permit being left uninitialized --> $DIR/invalid_value.rs:136:33 @@ -575,7 +575,7 @@ LL | let _val: *const [()] = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | - = note: raw pointers must not be uninitialized + = note: raw pointers must be initialized error: the type `WrapAroundRange` does not permit being left uninitialized --> $DIR/invalid_value.rs:139:37 @@ -587,7 +587,7 @@ LL | let _val: WrapAroundRange = mem::uninitialized(); | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: `WrapAroundRange` must be initialized inside its custom valid range -note: integers must not be uninitialized (in this struct field) +note: integers must be initialized (in this struct field) --> $DIR/invalid_value.rs:49:35 | LL | pub(crate) struct WrapAroundRange(u8); @@ -662,7 +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 + = note: raw pointers must be initialized error: the type `bool` does not permit being left uninitialized --> $DIR/invalid_value.rs:159:26 |
