Skip to content

Commit 208bb93

Browse files
committed
Use "must be init" instead of "must not be uninit" everywhere
1 parent 5446a52 commit 208bb93

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

compiler/rustc_lint/src/builtin.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -2568,13 +2568,11 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
25682568
Some("characters must be a valid Unicode codepoint".into())
25692569
}
25702570
Int(_) | Uint(_) if init == InitKind::Uninit => {
2571-
Some("integers must not be uninitialized".into())
2572-
}
2573-
Float(_) if init == InitKind::Uninit => {
2574-
Some("floats must not be uninitialized".into())
2571+
Some("integers must be initialized".into())
25752572
}
2573+
Float(_) if init == InitKind::Uninit => Some("floats must be initialized".into()),
25762574
RawPtr(_) if init == InitKind::Uninit => {
2577-
Some("raw pointers must not be uninitialized".into())
2575+
Some("raw pointers must be initialized".into())
25782576
}
25792577
// Recurse and checks for some compound types. (but not unions)
25802578
Adt(adt_def, substs) if !adt_def.is_union() => {

src/test/ui/lint/invalid_value.stderr

+11-11
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ LL | let _val: (i32, !) = mem::uninitialized();
9999
| this code causes undefined behavior when executed
100100
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
101101
|
102-
= note: integers must not be uninitialized
102+
= note: integers must be initialized
103103

104104
error: the type `Void` does not permit zero-initialization
105105
--> $DIR/invalid_value.rs:71:26
@@ -332,7 +332,7 @@ LL | let _val: NonNull<i32> = mem::uninitialized();
332332
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
333333
|
334334
= note: `std::ptr::NonNull<i32>` must be non-null
335-
= note: raw pointers must not be uninitialized
335+
= note: raw pointers must be initialized
336336

337337
error: the type `(NonZeroU32, i32)` does not permit zero-initialization
338338
--> $DIR/invalid_value.rs:95:39
@@ -355,7 +355,7 @@ LL | let _val: (NonZeroU32, i32) = mem::uninitialized();
355355
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
356356
|
357357
= note: `std::num::NonZeroU32` must be non-null
358-
= note: integers must not be uninitialized
358+
= note: integers must be initialized
359359

360360
error: the type `*const dyn Send` does not permit zero-initialization
361361
--> $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
462462
|
463463
LL | Banana(NonZeroU32),
464464
| ^^^^^^^^^^
465-
= note: integers must not be uninitialized
465+
= note: integers must be initialized
466466

467467
error: the type `bool` does not permit being left uninitialized
468468
--> $DIR/invalid_value.rs:112:26
@@ -501,7 +501,7 @@ LL | let _val: NonBig = mem::uninitialized();
501501
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
502502
|
503503
= note: `NonBig` must be initialized inside its custom valid range
504-
note: integers must not be uninitialized (in this struct field)
504+
note: integers must be initialized (in this struct field)
505505
--> $DIR/invalid_value.rs:23:26
506506
|
507507
LL | pub(crate) struct NonBig(u64);
@@ -542,7 +542,7 @@ LL | let _val: i32 = mem::uninitialized();
542542
| this code causes undefined behavior when executed
543543
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
544544
|
545-
= note: integers must not be uninitialized
545+
= note: integers must be initialized
546546

547547
error: the type `f32` does not permit being left uninitialized
548548
--> $DIR/invalid_value.rs:130:25
@@ -553,7 +553,7 @@ LL | let _val: f32 = mem::uninitialized();
553553
| this code causes undefined behavior when executed
554554
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
555555
|
556-
= note: floats must not be uninitialized
556+
= note: floats must be initialized
557557

558558
error: the type `*const ()` does not permit being left uninitialized
559559
--> $DIR/invalid_value.rs:133:31
@@ -564,7 +564,7 @@ LL | let _val: *const () = mem::uninitialized();
564564
| this code causes undefined behavior when executed
565565
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
566566
|
567-
= note: raw pointers must not be uninitialized
567+
= note: raw pointers must be initialized
568568

569569
error: the type `*const [()]` does not permit being left uninitialized
570570
--> $DIR/invalid_value.rs:136:33
@@ -575,7 +575,7 @@ LL | let _val: *const [()] = mem::uninitialized();
575575
| this code causes undefined behavior when executed
576576
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
577577
|
578-
= note: raw pointers must not be uninitialized
578+
= note: raw pointers must be initialized
579579

580580
error: the type `WrapAroundRange` does not permit being left uninitialized
581581
--> $DIR/invalid_value.rs:139:37
@@ -587,7 +587,7 @@ LL | let _val: WrapAroundRange = mem::uninitialized();
587587
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
588588
|
589589
= note: `WrapAroundRange` must be initialized inside its custom valid range
590-
note: integers must not be uninitialized (in this struct field)
590+
note: integers must be initialized (in this struct field)
591591
--> $DIR/invalid_value.rs:49:35
592592
|
593593
LL | pub(crate) struct WrapAroundRange(u8);
@@ -662,7 +662,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
662662
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
663663
|
664664
= note: `std::ptr::NonNull<i32>` must be non-null
665-
= note: raw pointers must not be uninitialized
665+
= note: raw pointers must be initialized
666666

667667
error: the type `bool` does not permit being left uninitialized
668668
--> $DIR/invalid_value.rs:159:26

0 commit comments

Comments
 (0)