diff options
Diffstat (limited to 'tests/ui/consts/dangling-alloc-id-ice.rs')
-rw-r--r-- | tests/ui/consts/dangling-alloc-id-ice.rs | 14 |
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 000000000..d591bfc73 --- /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() {} |