]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/region-escape-via-bound-contravariant-closure.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-closure.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 fn foo(x: &'x u32) -> impl Fn() -> &'y u32
14 where 'x: 'y
15 {
16     move || x
17 }
18
19 fn main() { }