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