fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
7.0 KiB134 linesraw
1error[E0080]: it is undefined behavior to use this value
2  --> $DIR/ub-enum.rs:27:1
3   |
4LL | 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: $SIZE, align: $ALIGN) {
9               HEX_DUMP
10           }
11
12error[E0080]: evaluation of constant value failed
13  --> $DIR/ub-enum.rs:30:1
14   |
15LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) };
16   | ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
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
21error[E0080]: evaluation of constant value failed
22  --> $DIR/ub-enum.rs:33:1
23   |
24LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
25   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
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
30error[E0080]: it is undefined behavior to use this value
31  --> $DIR/ub-enum.rs:45:1
32   |
33LL | 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: $SIZE, align: $ALIGN) {
38               HEX_DUMP
39           }
40
41error[E0080]: evaluation of constant value failed
42  --> $DIR/ub-enum.rs:47:1
43   |
44LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) };
45   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
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
50error[E0080]: evaluation of constant value failed
51  --> $DIR/ub-enum.rs:50:1
52   |
53LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
54   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
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
59error[E0080]: evaluation of constant value failed
60  --> $DIR/ub-enum.rs:59:42
61   |
62LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init };
63   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
64
65error[E0080]: evaluation of constant value failed
66  --> $DIR/ub-enum.rs:64:1
67   |
68LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
69   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
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
74error[E0080]: it is undefined behavior to use this value
75  --> $DIR/ub-enum.rs:81:1
76   |
77LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
78   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
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: $SIZE, align: $ALIGN) {
82               HEX_DUMP
83           }
84
85error[E0080]: it is undefined behavior to use this value
86  --> $DIR/ub-enum.rs:83:1
87   |
88LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
89   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
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: $SIZE, align: $ALIGN) {
93               HEX_DUMP
94           }
95
96error[E0080]: it is undefined behavior to use this value
97  --> $DIR/ub-enum.rs:91:1
98   |
99LL | 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: $SIZE, align: $ALIGN) {
104               HEX_DUMP
105           }
106
107error[E0080]: evaluation of constant value failed
108  --> $DIR/ub-enum.rs:96:77
109   |
110LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
111   |                                                                             ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
112
113error[E0080]: evaluation of constant value failed
114  --> $DIR/ub-enum.rs:98:77
115   |
116LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
117   |                                                                             ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
118
119error[E0080]: evaluation of constant value failed
120  --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
121   |
122   = note: read discriminant of an uninhabited enum variant
123   |
124note: inside `discriminant::<Never>`
125  --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
126note: inside `TEST_ICE_89765`
127  --> $DIR/ub-enum.rs:103:14
128   |
129LL |     unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); };
130   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131
132error: aborting due to 14 previous errors
133
134For more information about this error, try `rustc --explain E0080`.