forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
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#132489 - compiler-errors:fn-sugg-tweaks, r=BoxyUwU Fix closure arg extraction in `extract_callable_info`, generalize it to async closures * Fix argument extraction in `extract_callable_info` * FIx `extract_callable_info` to work for async closures * Remove redundant `is_fn_ty` which is just a less general `extract_callable_info` * More precisely name what is being called (i.e. call it a "closure" not a "function") Review this without whitespace -- I ended up reformatting `extract_callable_info` because some pesky `//` comments were keeping the let-chains from being formatted.
- Loading branch information
Showing
9 changed files
with
148 additions
and
139 deletions.
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
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,7 @@ | ||
// Ensure we give the right args when we suggest calling a closure. | ||
|
||
fn main() { | ||
let x = |a: i32, b: i32| a + b; | ||
let y: i32 = x; | ||
//~^ ERROR mismatched types | ||
} |
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,20 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/correct-args-on-call-suggestion.rs:5:18 | ||
| | ||
LL | let x = |a: i32, b: i32| a + b; | ||
| ---------------- the found closure | ||
LL | let y: i32 = x; | ||
| --- ^ expected `i32`, found closure | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected type `i32` | ||
found closure `{closure@$DIR/correct-args-on-call-suggestion.rs:4:13: 4:29}` | ||
help: use parentheses to call this closure | ||
| | ||
LL | let y: i32 = x(/* i32 */, /* i32 */); | ||
| ++++++++++++++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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
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
Oops, something went wrong.