]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/regions-close-over-type-parameter-2.rs
Rollup merge of #87922 - Manishearth:c-enum-target-spec, r=nagisa,eddyb
[rust.git] / src / test / ui / span / regions-close-over-type-parameter-2.rs
1 #![feature(box_syntax)]
2
3 // Test for what happens when a type parameter `A` is closed over into
4 // an object. This should yield errors unless `A` (and the object)
5 // both have suitable bounds.
6
7 trait Foo { fn get(&self); }
8
9 impl<A> Foo for A {
10     fn get(&self) { }
11 }
12
13 fn repeater3<'a,A:'a>(v: A) -> Box<dyn Foo + 'a> {
14     box v as Box<dyn Foo+'a>
15 }
16
17 fn main() {
18     // Error results because the type of is inferred to be
19     // ~Repeat<&'blk isize> where blk is the lifetime of the block below.
20
21     let _ = {
22         let tmp0 = 3;
23         let tmp1 = &tmp0;
24         repeater3(tmp1)
25     };
26     //~^^^ ERROR `tmp0` does not live long enough
27 }