about summary refs log tree commit diff
path: root/tests/ui/consts/dangling-alloc-id-ice.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/dangling-alloc-id-ice.rs')
-rw-r--r--tests/ui/consts/dangling-alloc-id-ice.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/consts/dangling-alloc-id-ice.rs b/tests/ui/consts/dangling-alloc-id-ice.rs
new file mode 100644
index 00000000000..d591bfc731c
--- /dev/null
+++ b/tests/ui/consts/dangling-alloc-id-ice.rs
@@ -0,0 +1,14 @@
+// https://github.com/rust-lang/rust/issues/55223
+
+union Foo<'a> {
+    y: &'a (),
+    long_live_the_unit: &'static (),
+}
+
+const FOO: &() = {
+//~^ ERROR encountered dangling pointer in final constant
+    let y = ();
+    unsafe { Foo { y: &y }.long_live_the_unit }
+};
+
+fn main() {}