]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/dropck_misc_variants.rs
Rollup merge of #87922 - Manishearth:c-enum-target-spec, r=nagisa,eddyb
[rust.git] / src / test / ui / span / dropck_misc_variants.rs
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));
24 }
25 //~^^ ERROR `bomb` does not live long enough
26
27 fn closure() {
28     let (_w,v);
29     v = vec![""];
30     _w = {
31         let u = NoisyDrop(&v);
32         //~^ ERROR `v` does not live long enough
33         move || u.0.len()
34     };
35 }
36
37 fn main() { closure(); projection() }