]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/region-escape-via-bound.rs
Rollup merge of #93400 - ChayimFriedman2:dont-suggest-using-const-with-bounds-unused...
[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
8 use std::cell::Cell;
9
10 trait Trait<'a> { }
11
12 impl<'a, 'b> Trait<'b> for Cell<&'a u32> { }
13
14 fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y>
15     //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds [E0700]
16 where 'x: 'y
17 {
18     x
19 }
20
21 fn main() { }