]> git.proxmox.com Git - rustc.git/blob - src/test/ui/impl-trait/issues/issue-57464-unexpected-regions.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / impl-trait / issues / issue-57464-unexpected-regions.rs
1 // Regression test for issue 57464.
2 //
3 // Closure are (surprisingly) allowed to outlive their signature. As such it
4 // was possible to end up with `ReScope`s appearing in the concrete type of an
5 // opaque type. As all regions are now required to outlive the bound in an
6 // opaque type we avoid the issue here.
7
8 // check-pass
9
10 struct A<F>(F);
11
12 unsafe impl <'a, 'b, F: Fn(&'a i32) -> &'b i32> Send for A<F> {}
13
14 fn wrapped_closure() -> impl Sized {
15 let f = |x| x;
16 f(&0);
17 A(f)
18 }
19
20 fn wrapped_closure_with_bound() -> impl Sized + 'static {
21 let f = |x| x;
22 f(&0);
23 A(f)
24 }
25
26 fn main() {
27 let x: Box<dyn Send> = Box::new(wrapped_closure());
28 let y: Box<dyn Send> = Box::new(wrapped_closure_with_bound());
29 }