]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/region-escape-via-bound-contravariant-closure.rs
Rollup merge of #103159 - cuviper:check_pow-final-try_opt, r=Mark-Simulacrum
[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
12 fn foo<'x, 'y>(x: &'x u32) -> impl Fn() -> &'y u32
13 where 'x: 'y
14 {
15     move || x
16 }
17
18 fn main() { }