Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 60ff307

Browse files
committedJun 5, 2025·
Use !null pattern type in libcore
Use `!null` pattern type in libcore
1 parent e245311 commit 60ff307

File tree

30 files changed

+222
-186
lines changed

30 files changed

+222
-186
lines changed
 

‎compiler/rustc_const_eval/src/interpret/visitor.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
156156
);
157157
// ... that contains a `NonNull`... (gladly, only a single field here)
158158
assert_eq!(nonnull_ptr.layout().fields.count(), 1);
159-
let raw_ptr = self.ecx().project_field(&nonnull_ptr, 0)?; // the actual raw ptr
159+
let pat_ty = self.ecx().project_field(&nonnull_ptr, 0)?; // `*mut T is !null`
160+
let base = match *pat_ty.layout().ty.kind() {
161+
ty::Pat(base, _) => self.ecx().layout_of(base)?,
162+
_ => unreachable!(),
163+
};
164+
let raw_ptr = pat_ty.transmute(base, self.ecx())?; // The actual raw pointer
160165
// ... whose only field finally is a raw ptr we can dereference.
161166
self.visit_box(ty, &raw_ptr)?;
162167

‎compiler/rustc_mir_transform/src/elaborate_box_derefs.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::def_id::DefId;
77
use rustc_middle::mir::visit::MutVisitor;
88
use rustc_middle::mir::*;
99
use rustc_middle::span_bug;
10-
use rustc_middle::ty::{Ty, TyCtxt};
10+
use rustc_middle::ty::{PatternKind, Ty, TyCtxt};
1111

1212
use crate::patch::MirPatch;
1313

@@ -17,13 +17,14 @@ fn build_ptr_tys<'tcx>(
1717
pointee: Ty<'tcx>,
1818
unique_did: DefId,
1919
nonnull_did: DefId,
20-
) -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) {
20+
) -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) {
2121
let args = tcx.mk_args(&[pointee.into()]);
2222
let unique_ty = tcx.type_of(unique_did).instantiate(tcx, args);
2323
let nonnull_ty = tcx.type_of(nonnull_did).instantiate(tcx, args);
2424
let ptr_ty = Ty::new_imm_ptr(tcx, pointee);
25+
let pat_ty = Ty::new_pat(tcx, ptr_ty, tcx.mk_pat(PatternKind::NotNull));
2526

26-
(unique_ty, nonnull_ty, ptr_ty)
27+
(unique_ty, nonnull_ty, pat_ty, ptr_ty)
2728
}
2829

2930
/// Constructs the projection needed to access a Box's pointer
@@ -63,7 +64,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> {
6364
{
6465
let source_info = self.local_decls[place.local].source_info;
6566

66-
let (unique_ty, nonnull_ty, ptr_ty) =
67+
let (unique_ty, nonnull_ty, _pat_ty, ptr_ty) =
6768
build_ptr_tys(tcx, boxed_ty, self.unique_did, self.nonnull_did);
6869

6970
let ptr_local = self.patch.new_temp(ptr_ty, source_info.span);
@@ -130,10 +131,11 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs {
130131
let new_projections =
131132
new_projections.get_or_insert_with(|| base.projection.to_vec());
132133

133-
let (unique_ty, nonnull_ty, ptr_ty) =
134+
let (unique_ty, nonnull_ty, pat_ty, ptr_ty) =
134135
build_ptr_tys(tcx, boxed_ty, unique_did, nonnull_did);
135136

136137
new_projections.extend_from_slice(&build_projection(unique_ty, nonnull_ty));
138+
new_projections.push(PlaceElem::Field(FieldIdx::ZERO, pat_ty));
137139
// While we can't project into `NonNull<_>` in a basic block
138140
// due to MCP#807, this is debug info where it's fine.
139141
new_projections.push(PlaceElem::Field(FieldIdx::ZERO, ptr_ty));

‎library/core/src/ptr/non_null.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::cmp::Ordering;
22
use crate::marker::Unsize;
3-
use crate::mem::{MaybeUninit, SizedTypeProperties};
3+
use crate::mem::{MaybeUninit, SizedTypeProperties, transmute};
44
use crate::num::NonZero;
55
use crate::ops::{CoerceUnsized, DispatchFromDyn};
66
use crate::pin::PinCoerceUnsized;
@@ -64,13 +64,10 @@ use crate::{fmt, hash, intrinsics, mem, ptr};
6464
/// [null pointer optimization]: crate::option#representation
6565
#[stable(feature = "nonnull", since = "1.25.0")]
6666
#[repr(transparent)]
67-
#[rustc_layout_scalar_valid_range_start(1)]
6867
#[rustc_nonnull_optimization_guaranteed]
6968
#[rustc_diagnostic_item = "NonNull"]
7069
pub struct NonNull<T: ?Sized> {
71-
// Remember to use `.as_ptr()` instead of `.pointer`, as field projecting to
72-
// this is banned by <https://github.com/rust-lang/compiler-team/issues/807>.
73-
pointer: *const T,
70+
pointer: crate::pattern_type!(*const T is !null),
7471
}
7572

7673
/// `NonNull` pointers are not `Send` because the data they reference may be aliased.
@@ -93,9 +90,9 @@ impl<T: Sized> NonNull<T> {
9390
#[must_use]
9491
#[inline]
9592
pub const fn without_provenance(addr: NonZero<usize>) -> Self {
96-
let pointer = crate::ptr::without_provenance(addr.get());
93+
let pointer: *const T = crate::ptr::without_provenance(addr.get());
9794
// SAFETY: we know `addr` is non-zero.
98-
unsafe { NonNull { pointer } }
95+
unsafe { NonNull { pointer: transmute(pointer) } }
9996
}
10097

10198
/// Creates a new `NonNull` that is dangling, but well-aligned.
@@ -225,7 +222,7 @@ impl<T: ?Sized> NonNull<T> {
225222
"NonNull::new_unchecked requires that the pointer is non-null",
226223
(ptr: *mut () = ptr as *mut ()) => !ptr.is_null()
227224
);
228-
NonNull { pointer: ptr as _ }
225+
NonNull { pointer: transmute(ptr) }
229226
}
230227
}
231228

@@ -268,7 +265,7 @@ impl<T: ?Sized> NonNull<T> {
268265
#[inline]
269266
pub const fn from_ref(r: &T) -> Self {
270267
// SAFETY: A reference cannot be null.
271-
unsafe { NonNull { pointer: r as *const T } }
268+
unsafe { NonNull { pointer: transmute(r as *const T) } }
272269
}
273270

274271
/// Converts a mutable reference to a `NonNull` pointer.
@@ -277,7 +274,7 @@ impl<T: ?Sized> NonNull<T> {
277274
#[inline]
278275
pub const fn from_mut(r: &mut T) -> Self {
279276
// SAFETY: A mutable reference cannot be null.
280-
unsafe { NonNull { pointer: r as *mut T } }
277+
unsafe { NonNull { pointer: transmute(r as *mut T) } }
281278
}
282279

283280
/// Performs the same functionality as [`std::ptr::from_raw_parts`], except that a
@@ -488,7 +485,7 @@ impl<T: ?Sized> NonNull<T> {
488485
#[inline]
489486
pub const fn cast<U>(self) -> NonNull<U> {
490487
// SAFETY: `self` is a `NonNull` pointer which is necessarily non-null
491-
unsafe { NonNull { pointer: self.as_ptr() as *mut U } }
488+
unsafe { NonNull { pointer: transmute(self.as_ptr() as *mut U) } }
492489
}
493490

494491
/// Try to cast to a pointer of another type by checking aligment.
@@ -567,7 +564,7 @@ impl<T: ?Sized> NonNull<T> {
567564
// Additionally safety contract of `offset` guarantees that the resulting pointer is
568565
// pointing to an allocation, there can't be an allocation at null, thus it's safe to
569566
// construct `NonNull`.
570-
unsafe { NonNull { pointer: intrinsics::offset(self.as_ptr(), count) } }
567+
unsafe { NonNull { pointer: transmute(intrinsics::offset(self.as_ptr(), count)) } }
571568
}
572569

573570
/// Calculates the offset from a pointer in bytes.
@@ -591,7 +588,7 @@ impl<T: ?Sized> NonNull<T> {
591588
// Additionally safety contract of `offset` guarantees that the resulting pointer is
592589
// pointing to an allocation, there can't be an allocation at null, thus it's safe to
593590
// construct `NonNull`.
594-
unsafe { NonNull { pointer: self.as_ptr().byte_offset(count) } }
591+
unsafe { NonNull { pointer: transmute(self.as_ptr().byte_offset(count)) } }
595592
}
596593

597594
/// Adds an offset to a pointer (convenience for `.offset(count as isize)`).
@@ -643,7 +640,7 @@ impl<T: ?Sized> NonNull<T> {
643640
// Additionally safety contract of `offset` guarantees that the resulting pointer is
644641
// pointing to an allocation, there can't be an allocation at null, thus it's safe to
645642
// construct `NonNull`.
646-
unsafe { NonNull { pointer: intrinsics::offset(self.as_ptr(), count) } }
643+
unsafe { NonNull { pointer: transmute(intrinsics::offset(self.as_ptr(), count)) } }
647644
}
648645

649646
/// Calculates the offset from a pointer in bytes (convenience for `.byte_offset(count as isize)`).
@@ -667,7 +664,7 @@ impl<T: ?Sized> NonNull<T> {
667664
// Additionally safety contract of `add` guarantees that the resulting pointer is pointing
668665
// to an allocation, there can't be an allocation at null, thus it's safe to construct
669666
// `NonNull`.
670-
unsafe { NonNull { pointer: self.as_ptr().byte_add(count) } }
667+
unsafe { NonNull { pointer: transmute(self.as_ptr().byte_add(count)) } }
671668
}
672669

673670
/// Subtracts an offset from a pointer (convenience for
@@ -749,7 +746,7 @@ impl<T: ?Sized> NonNull<T> {
749746
// Additionally safety contract of `sub` guarantees that the resulting pointer is pointing
750747
// to an allocation, there can't be an allocation at null, thus it's safe to construct
751748
// `NonNull`.
752-
unsafe { NonNull { pointer: self.as_ptr().byte_sub(count) } }
749+
unsafe { NonNull { pointer: transmute(self.as_ptr().byte_sub(count)) } }
753750
}
754751

755752
/// Calculates the distance between two pointers within the same allocation. The returned value is in

‎library/std/src/os/unix/io/tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use crate::os::unix::io::RawFd;
22

33
#[test]
44
fn test_raw_fd_layout() {
5-
// `OwnedFd` and `BorrowedFd` use `rustc_layout_scalar_valid_range_start`
6-
// and `rustc_layout_scalar_valid_range_end`, with values that depend on
5+
// `OwnedFd` and `BorrowedFd` use pattern types, with ranges that depend on
76
// the bit width of `RawFd`. If this ever changes, those values will need
87
// to be updated.
98
assert_eq!(size_of::<RawFd>(), 4);

‎library/std/src/os/wasi/io/tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use crate::os::wasi::io::RawFd;
22

33
#[test]
44
fn test_raw_fd_layout() {
5-
// `OwnedFd` and `BorrowedFd` use `rustc_layout_scalar_valid_range_start`
6-
// and `rustc_layout_scalar_valid_range_end`, with values that depend on
5+
// `OwnedFd` and `BorrowedFd` use pattern types with ranges that depend on
76
// the bit width of `RawFd`. If this ever changes, those values will need
87
// to be updated.
98
assert_eq!(size_of::<RawFd>(), 4);

‎src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx>
242242
loop {
243243
ty = cx.tcx.try_normalize_erasing_regions(cx.typing_env(), ty).unwrap_or(ty);
244244
return match *ty.kind() {
245+
ty::Pat(base, _) => {
246+
ty = base;
247+
continue;
248+
},
245249
ty::Array(sub_ty, _) if matches!(sub_ty.kind(), ty::Int(_) | ty::Uint(_)) => {
246250
ReducedTy::TypeErasure { raw_ptr_only: false }
247251
},

‎tests/codegen/loads.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub fn load_raw_pointer<'a>(x: &*const i32) -> *const i32 {
5858
// CHECK-LABEL: @load_box
5959
#[no_mangle]
6060
pub fn load_box<'a>(x: Box<Box<i32>>) -> Box<i32> {
61-
// CHECK: load ptr, ptr %{{.*}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !align ![[ALIGN_4_META]], !noundef !{{[0-9]+}}
61+
// CHECK: load ptr, ptr %{{.*}}, align [[PTR_ALIGNMENT]], !nonnull !{{[0-9]+}}, !noundef !{{[0-9]+}}
6262
*x
6363
}
6464

‎tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
StorageLive(_1);
1414
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
1515
- _2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
16-
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
17-
+ _2 = const std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} }} as *const Never (Transmute);
16+
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
17+
+ _2 = const std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }} as *const Never (Transmute);
1818
unreachable;
1919
}
2020
}

‎tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
StorageLive(_1);
1414
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
1515
- _2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
16-
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
17-
+ _2 = const std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} }} as *const Never (Transmute);
16+
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
17+
+ _2 = const std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }} as *const Never (Transmute);
1818
unreachable;
1919
}
2020
}

‎tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
scope 8 (inlined std::ptr::Alignment::as_nonzero) {
2222
}
2323
scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) {
24-
let _7: *const [bool; 0];
24+
let mut _7: (*const [bool; 0]) is !null;
2525
scope 10 {
2626
}
2727
scope 11 (inlined NonZero::<usize>::get) {
@@ -47,17 +47,17 @@
4747
StorageLive(_6);
4848
_6 = const NonZero::<usize>(core::num::niche_types::NonZeroUsizeInner(1_usize is 1..));
4949
StorageLive(_7);
50-
_7 = const {0x1 as *const [bool; 0]};
51-
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
50+
_7 = const {0x1 as *const [bool; 0]} is !null;
51+
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
5252
StorageDead(_7);
5353
StorageDead(_6);
54-
_4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
54+
_4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
5555
StorageDead(_5);
56-
_3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
56+
_3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }};
5757
StorageDead(_4);
58-
_2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
58+
_2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
5959
StorageDead(_3);
60-
_1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
60+
_1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
6161
StorageDead(_2);
6262
_0 = const ();
6363
drop(_1) -> [return: bb1, unwind unreachable];

‎tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
scope 8 (inlined std::ptr::Alignment::as_nonzero) {
2222
}
2323
scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) {
24-
let _7: *const [bool; 0];
24+
let mut _7: (*const [bool; 0]) is !null;
2525
scope 10 {
2626
}
2727
scope 11 (inlined NonZero::<usize>::get) {
@@ -47,17 +47,17 @@
4747
StorageLive(_6);
4848
_6 = const NonZero::<usize>(core::num::niche_types::NonZeroUsizeInner(1_usize is 1..));
4949
StorageLive(_7);
50-
_7 = const {0x1 as *const [bool; 0]};
51-
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
50+
_7 = const {0x1 as *const [bool; 0]} is !null;
51+
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
5252
StorageDead(_7);
5353
StorageDead(_6);
54-
_4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
54+
_4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
5555
StorageDead(_5);
56-
_3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
56+
_3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }};
5757
StorageDead(_4);
58-
_2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
58+
_2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
5959
StorageDead(_3);
60-
_1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
60+
_1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
6161
StorageDead(_2);
6262
_0 = const ();
6363
drop(_1) -> [return: bb1, unwind: bb2];

‎tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
scope 8 (inlined std::ptr::Alignment::as_nonzero) {
2222
}
2323
scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) {
24-
let _7: *const [bool; 0];
24+
let mut _7: (*const [bool; 0]) is !null;
2525
scope 10 {
2626
}
2727
scope 11 (inlined NonZero::<usize>::get) {
@@ -47,17 +47,17 @@
4747
StorageLive(_6);
4848
_6 = const NonZero::<usize>(core::num::niche_types::NonZeroUsizeInner(1_usize is 1..));
4949
StorageLive(_7);
50-
_7 = const {0x1 as *const [bool; 0]};
51-
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
50+
_7 = const {0x1 as *const [bool; 0]} is !null;
51+
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
5252
StorageDead(_7);
5353
StorageDead(_6);
54-
_4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
54+
_4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
5555
StorageDead(_5);
56-
_3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
56+
_3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }};
5757
StorageDead(_4);
58-
_2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
58+
_2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
5959
StorageDead(_3);
60-
_1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
60+
_1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
6161
StorageDead(_2);
6262
_0 = const ();
6363
drop(_1) -> [return: bb1, unwind unreachable];

‎tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
scope 8 (inlined std::ptr::Alignment::as_nonzero) {
2222
}
2323
scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) {
24-
let _7: *const [bool; 0];
24+
let mut _7: (*const [bool; 0]) is !null;
2525
scope 10 {
2626
}
2727
scope 11 (inlined NonZero::<usize>::get) {
@@ -47,17 +47,17 @@
4747
StorageLive(_6);
4848
_6 = const NonZero::<usize>(core::num::niche_types::NonZeroUsizeInner(1_usize is 1..));
4949
StorageLive(_7);
50-
_7 = const {0x1 as *const [bool; 0]};
51-
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
50+
_7 = const {0x1 as *const [bool; 0]} is !null;
51+
_5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
5252
StorageDead(_7);
5353
StorageDead(_6);
54-
_4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
54+
_4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
5555
StorageDead(_5);
56-
_3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
56+
_3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }};
5757
StorageDead(_4);
58-
_2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
58+
_2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
5959
StorageDead(_3);
60-
_1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
60+
_1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
6161
StorageDead(_2);
6262
_0 = const ();
6363
drop(_1) -> [return: bb1, unwind: bb2];

‎tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
scope 8 (inlined std::ptr::Alignment::as_nonzero) {
2222
}
2323
scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) {
24-
let _7: *const [bool; 0];
24+
let mut _7: (*const [bool; 0]) is !null;
2525
scope 10 {
2626
}
2727
scope 11 (inlined NonZero::<usize>::get) {
@@ -48,23 +48,23 @@
4848
- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero<usize> (Transmute);
4949
+ _6 = const NonZero::<usize>(core::num::niche_types::NonZeroUsizeInner(1_usize is 1..));
5050
StorageLive(_7);
51-
- _7 = copy _6 as *const [bool; 0] (Transmute);
52-
- _5 = NonNull::<[bool; 0]> { pointer: copy _7 };
53-
+ _7 = const {0x1 as *const [bool; 0]};
54-
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
51+
- _7 = copy _6 as (*const [bool; 0]) is !null (Transmute);
52+
- _5 = NonNull::<[bool; 0]> { pointer: move _7 };
53+
+ _7 = const {0x1 as *const [bool; 0]} is !null;
54+
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
5555
StorageDead(_7);
5656
StorageDead(_6);
5757
- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> };
58-
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
58+
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
5959
StorageDead(_5);
6060
- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit));
61-
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
61+
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }};
6262
StorageDead(_4);
6363
- _2 = Box::<[bool]>(copy _3, const std::alloc::Global);
64-
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
64+
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
6565
StorageDead(_3);
6666
- _1 = A { foo: move _2 };
67-
+ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
67+
+ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
6868
StorageDead(_2);
6969
_0 = const ();
7070
drop(_1) -> [return: bb1, unwind unreachable];

‎tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
scope 8 (inlined std::ptr::Alignment::as_nonzero) {
2222
}
2323
scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) {
24-
let _7: *const [bool; 0];
24+
let mut _7: (*const [bool; 0]) is !null;
2525
scope 10 {
2626
}
2727
scope 11 (inlined NonZero::<usize>::get) {
@@ -48,23 +48,23 @@
4848
- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero<usize> (Transmute);
4949
+ _6 = const NonZero::<usize>(core::num::niche_types::NonZeroUsizeInner(1_usize is 1..));
5050
StorageLive(_7);
51-
- _7 = copy _6 as *const [bool; 0] (Transmute);
52-
- _5 = NonNull::<[bool; 0]> { pointer: copy _7 };
53-
+ _7 = const {0x1 as *const [bool; 0]};
54-
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
51+
- _7 = copy _6 as (*const [bool; 0]) is !null (Transmute);
52+
- _5 = NonNull::<[bool; 0]> { pointer: move _7 };
53+
+ _7 = const {0x1 as *const [bool; 0]} is !null;
54+
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
5555
StorageDead(_7);
5656
StorageDead(_6);
5757
- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> };
58-
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
58+
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
5959
StorageDead(_5);
6060
- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit));
61-
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
61+
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }};
6262
StorageDead(_4);
6363
- _2 = Box::<[bool]>(copy _3, const std::alloc::Global);
64-
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
64+
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
6565
StorageDead(_3);
6666
- _1 = A { foo: move _2 };
67-
+ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
67+
+ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
6868
StorageDead(_2);
6969
_0 = const ();
7070
drop(_1) -> [return: bb1, unwind: bb2];

‎tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
scope 8 (inlined std::ptr::Alignment::as_nonzero) {
2222
}
2323
scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) {
24-
let _7: *const [bool; 0];
24+
let mut _7: (*const [bool; 0]) is !null;
2525
scope 10 {
2626
}
2727
scope 11 (inlined NonZero::<usize>::get) {
@@ -48,23 +48,23 @@
4848
- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero<usize> (Transmute);
4949
+ _6 = const NonZero::<usize>(core::num::niche_types::NonZeroUsizeInner(1_usize is 1..));
5050
StorageLive(_7);
51-
- _7 = copy _6 as *const [bool; 0] (Transmute);
52-
- _5 = NonNull::<[bool; 0]> { pointer: copy _7 };
53-
+ _7 = const {0x1 as *const [bool; 0]};
54-
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
51+
- _7 = copy _6 as (*const [bool; 0]) is !null (Transmute);
52+
- _5 = NonNull::<[bool; 0]> { pointer: move _7 };
53+
+ _7 = const {0x1 as *const [bool; 0]} is !null;
54+
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
5555
StorageDead(_7);
5656
StorageDead(_6);
5757
- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> };
58-
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
58+
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
5959
StorageDead(_5);
6060
- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit));
61-
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
61+
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }};
6262
StorageDead(_4);
6363
- _2 = Box::<[bool]>(copy _3, const std::alloc::Global);
64-
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
64+
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
6565
StorageDead(_3);
6666
- _1 = A { foo: move _2 };
67-
+ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
67+
+ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
6868
StorageDead(_2);
6969
_0 = const ();
7070
drop(_1) -> [return: bb1, unwind unreachable];

‎tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
scope 8 (inlined std::ptr::Alignment::as_nonzero) {
2222
}
2323
scope 9 (inlined NonNull::<[bool; 0]>::without_provenance) {
24-
let _7: *const [bool; 0];
24+
let mut _7: (*const [bool; 0]) is !null;
2525
scope 10 {
2626
}
2727
scope 11 (inlined NonZero::<usize>::get) {
@@ -48,23 +48,23 @@
4848
- _6 = const std::ptr::Alignment::of::<[bool; 0]>::{constant#0} as std::num::NonZero<usize> (Transmute);
4949
+ _6 = const NonZero::<usize>(core::num::niche_types::NonZeroUsizeInner(1_usize is 1..));
5050
StorageLive(_7);
51-
- _7 = copy _6 as *const [bool; 0] (Transmute);
52-
- _5 = NonNull::<[bool; 0]> { pointer: copy _7 };
53-
+ _7 = const {0x1 as *const [bool; 0]};
54-
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }};
51+
- _7 = copy _6 as (*const [bool; 0]) is !null (Transmute);
52+
- _5 = NonNull::<[bool; 0]> { pointer: move _7 };
53+
+ _7 = const {0x1 as *const [bool; 0]} is !null;
54+
+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }};
5555
StorageDead(_7);
5656
StorageDead(_6);
5757
- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> };
58-
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }};
58+
+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} is !null }}, _marker: PhantomData::<[bool; 0]> }};
5959
StorageDead(_5);
6060
- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize, Implicit));
61-
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }};
61+
+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }};
6262
StorageDead(_4);
6363
- _2 = Box::<[bool]>(copy _3, const std::alloc::Global);
64-
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
64+
+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global);
6565
StorageDead(_3);
6666
- _1 = A { foo: move _2 };
67-
+ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
67+
+ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: (*const [bool]) is !null }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }};
6868
StorageDead(_2);
6969
_0 = const ();
7070
drop(_1) -> [return: bb1, unwind: bb2];

‎tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.32bit.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
bb0: {
1313
StorageLive(_1);
1414
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
15-
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
15+
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
1616
_2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
1717
unreachable;
1818
}

‎tests/mir-opt/dataflow-const-prop/transmute.unreachable_box.DataflowConstProp.64bit.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
bb0: {
1313
StorageLive(_1);
1414
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
15-
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
15+
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} is !null }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
1616
_2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
1717
unreachable;
1818
}

‎tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.32bit.panic-abort.diff

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
let mut _8: *const [()];
1111
let mut _9: std::boxed::Box<()>;
1212
let mut _10: *const ();
13-
let mut _23: usize;
13+
let mut _25: usize;
1414
scope 1 {
1515
debug vp_ctx => _1;
1616
let _4: *const ();
@@ -47,7 +47,9 @@
4747
scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) {
4848
scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) {
4949
scope 13 (inlined NonNull::<[u8]>::cast::<u8>) {
50-
let mut _22: *mut [u8];
50+
let mut _22: (*const u8) is !null;
51+
let mut _23: *mut u8;
52+
let mut _24: *mut [u8];
5153
scope 14 (inlined NonNull::<[u8]>::as_ptr) {
5254
}
5355
}
@@ -105,8 +107,14 @@
105107
bb4: {
106108
_17 = copy ((_15 as Ok).0: std::ptr::NonNull<[u8]>);
107109
StorageLive(_22);
108-
_22 = copy _17 as *mut [u8] (Transmute);
109-
_13 = copy _22 as *mut u8 (PtrToPtr);
110+
StorageLive(_23);
111+
StorageLive(_24);
112+
_24 = copy _17 as *mut [u8] (Transmute);
113+
_23 = move _24 as *mut u8 (PtrToPtr);
114+
StorageDead(_24);
115+
_22 = move _23 as (*const u8) is !null (Transmute);
116+
StorageDead(_23);
117+
_13 = copy _22 as *mut u8 (Transmute);
110118
StorageDead(_22);
111119
StorageDead(_15);
112120
StorageDead(_17);
@@ -129,11 +137,11 @@
129137
StorageLive(_6);
130138
- _6 = copy _4;
131139
+ _6 = copy _10;
132-
StorageLive(_23);
133-
_23 = const 1_usize;
134-
- _5 = *const [()] from (copy _6, copy _23);
140+
StorageLive(_25);
141+
_25 = const 1_usize;
142+
- _5 = *const [()] from (copy _6, copy _25);
135143
+ _5 = *const [()] from (copy _10, const 1_usize);
136-
StorageDead(_23);
144+
StorageDead(_25);
137145
StorageDead(_6);
138146
StorageLive(_7);
139147
StorageLive(_8);

‎tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.64bit.panic-abort.diff

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
let mut _8: *const [()];
1111
let mut _9: std::boxed::Box<()>;
1212
let mut _10: *const ();
13-
let mut _23: usize;
13+
let mut _25: usize;
1414
scope 1 {
1515
debug vp_ctx => _1;
1616
let _4: *const ();
@@ -47,7 +47,9 @@
4747
scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) {
4848
scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) {
4949
scope 13 (inlined NonNull::<[u8]>::cast::<u8>) {
50-
let mut _22: *mut [u8];
50+
let mut _22: (*const u8) is !null;
51+
let mut _23: *mut u8;
52+
let mut _24: *mut [u8];
5153
scope 14 (inlined NonNull::<[u8]>::as_ptr) {
5254
}
5355
}
@@ -105,8 +107,14 @@
105107
bb4: {
106108
_17 = copy ((_15 as Ok).0: std::ptr::NonNull<[u8]>);
107109
StorageLive(_22);
108-
_22 = copy _17 as *mut [u8] (Transmute);
109-
_13 = copy _22 as *mut u8 (PtrToPtr);
110+
StorageLive(_23);
111+
StorageLive(_24);
112+
_24 = copy _17 as *mut [u8] (Transmute);
113+
_23 = move _24 as *mut u8 (PtrToPtr);
114+
StorageDead(_24);
115+
_22 = move _23 as (*const u8) is !null (Transmute);
116+
StorageDead(_23);
117+
_13 = copy _22 as *mut u8 (Transmute);
110118
StorageDead(_22);
111119
StorageDead(_15);
112120
StorageDead(_17);
@@ -129,11 +137,11 @@
129137
StorageLive(_6);
130138
- _6 = copy _4;
131139
+ _6 = copy _10;
132-
StorageLive(_23);
133-
_23 = const 1_usize;
134-
- _5 = *const [()] from (copy _6, copy _23);
140+
StorageLive(_25);
141+
_25 = const 1_usize;
142+
- _5 = *const [()] from (copy _6, copy _25);
135143
+ _5 = *const [()] from (copy _10, const 1_usize);
136-
StorageDead(_23);
144+
StorageDead(_25);
137145
StorageDead(_6);
138146
StorageLive(_7);
139147
StorageLive(_8);

‎tests/mir-opt/elaborate_box_deref_in_debuginfo.pointee.ElaborateBoxDerefs.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
fn pointee(_1: Box<i32>) -> () {
55
- debug foo => (*_1);
6-
+ debug foo => (*(((_1.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32));
6+
+ debug foo => (*((((_1.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: (*const i32) is !null).0: *const i32));
77
let mut _0: ();
88

99
bb0: {

‎tests/mir-opt/gvn_ptr_eq_with_constant.main.GVN.diff

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
scope 5 (inlined std::ptr::Alignment::as_nonzero) {
1313
}
1414
scope 6 (inlined NonNull::<u8>::without_provenance) {
15+
let mut _4: (*const u8) is !null;
1516
scope 7 {
1617
}
1718
scope 8 (inlined NonZero::<usize>::get) {
@@ -29,36 +30,39 @@
2930
}
3031
}
3132
scope 12 (inlined Foo::<u8>::cmp_ptr) {
32-
let mut _4: *const u8;
33-
let mut _5: *mut u8;
34-
let mut _6: *const u8;
33+
let mut _5: *const u8;
34+
let mut _6: *mut u8;
35+
let mut _7: *const u8;
3536
scope 13 (inlined std::ptr::eq::<u8>) {
3637
}
3738
}
3839

3940
bb0: {
4041
StorageLive(_1);
4142
StorageLive(_2);
43+
StorageLive(_4);
4244
StorageLive(_3);
4345
- _3 = const std::ptr::Alignment::of::<u8>::{constant#0} as std::num::NonZero<usize> (Transmute);
44-
- _2 = copy _3 as *mut u8 (Transmute);
46+
- _4 = copy _3 as (*const u8) is !null (Transmute);
4547
+ _3 = const NonZero::<usize>(core::num::niche_types::NonZeroUsizeInner(1_usize is 1..));
46-
+ _2 = const {0x1 as *mut u8};
48+
+ _4 = const {0x1 as *const u8} is !null;
4749
StorageDead(_3);
48-
StorageLive(_4);
50+
- _2 = copy _4 as *mut u8 (Transmute);
51+
+ _2 = const {0x1 as *const u8} is !null as *mut u8 (Transmute);
52+
StorageDead(_4);
4953
StorageLive(_5);
50-
- _5 = copy _2;
51-
- _4 = copy _2 as *const u8 (PtrToPtr);
52-
+ _5 = const {0x1 as *mut u8};
53-
+ _4 = const {0x1 as *const u8};
54-
StorageDead(_5);
5554
StorageLive(_6);
56-
- _6 = const Foo::<u8>::SENTINEL as *const u8 (PtrToPtr);
57-
- _1 = Eq(copy _4, copy _6);
58-
+ _6 = const {0x1 as *const u8};
59-
+ _1 = const true;
55+
_6 = copy _2;
56+
- _5 = copy _2 as *const u8 (PtrToPtr);
57+
+ _5 = const {0x1 as *const u8} is !null as *const u8 (Transmute);
6058
StorageDead(_6);
61-
StorageDead(_4);
59+
StorageLive(_7);
60+
- _7 = const Foo::<u8>::SENTINEL as *const u8 (PtrToPtr);
61+
- _1 = Eq(copy _5, copy _7);
62+
+ _7 = const {0x1 as *const u8};
63+
+ _1 = Eq(copy _5, const {0x1 as *const u8});
64+
StorageDead(_7);
65+
StorageDead(_5);
6266
StorageDead(_2);
6367
StorageDead(_1);
6468
_0 = const ();

‎tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
+ scope 4 (inlined alloc::raw_vec::RawVec::<A>::ptr) {
2020
+ scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::<A>) {
2121
+ scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::<A>) {
22-
+ let mut _11: std::ptr::NonNull<u8>;
22+
+ let mut _12: std::ptr::NonNull<u8>;
2323
+ scope 7 (inlined Unique::<u8>::cast::<A>) {
2424
+ scope 8 (inlined NonNull::<u8>::cast::<A>) {
25+
+ let mut _11: (*const A) is !null;
2526
+ scope 9 (inlined NonNull::<u8>::as_ptr) {
2627
+ }
2728
+ }
@@ -39,15 +40,15 @@
3940
+ }
4041
+ }
4142
+ scope 14 (inlined drop_in_place::<[A]> - shim(Some([A]))) {
42-
+ let mut _12: usize;
43-
+ let mut _13: *mut A;
44-
+ let mut _14: bool;
43+
+ let mut _13: usize;
44+
+ let mut _14: *mut A;
45+
+ let mut _15: bool;
4546
+ }
4647
+ }
4748
+ }
4849
+ scope 15 (inlined drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
49-
+ let mut _15: isize;
5050
+ let mut _16: isize;
51+
+ let mut _17: isize;
5152
+ }
5253

5354
bb0: {
@@ -62,16 +63,19 @@
6263
+ StorageLive(_8);
6364
+ StorageLive(_9);
6465
+ StorageLive(_11);
65-
+ _11 = copy (((((*_6).0: alloc::raw_vec::RawVec<A>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
66+
+ StorageLive(_12);
67+
+ _12 = copy (((((*_6).0: alloc::raw_vec::RawVec<A>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
68+
+ _11 = copy _12 as (*const A) is !null (Transmute);
69+
+ StorageDead(_12);
6670
+ _9 = copy _11 as *mut A (Transmute);
6771
+ StorageDead(_11);
6872
+ _10 = copy ((*_6).1: usize);
6973
+ _8 = *mut [A] from (copy _9, copy _10);
7074
+ StorageDead(_9);
71-
+ StorageLive(_12);
7275
+ StorageLive(_13);
7376
+ StorageLive(_14);
74-
+ _12 = const 0_usize;
77+
+ StorageLive(_15);
78+
+ _13 = const 0_usize;
7579
+ goto -> bb4;
7680
}
7781

@@ -83,35 +87,35 @@
8387
StorageLive(_5);
8488
_5 = copy _2;
8589
- _0 = drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind unreachable];
86-
+ StorageLive(_15);
8790
+ StorageLive(_16);
88-
+ _15 = discriminant((*_5));
89-
+ switchInt(move _15) -> [0: bb5, otherwise: bb6];
91+
+ StorageLive(_17);
92+
+ _16 = discriminant((*_5));
93+
+ switchInt(move _16) -> [0: bb5, otherwise: bb6];
9094
}
9195

9296
bb2: {
97+
+ StorageDead(_15);
9398
+ StorageDead(_14);
9499
+ StorageDead(_13);
95-
+ StorageDead(_12);
96100
+ StorageDead(_8);
97101
+ StorageDead(_10);
98102
+ drop(((*_4).0: alloc::raw_vec::RawVec<A>)) -> [return: bb1, unwind unreachable];
99103
+ }
100104
+
101105
+ bb3: {
102-
+ _13 = &raw mut (*_8)[_12];
103-
+ _12 = Add(move _12, const 1_usize);
104-
+ drop((*_13)) -> [return: bb4, unwind unreachable];
106+
+ _14 = &raw mut (*_8)[_13];
107+
+ _13 = Add(move _13, const 1_usize);
108+
+ drop((*_14)) -> [return: bb4, unwind unreachable];
105109
+ }
106110
+
107111
+ bb4: {
108-
+ _14 = Eq(copy _12, copy _10);
109-
+ switchInt(move _14) -> [0: bb3, otherwise: bb2];
112+
+ _15 = Eq(copy _13, copy _10);
113+
+ switchInt(move _15) -> [0: bb3, otherwise: bb2];
110114
+ }
111115
+
112116
+ bb5: {
117+
+ StorageDead(_17);
113118
+ StorageDead(_16);
114-
+ StorageDead(_15);
115119
StorageDead(_5);
116120
return;
117121
+ }

‎tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
77
debug self => _1;
88
scope 2 (inlined Vec::<u8>::as_slice) {
99
debug self => _1;
10-
let mut _3: *const u8;
11-
let mut _4: usize;
10+
let mut _4: *const u8;
11+
let mut _5: usize;
1212
scope 3 (inlined Vec::<u8>::as_ptr) {
1313
debug self => _1;
1414
scope 4 (inlined alloc::raw_vec::RawVec::<u8>::ptr) {
@@ -17,6 +17,7 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
1717
let mut _2: std::ptr::NonNull<u8>;
1818
scope 7 (inlined Unique::<u8>::cast::<u8>) {
1919
scope 8 (inlined NonNull::<u8>::cast::<u8>) {
20+
let mut _3: (*const u8) is !null;
2021
scope 9 (inlined NonNull::<u8>::as_ptr) {
2122
}
2223
}
@@ -30,9 +31,9 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
3031
}
3132
}
3233
scope 12 (inlined #[track_caller] std::slice::from_raw_parts::<'_, u8>) {
33-
debug data => _3;
34-
debug len => _4;
35-
let _5: *const [u8];
34+
debug data => _4;
35+
debug len => _5;
36+
let _6: *const [u8];
3637
scope 13 (inlined core::ub_checks::check_language_ub) {
3738
scope 14 (inlined core::ub_checks::check_language_ub::runtime) {
3839
}
@@ -42,30 +43,33 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
4243
scope 16 (inlined align_of::<u8>) {
4344
}
4445
scope 17 (inlined slice_from_raw_parts::<u8>) {
45-
debug data => _3;
46-
debug len => _4;
46+
debug data => _4;
47+
debug len => _5;
4748
scope 18 (inlined std::ptr::from_raw_parts::<[u8], u8>) {
48-
debug data_pointer => _3;
49+
debug data_pointer => _4;
4950
}
5051
}
5152
}
5253
}
5354
}
5455

5556
bb0: {
56-
StorageLive(_2);
5757
StorageLive(_3);
58-
_2 = copy (((((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
59-
_3 = copy _2 as *const u8 (Transmute);
6058
StorageLive(_4);
61-
_4 = copy ((*_1).1: usize);
59+
StorageLive(_2);
60+
_2 = copy (((((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
61+
_3 = copy _2 as (*const u8) is !null (Transmute);
62+
StorageDead(_2);
63+
_4 = copy _3 as *const u8 (Transmute);
6264
StorageLive(_5);
63-
_5 = *const [u8] from (copy _3, copy _4);
64-
_0 = &(*_5);
65+
_5 = copy ((*_1).1: usize);
66+
StorageLive(_6);
67+
_6 = *const [u8] from (copy _4, copy _5);
68+
_0 = &(*_6);
69+
StorageDead(_6);
6570
StorageDead(_5);
6671
StorageDead(_4);
6772
StorageDead(_3);
68-
StorageDead(_2);
6973
return;
7074
}
7175
}

‎tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
77
debug self => _1;
88
scope 2 (inlined Vec::<u8>::as_slice) {
99
debug self => _1;
10-
let mut _3: *const u8;
11-
let mut _4: usize;
10+
let mut _4: *const u8;
11+
let mut _5: usize;
1212
scope 3 (inlined Vec::<u8>::as_ptr) {
1313
debug self => _1;
1414
scope 4 (inlined alloc::raw_vec::RawVec::<u8>::ptr) {
@@ -17,6 +17,7 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
1717
let mut _2: std::ptr::NonNull<u8>;
1818
scope 7 (inlined Unique::<u8>::cast::<u8>) {
1919
scope 8 (inlined NonNull::<u8>::cast::<u8>) {
20+
let mut _3: (*const u8) is !null;
2021
scope 9 (inlined NonNull::<u8>::as_ptr) {
2122
}
2223
}
@@ -30,9 +31,9 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
3031
}
3132
}
3233
scope 12 (inlined #[track_caller] std::slice::from_raw_parts::<'_, u8>) {
33-
debug data => _3;
34-
debug len => _4;
35-
let _5: *const [u8];
34+
debug data => _4;
35+
debug len => _5;
36+
let _6: *const [u8];
3637
scope 13 (inlined core::ub_checks::check_language_ub) {
3738
scope 14 (inlined core::ub_checks::check_language_ub::runtime) {
3839
}
@@ -42,30 +43,33 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
4243
scope 16 (inlined align_of::<u8>) {
4344
}
4445
scope 17 (inlined slice_from_raw_parts::<u8>) {
45-
debug data => _3;
46-
debug len => _4;
46+
debug data => _4;
47+
debug len => _5;
4748
scope 18 (inlined std::ptr::from_raw_parts::<[u8], u8>) {
48-
debug data_pointer => _3;
49+
debug data_pointer => _4;
4950
}
5051
}
5152
}
5253
}
5354
}
5455

5556
bb0: {
56-
StorageLive(_2);
5757
StorageLive(_3);
58-
_2 = copy (((((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
59-
_3 = copy _2 as *const u8 (Transmute);
6058
StorageLive(_4);
61-
_4 = copy ((*_1).1: usize);
59+
StorageLive(_2);
60+
_2 = copy (((((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
61+
_3 = copy _2 as (*const u8) is !null (Transmute);
62+
StorageDead(_2);
63+
_4 = copy _3 as *const u8 (Transmute);
6264
StorageLive(_5);
63-
_5 = *const [u8] from (copy _3, copy _4);
64-
_0 = &(*_5);
65+
_5 = copy ((*_1).1: usize);
66+
StorageLive(_6);
67+
_6 = *const [u8] from (copy _4, copy _5);
68+
_0 = &(*_6);
69+
StorageDead(_6);
6570
StorageDead(_5);
6671
StorageDead(_4);
6772
StorageDead(_3);
68-
StorageDead(_2);
6973
return;
7074
}
7175
}

‎tests/ui/consts/const-eval/raw-bytes.32bit.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
5353
78 00 00 00 ff ff ff ff │ x.......
5454
}
5555

56-
error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1
56+
error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1
5757
--> $DIR/raw-bytes.rs:58:1
5858
|
5959
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
@@ -108,7 +108,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
108108
14 00 00 00 │ ....
109109
}
110110

111-
error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1
111+
error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1
112112
--> $DIR/raw-bytes.rs:78:1
113113
|
114114
LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {

‎tests/ui/consts/const-eval/raw-bytes.64bit.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
5353
78 00 00 00 ff ff ff ff │ x.......
5454
}
5555

56-
error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1
56+
error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1
5757
--> $DIR/raw-bytes.rs:58:1
5858
|
5959
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
@@ -108,7 +108,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
108108
14 00 00 00 │ ....
109109
}
110110

111-
error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1
111+
error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1
112112
--> $DIR/raw-bytes.rs:78:1
113113
|
114114
LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {

‎tests/ui/consts/const-eval/ub-nonnull.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1
1+
error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1
22
--> $DIR/ub-nonnull.rs:16:1
33
|
44
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
@@ -65,7 +65,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
6565
HEX_DUMP
6666
}
6767

68-
error[E0080]: constructing invalid value: encountered 0, but expected something greater or equal to 1
68+
error[E0080]: constructing invalid value at .pointer: encountered 0, but expected something greater or equal to 1
6969
--> $DIR/ub-nonnull.rs:53:1
7070
|
7171
LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {

‎tests/ui/lint/invalid_value.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ LL | let _val: NonNull<i32> = mem::uninitialized();
314314
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
315315
|
316316
= note: `std::ptr::NonNull<i32>` must be non-null
317-
= note: raw pointers must be initialized
318317

319318
error: the type `(NonZero<u32>, i32)` does not permit zero-initialization
320319
--> $DIR/invalid_value.rs:94:41
@@ -623,7 +622,6 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
623622
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
624623
|
625624
= note: `std::ptr::NonNull<i32>` must be non-null
626-
= note: raw pointers must be initialized
627625

628626
error: the type `bool` does not permit being left uninitialized
629627
--> $DIR/invalid_value.rs:158:26

0 commit comments

Comments
 (0)
Please sign in to comment.