diff options
Diffstat (limited to 'tests/ui/fn/suggest-return-closure.rs')
-rw-r--r-- | tests/ui/fn/suggest-return-closure.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/fn/suggest-return-closure.rs b/tests/ui/fn/suggest-return-closure.rs new file mode 100644 index 000000000..33daa1ea0 --- /dev/null +++ b/tests/ui/fn/suggest-return-closure.rs @@ -0,0 +1,34 @@ +fn fn_once() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] + //~| NOTE not allowed in type signatures + //~| HELP replace with an appropriate return type + //~| SUGGESTION impl FnOnce() + //~| NOTE for more information on `Fn` traits and closure types + let x = String::new(); + || { + drop(x); + } +} + +fn fn_mut() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] + //~| NOTE not allowed in type signatures + //~| HELP replace with an appropriate return type + //~| SUGGESTION impl FnMut(char) + //~| NOTE for more information on `Fn` traits and closure types + let x = String::new(); + |c| { + x.push(c); + } +} + +fn fun() -> _ { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] + //~| NOTE not allowed in type signatures + //~| HELP replace with an appropriate return type + //~| SUGGESTION impl Fn() -> i32 + //~| NOTE for more information on `Fn` traits and closure types + || 1i32 +} + +fn main() {} |