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#123379 - wutchzone:119266, r=compiler-errors
Print note with closure signature on type mismatch Fixes rust-lang#119266 r? Nilstrieb
- Loading branch information
Showing
4 changed files
with
48 additions
and
2 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,11 @@ | ||
fn main() { | ||
let x = |a: u8, b: (usize, u32), c: fn() -> char| -> String { "I love beans.".to_string() }; | ||
//~^ NOTE: the found closure | ||
|
||
let x: fn(i32) = x; | ||
//~^ ERROR: 5:22: 5:23: mismatched types [E0308] | ||
//~| NOTE: incorrect number of function parameters | ||
//~| NOTE: expected due to this | ||
//~| NOTE: expected fn pointer `fn(i32)` | ||
//~| NOTE: closure has signature: `fn(u8, (usize, u32), fn() -> char) -> String` | ||
} |
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,18 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/hint-closure-signature-119266.rs:5:22 | ||
| | ||
LL | let x = |a: u8, b: (usize, u32), c: fn() -> char| -> String { "I love beans.".to_string() }; | ||
| --------------------------------------------------- the found closure | ||
... | ||
LL | let x: fn(i32) = x; | ||
| ------- ^ incorrect number of function parameters | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected fn pointer `fn(i32)` | ||
found closure `{closure@$DIR/hint-closure-signature-119266.rs:2:13: 2:64}` | ||
= note: closure has signature: `fn(u8, (usize, u32), fn() -> char) -> String` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |