]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/ub-enum.64bit.stderr
Rollup merge of #101655 - dns2utf8:box_docs, r=dtolnay
[rust.git] / src / test / ui / consts / const-eval / ub-enum.64bit.stderr
1 error[E0080]: it is undefined behavior to use this value
2   --> $DIR/ub-enum.rs:24:1
3    |
4 LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
5    | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000001, but expected a valid enum tag
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    = note: the raw bytes of the constant (size: 8, align: 8) {
9                01 00 00 00 00 00 00 00                         │ ........
10            }
11
12 error[E0080]: evaluation of constant value failed
13   --> $DIR/ub-enum.rs:27:1
14    |
15 LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) };
16    | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
17    |
18    = help: this code performed an operation that depends on the underlying bytes representing a pointer
19    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
20
21 error[E0080]: evaluation of constant value failed
22   --> $DIR/ub-enum.rs:30:1
23    |
24 LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
25    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
26    |
27    = help: this code performed an operation that depends on the underlying bytes representing a pointer
28    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
29
30 error[E0080]: it is undefined behavior to use this value
31   --> $DIR/ub-enum.rs:42:1
32    |
33 LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
34    | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag
35    |
36    = 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.
37    = note: the raw bytes of the constant (size: 8, align: 8) {
38                00 00 00 00 00 00 00 00                         │ ........
39            }
40
41 error[E0080]: evaluation of constant value failed
42   --> $DIR/ub-enum.rs:44:1
43    |
44 LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) };
45    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
46    |
47    = help: this code performed an operation that depends on the underlying bytes representing a pointer
48    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
49
50 error[E0080]: evaluation of constant value failed
51   --> $DIR/ub-enum.rs:47:1
52    |
53 LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
54    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
55    |
56    = help: this code performed an operation that depends on the underlying bytes representing a pointer
57    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
58
59 error[E0080]: evaluation of constant value failed
60   --> $DIR/ub-enum.rs:56:42
61    |
62 LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init };
63    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
64
65 error[E0080]: evaluation of constant value failed
66   --> $DIR/ub-enum.rs:61:1
67    |
68 LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
69    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
70    |
71    = help: this code performed an operation that depends on the underlying bytes representing a pointer
72    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
73
74 error[E0080]: it is undefined behavior to use this value
75   --> $DIR/ub-enum.rs:78:1
76    |
77 LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
78    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(B)>.0: encountered a value of the never type `!`
79    |
80    = 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.
81    = note: the raw bytes of the constant (size: 1, align: 1) {
82                01                                              │ .
83            }
84
85 error[E0080]: it is undefined behavior to use this value
86   --> $DIR/ub-enum.rs:80:1
87    |
88 LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
89    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never
90    |
91    = 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.
92    = note: the raw bytes of the constant (size: 1, align: 1) {
93                03                                              │ .
94            }
95
96 error[E0080]: it is undefined behavior to use this value
97   --> $DIR/ub-enum.rs:88:1
98    |
99 LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
100    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
101    |
102    = 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.
103    = note: the raw bytes of the constant (size: 8, align: 4) {
104                78 00 00 00 ff ff ff ff                         │ x.......
105            }
106
107 error[E0080]: evaluation of constant value failed
108   --> $DIR/ub-enum.rs:93:77
109    |
110 LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
111    |                                                                             ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
112
113 error[E0080]: evaluation of constant value failed
114   --> $DIR/ub-enum.rs:95:77
115    |
116 LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
117    |                                                                             ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type
118
119 error: aborting due to 13 previous errors
120
121 For more information about this error, try `rustc --explain E0080`.