@@ -32,7 +32,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
3232 }
3333
3434error[E0080]: it is undefined behavior to use this value
35- --> $DIR/ub-ref-ptr.rs:26 :1
35+ --> $DIR/ub-ref-ptr.rs:27 :1
3636 |
3737LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
3838 | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
@@ -43,7 +43,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
4343 }
4444
4545error[E0080]: evaluation of constant value failed
46- --> $DIR/ub-ref-ptr.rs:33 :1
46+ --> $DIR/ub-ref-ptr.rs:35 :1
4747 |
4848LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
4949 | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -52,7 +52,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
5252 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
5353
5454error[E0080]: evaluation of constant value failed
55- --> $DIR/ub-ref-ptr.rs:36 :39
55+ --> $DIR/ub-ref-ptr.rs:38 :39
5656 |
5757LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
5858 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -61,13 +61,13 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
6161 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
6262
6363note: erroneous constant encountered
64- --> $DIR/ub-ref-ptr.rs:36 :38
64+ --> $DIR/ub-ref-ptr.rs:38 :38
6565 |
6666LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
6767 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6868
6969error[E0080]: evaluation of constant value failed
70- --> $DIR/ub-ref-ptr.rs:39 :86
70+ --> $DIR/ub-ref-ptr.rs:41 :86
7171 |
7272LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
7373 | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -76,13 +76,13 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us
7676 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
7777
7878note: erroneous constant encountered
79- --> $DIR/ub-ref-ptr.rs:39 :85
79+ --> $DIR/ub-ref-ptr.rs:41 :85
8080 |
8181LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
8282 | ^^^^^^^^^^^^^^^^^^^^^
8383
8484error[E0080]: it is undefined behavior to use this value
85- --> $DIR/ub-ref-ptr.rs:42 :1
85+ --> $DIR/ub-ref-ptr.rs:44 :1
8686 |
8787LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
8888 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
@@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
9393 }
9494
9595error[E0080]: it is undefined behavior to use this value
96- --> $DIR/ub-ref-ptr.rs:45 :1
96+ --> $DIR/ub-ref-ptr.rs:48 :1
9797 |
9898LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
9999 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
@@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
104104 }
105105
106106error[E0080]: evaluation of constant value failed
107- --> $DIR/ub-ref-ptr.rs:48 :41
107+ --> $DIR/ub-ref-ptr.rs:52 :41
108108 |
109109LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
110110 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
111111
112112error[E0080]: it is undefined behavior to use this value
113- --> $DIR/ub-ref-ptr.rs:52 :1
113+ --> $DIR/ub-ref-ptr.rs:56 :1
114114 |
115115LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
116116 | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
@@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
121121 }
122122
123123error[E0080]: evaluation of constant value failed
124- --> $DIR/ub-ref-ptr.rs:54 :38
124+ --> $DIR/ub-ref-ptr.rs:59 :38
125125 |
126126LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
127127 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
128128
129129error[E0080]: it is undefined behavior to use this value
130- --> $DIR/ub-ref-ptr.rs:57 :1
130+ --> $DIR/ub-ref-ptr.rs:62 :1
131131 |
132132LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
133133 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
@@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
138138 }
139139
140140error[E0080]: it is undefined behavior to use this value
141- --> $DIR/ub-ref-ptr.rs:59 :1
141+ --> $DIR/ub-ref-ptr.rs:65 :1
142142 |
143143LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
144144 | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer
@@ -158,13 +158,13 @@ note: inside `std::ptr::read::<u32>`
158158note: inside `std::ptr::const_ptr::<impl *const u32>::read`
159159 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
160160note: inside `UNALIGNED_READ`
161- --> $DIR/ub-ref-ptr.rs:66 :5
161+ --> $DIR/ub-ref-ptr.rs:73 :5
162162 |
163163LL | ptr.read();
164164 | ^^^^^^^^^^
165165
166166error[E0080]: it is undefined behavior to use this value
167- --> $DIR/ub-ref-ptr.rs:69 :1
167+ --> $DIR/ub-ref-ptr.rs:76 :1
168168 |
169169LL | const POINTS_TO_FUNCTION: &() = unsafe {
170170 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a function
@@ -175,7 +175,7 @@ LL | const POINTS_TO_FUNCTION: &() = unsafe {
175175 }
176176
177177error[E0080]: it is undefined behavior to use this value
178- --> $DIR/ub-ref-ptr.rs:74 :1
178+ --> $DIR/ub-ref-ptr.rs:81 :1
179179 |
180180LL | const POINTS_TO_VTABLE: (&(), &()) = unsafe {
181181 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .1: encountered a reference pointing to a vtable
0 commit comments