We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e05aae8 commit b1d4cbcCopy full SHA for b1d4cbc
tests/ui/consts/dangling_raw_ptr.rs
@@ -3,6 +3,16 @@ const FOO: *const u32 = { //~ ERROR it is undefined behavior
3
&x
4
};
5
6
+union Union {
7
+ ptr: *const u32
8
+}
9
+
10
+const BAR: Union = { //~ ERROR encountered dangling pointer in final value
11
+ let x = 42;
12
+ Union { ptr: &x }
13
+};
14
15
fn main() {
16
let x = FOO;
17
+ let x = BAR;
18
}
tests/ui/consts/dangling_raw_ptr.stderr
@@ -9,6 +9,12 @@ LL | const FOO: *const u32 = {
╾ALLOC0<imm>╼ │ ╾──────╼
-error: aborting due to 1 previous error
+error: encountered dangling pointer in final value of constant
+ --> $DIR/dangling_raw_ptr.rs:10:1
+ |
+LL | const BAR: Union = {
+ | ^^^^^^^^^^^^^^^^
+error: aborting due to 2 previous errors
19
20
For more information about this error, try `rustc --explain E0080`.
0 commit comments