]>
git.proxmox.com Git - rustc.git/blob - tests/ui/dropck/issue-28498-ugeh-with-lifetime-param.rs
3 // Demonstrate the use of the unguarded escape hatch with a lifetime param
4 // to assert that destructor will not access any dead data.
6 // Compare with ui/span/issue28498-reject-lifetime-param.rs
8 #![feature(dropck_eyepatch)]
11 struct ScribbleOnDrop(String
);
13 impl Drop
for ScribbleOnDrop
{
15 self.0 = format
!("DROPPED");
19 struct Foo
<'a
>(u32, &'a ScribbleOnDrop
);
21 unsafe impl<#[may_dangle] 'a> Drop for Foo<'a> {
23 // Use of `may_dangle` is sound, because destructor never accesses `self.1`.
24 println
!("Dropping Foo({}, _)", self.0);
29 let (last_dropped
, foo0
);
30 let (foo1
, first_dropped
);
32 last_dropped
= ScribbleOnDrop(format
!("last"));
33 first_dropped
= ScribbleOnDrop(format
!("first"));
34 foo0
= Foo(0, &last_dropped
);
35 foo1
= Foo(1, &first_dropped
);
37 println
!("foo0.1: {:?} foo1.1: {:?}", foo0
.1
, foo1
.1
);