]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/region-escape-via-bound.rs
Rollup merge of #93568 - willcrichton:scrape-examples-leading-whitespace, r=CraftSpider
[rust.git] / src / test / ui / impl-trait / region-escape-via-bound.rs
1 // Test that we do not allow the region `'x` to escape in the impl
2 // trait **even though** `'y` escapes, which outlives `'x`.
3 //
4 // See https://github.com/rust-lang/rust/issues/46541 for more details.
5
6 #![allow(dead_code)]
7 #![feature(in_band_lifetimes)]
8
9 use std::cell::Cell;
10
11 trait Trait<'a> { }
12
13 impl Trait<'b> for Cell<&'a u32> { }
14
15 fn foo(x: Cell<&'x u32>) -> impl Trait<'y>
16 where 'x: 'y
17 {
18     x
19     //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds [E0700]
20 }
21
22 fn main() { }