-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc_typeck: improve diagnostics for -> _ fn return type
Closes: #56132
- Loading branch information
1 parent
d9ad04a
commit f8681f0
Showing
6 changed files
with
113 additions
and
30 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
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 @@ | ||
// This test checks that it proper item type will be suggested when | ||
// using the `_` type placeholder. | ||
|
||
fn test1() -> _ { Some(42) } | ||
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures | ||
|
||
pub fn main() { | ||
let _: Option<usize> = test1(); | ||
let _: f64 = test1(); | ||
let _: Option<i32> = test1(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/typeck/typeck_type_placeholder_item_help.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,12 @@ | ||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures | ||
--> $DIR/typeck_type_placeholder_item_help.rs:4:15 | ||
| | ||
LL | fn test1() -> _ { Some(42) } | ||
| ^ | ||
| | | ||
| not allowed in type signatures | ||
| help: replace `_` with the correct return type: `std::option::Option<i32>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0121`. |