-
Notifications
You must be signed in to change notification settings - Fork 14k
rustc_typeck: improve diagnostics for -> _ fn return type #62694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,10 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa | |
| --> $DIR/E0121.rs:1:13 | ||
| | | ||
| LL | fn foo() -> _ { 5 } | ||
| | ^ not allowed in type signatures | ||
| | ^ | ||
| | | | ||
| | not allowed in type signatures | ||
| | help: replace `_` with the correct return type: `i32` | ||
|
|
||
| error[E0121]: the type placeholder `_` is not allowed within types on item signatures | ||
|
||
| --> $DIR/E0121.rs:3:13 | ||
|
|
||
| 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(); | ||
| } |
| 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`. |
Uh oh!
There was an error while loading. Please reload this page.