Skip to content

Commit

Permalink
Use "must be init" instead of "must not be uninit" everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Nov 25, 2022
1 parent 5446a52 commit 208bb93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
8 changes: 3 additions & 5 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() => {
Expand Down
22 changes: 11 additions & 11 deletions src/test/ui/lint/invalid_value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 208bb93

Please sign in to comment.