forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#59035 - estebank:closure-instacall, r=david…
…twco When encountetring `||{}()`, suggest the likely intended `(||{})()` Fix rust-lang#55851.
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
let _ = ||{}(); | ||
//~^ ERROR expected function, found `()` | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/suggest-on-bare-closure-call.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0618]: expected function, found `()` | ||
--> $DIR/suggest-on-bare-closure-call.rs:2:15 | ||
| | ||
LL | let _ = ||{}(); | ||
| ^^-- | ||
| | | ||
| call expression requires function | ||
help: if you meant to create this closure and immediately call it, surround the closure with parenthesis | ||
| | ||
LL | let _ = (||{})(); | ||
| ^ ^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0618`. |