]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-22323-temp-destruction.rs
Auto merge of #105121 - oli-obk:simpler-cheaper-dump_mir, r=nnethercote
[rust.git] / src / test / ui / nll / issue-22323-temp-destruction.rs
1 // rust-lang/rust#22323: regression test demonstrating that NLL
2 // precisely tracks temporary destruction order.
3
4 // check-pass
5
6 fn main() {
7     let _s = construct().borrow().consume_borrowed();
8 }
9
10 fn construct() -> Value { Value }
11
12 pub struct Value;
13
14 impl Value {
15     fn borrow<'a>(&'a self) -> Borrowed<'a> { unimplemented!() }
16 }
17
18 pub struct Borrowed<'a> {
19     _inner: Guard<'a, Value>,
20 }
21
22 impl<'a> Borrowed<'a> {
23     fn consume_borrowed(self) -> String { unimplemented!() }
24 }
25
26 pub struct Guard<'a, T: ?Sized + 'a> {
27     _lock: &'a T,
28 }
29
30 impl<'a, T: ?Sized> Drop for Guard<'a, T> { fn drop(&mut self) {} }