blob: 79319dfe796a2e51e623d0cda08d7d10e3ca9eee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// In contrast to `region-escape-via-bound-invariant`, in this case we
// *can* return a value of type `&'x u32`, even though `'x` does not
// appear in the bounds. This is because `&` is contravariant, and so
// we are *actually* returning a `&'y u32`.
//
// See https://github.com/rust-lang/rust/issues/46541 for more details.
// run-pass
#![allow(dead_code)]
trait Trait<'a> { }
impl<'a, 'b> Trait<'b> for &'a u32 { }
fn foo<'x, 'y>(x: &'x u32) -> impl Trait<'y>
where 'x: 'y
{
x
}
fn main() { }
|