Skip to content

Commit f4be633

Browse files
committed
Fix lint.
1 parent 06992c7 commit f4be633

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

compiler/rustc_lint/src/builtin.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2468,6 +2468,8 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
24682468
ty: Ty<'tcx>,
24692469
init: InitKind,
24702470
) -> Option<InitError> {
2471+
let ty = cx.tcx.try_normalize_erasing_regions(cx.param_env, ty).unwrap_or(ty);
2472+
24712473
use rustc_type_ir::TyKind::*;
24722474
match ty.kind() {
24732475
// Primitive types that don't like 0 as a value.

tests/ui/lint/invalid_value.stderr

+7
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ LL | let _val: (NonZero<u32>, i32) = mem::zeroed();
323323
| ^^^^^^^^^^^^^ this code causes undefined behavior when executed
324324
|
325325
= note: `std::num::NonZero<u32>` must be non-null
326+
= note: because `core::num::nonzero::private::NonZeroU32Inner` must be non-null
326327

327328
error: the type `(NonZero<u32>, i32)` does not permit being left uninitialized
328329
--> $DIR/invalid_value.rs:95:41
@@ -331,6 +332,8 @@ LL | let _val: (NonZero<u32>, i32) = mem::uninitialized();
331332
| ^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed
332333
|
333334
= note: `std::num::NonZero<u32>` must be non-null
335+
= note: because `core::num::nonzero::private::NonZeroU32Inner` must be non-null
336+
= note: integers must be initialized
334337

335338
error: the type `*const dyn Send` does not permit zero-initialization
336339
--> $DIR/invalid_value.rs:97:37
@@ -412,6 +415,7 @@ note: because `std::num::NonZero<u32>` must be non-null (in this field of the on
412415
|
413416
LL | Banana(NonZero<u32>),
414417
| ^^^^^^^^^^^^
418+
= note: because `core::num::nonzero::private::NonZeroU32Inner` must be non-null
415419

416420
error: the type `OneFruitNonZero` does not permit being left uninitialized
417421
--> $DIR/invalid_value.rs:107:37
@@ -425,6 +429,8 @@ note: because `std::num::NonZero<u32>` must be non-null (in this field of the on
425429
|
426430
LL | Banana(NonZero<u32>),
427431
| ^^^^^^^^^^^^
432+
= note: because `core::num::nonzero::private::NonZeroU32Inner` must be non-null
433+
= note: integers must be initialized
428434

429435
error: the type `bool` does not permit being left uninitialized
430436
--> $DIR/invalid_value.rs:111:26
@@ -596,6 +602,7 @@ LL | let _val: NonZero<u32> = mem::transmute(0);
596602
| ^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed
597603
|
598604
= note: `std::num::NonZero<u32>` must be non-null
605+
= note: because `core::num::nonzero::private::NonZeroU32Inner` must be non-null
599606

600607
error: the type `NonNull<i32>` does not permit zero-initialization
601608
--> $DIR/invalid_value.rs:156:34

0 commit comments

Comments
 (0)