]> git.proxmox.com Git - rustc.git/blame - src/test/ui/closures/binder/implicit-stuff.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / closures / binder / implicit-stuff.rs
CommitLineData
064997fb
FG
1#![feature(closure_lifetime_binder)]
2
3fn main() {
4 // Implicit types
5 let _ = for<> || {}; //~ ERROR implicit types in closure signatures are forbidden when `for<...>` is present
6 let _ = for<'a> || -> &'a _ { &() }; //~ ERROR implicit types in closure signatures are forbidden when `for<...>` is present
7 let _ = for<'a> |x| -> &'a () { x }; //~ ERROR implicit types in closure signatures are forbidden when `for<...>` is present
8 let _ = for<'a> |x: &'a _| -> &'a () { x }; //~ ERROR implicit types in closure signatures are forbidden when `for<...>` is present
9 let _ = for<'a> |x: &'a Vec::<_>| -> &'a Vec::<()> { x }; //~ ERROR implicit types in closure signatures are forbidden when `for<...>` is present
10 let _ = for<'a> |x: &'a Vec<()>| -> &'a Vec<_> { x }; //~ ERROR implicit types in closure signatures are forbidden when `for<...>` is present
11 let _ = for<'a> |x: &'a _| -> &'a &'a () { x }; //~ ERROR implicit types in closure signatures are forbidden when `for<...>` is present
12 let _ = for<'a> |x: &'a _, y, z: _| -> &'a _ { //~ ERROR implicit types in closure signatures are forbidden when `for<...>` is present
13 let _: &u8 = x;
14 let _: u32 = y;
15 let _: i32 = z;
16 x
17 };
18
19 // Lifetime elision
20 let _ = for<> |_: &()| -> () {}; //~ ERROR `&` without an explicit lifetime name cannot be used here
21 let _ = for<> |x: &()| -> &() { x }; //~ ERROR `&` without an explicit lifetime name cannot be used here
22 //~| ERROR `&` without an explicit lifetime name cannot be used here
23 let _ = for<> |x: &'_ ()| -> &'_ () { x }; //~ ERROR `'_` cannot be used here
24 //~| ERROR `'_` cannot be used here
25 let _ = for<'a> |x: &()| -> &'a () { x }; //~ ERROR `&` without an explicit lifetime name cannot be used here
26 let _ = for<'a> |x: &'a ()| -> &() { x }; //~ ERROR `&` without an explicit lifetime name cannot be used here
27}