]>
Commit | Line | Data |
---|---|---|
c1a9b12d SL |
1 | // check that dropck does the right thing with misc. Ty variants |
2 | ||
3 | use std::fmt; | |
4 | struct NoisyDrop<T: fmt::Debug>(T); | |
5 | impl<T: fmt::Debug> Drop for NoisyDrop<T> { | |
6 | fn drop(&mut self) { | |
7 | let _ = vec!["0wned"]; | |
8 | println!("dropping {:?}", self.0) | |
9 | } | |
10 | } | |
11 | ||
12 | trait Associator { | |
13 | type As; | |
14 | } | |
15 | impl<T: fmt::Debug> Associator for T { | |
16 | type As = NoisyDrop<T>; | |
17 | } | |
18 | struct Wrap<A: Associator>(<A as Associator>::As); | |
19 | ||
20 | fn projection() { | |
21 | let (_w, bomb); | |
22 | bomb = vec![""]; | |
23 | _w = Wrap::<&[&str]>(NoisyDrop(&bomb)); | |
c1a9b12d | 24 | } |
ff7c6d11 | 25 | //~^^ ERROR `bomb` does not live long enough |
c1a9b12d SL |
26 | |
27 | fn closure() { | |
28 | let (_w,v); | |
29 | v = vec![""]; | |
30 | _w = { | |
31 | let u = NoisyDrop(&v); | |
ff7c6d11 | 32 | //~^ ERROR `v` does not live long enough |
c1a9b12d SL |
33 | move || u.0.len() |
34 | }; | |
35 | } | |
36 | ||
37 | fn main() { closure(); projection() } |