]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/regions-close-over-type-parameter-2.rs
Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
[rust.git] / src / test / ui / span / regions-close-over-type-parameter-2.rs
1 // Test for what happens when a type parameter `A` is closed over into
2 // an object. This should yield errors unless `A` (and the object)
3 // both have suitable bounds.
4
5 trait Foo { fn get(&self); }
6
7 impl<A> Foo for A {
8     fn get(&self) {
9     }
10 }
11
12 fn repeater3<'a,A:'a>(v: A) -> Box<dyn Foo + 'a> {
13     Box::new(v) as Box<dyn Foo+'a>
14 }
15
16 fn main() {
17
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 }