]> git.proxmox.com Git - rustc.git/blob - src/test/ui/nll/user-annotations/closure-substs.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / nll / user-annotations / closure-substs.rs
1 // Test that we enforce user-provided type annotations on closures.
2
3 fn foo<'a>() {
4 // Here `x` is free in the closure sig:
5 |x: &'a i32| -> &'static i32 {
6 return x; //~ ERROR lifetime may not live long enough
7 };
8 }
9
10 fn foo1() {
11 // Here `x` is bound in the closure sig:
12 |x: &i32| -> &'static i32 {
13 return x; //~ ERROR lifetime may not live long enough
14 };
15 }
16
17 fn bar<'a>() {
18 // Here `x` is free in the closure sig:
19 |x: &'a i32, b: fn(&'static i32)| {
20 b(x); //~ ERROR lifetime may not live long enough
21 };
22 }
23
24 fn bar1() {
25 // Here `x` is bound in the closure sig:
26 |x: &i32, b: fn(&'static i32)| {
27 b(x); //~ ERROR borrowed data escapes outside of closure
28 };
29 }
30
31 fn main() {}