]> git.lizzy.rs Git - rust.git/blob - tests/ui/impl-trait/can-return-unconstrained-closure.rs
Auto merge of #106742 - compiler-errors:new-solver-make-it-not-ice, r=lcnr
[rust.git] / tests / ui / impl-trait / can-return-unconstrained-closure.rs
1 // Test that we are special casing "outlives" for opaque types.
2 //
3 // The return type of a closure is not required to outlive the closure. As such
4 // the following code would not compile if we used a standard outlives check
5 // when checking the return type, because the return type of the closure would
6 // be `&ReEmpty i32`, and we don't allow `ReEmpty` to occur in the concrete
7 // type used for an opaque type.
8 //
9 // However, opaque types are special cased to include check all regions in the
10 // concrete type against the bound, which forces the return type to be
11 // `&'static i32` here.
12
13 // build-pass (FIXME(62277): could be check-pass?)
14
15 fn make_identity() -> impl Sized {
16     |x: &'static i32| x
17 }
18
19 fn make_identity_static() -> impl Sized + 'static {
20     |x: &'static i32| x
21 }
22
23 fn main() {}