]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/region-escape-via-bound.rs
Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obk
[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 where 'x: 'y
16 {
17     x
18     //~^ ERROR hidden type for `impl Trait<'y>` captures lifetime that does not appear in bounds [E0700]
19 }
20
21 fn main() { }