]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/ub-ref.stderr
Rollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJung
[rust.git] / src / test / ui / consts / const-eval / ub-ref.stderr
1 error[E0080]: it is undefined behavior to use this value
2   --> $DIR/ub-ref.rs:7:1
3    |
4 LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
5    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered an unaligned reference (required 2 byte alignment but found 1)
6    |
7    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
8
9 error[E0080]: it is undefined behavior to use this value
10   --> $DIR/ub-ref.rs:11:1
11    |
12 LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
13    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered an unaligned box (required 2 byte alignment but found 1)
14    |
15    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
16
17 error[E0080]: it is undefined behavior to use this value
18   --> $DIR/ub-ref.rs:15:1
19    |
20 LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
21    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL reference
22    |
23    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
24
25 error[E0080]: it is undefined behavior to use this value
26   --> $DIR/ub-ref.rs:18:1
27    |
28 LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
29    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a NULL box
30    |
31    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
32
33 error[E0080]: it is undefined behavior to use this value
34   --> $DIR/ub-ref.rs:24:1
35    |
36 LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
37    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain (non-pointer) bytes
38    |
39    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
40
41 error[E0080]: it is undefined behavior to use this value
42   --> $DIR/ub-ref.rs:27:1
43    |
44 LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
45    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at .<deref>, but expected plain (non-pointer) bytes
46    |
47    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
48
49 error[E0080]: it is undefined behavior to use this value
50   --> $DIR/ub-ref.rs:30:1
51    |
52 LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
53    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at .<deref>, but expected plain (non-pointer) bytes
54    |
55    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
56
57 error[E0080]: it is undefined behavior to use this value
58   --> $DIR/ub-ref.rs:33:1
59    |
60 LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
61    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (created from integer)
62    |
63    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
64
65 error[E0080]: it is undefined behavior to use this value
66   --> $DIR/ub-ref.rs:36:1
67    |
68 LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
69    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling box (created from integer)
70    |
71    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
72
73 error: aborting due to 9 previous errors
74
75 For more information about this error, try `rustc --explain E0080`.