-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #91450 - hkmatsumoto:hide-type-error, r=estebank
Don't suggest types whose inner type is erroneous Currently, we check if the returned type equals to `tcx.ty_error()` not to emit erroneous types, but this has a pitfall; for example, `Option<[type error]> != tcx.ty_error()` holds. Fixes #91371.
- Loading branch information
Showing
3 changed files
with
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Regression test for #91450. | ||
// This test ensures that the compiler does not suggest `Foo<[type error]>` in diagnostic messages. | ||
|
||
fn foo() -> Option<_> {} //~ ERROR: [E0308] | ||
//~^ ERROR: the type placeholder `_` is not allowed | ||
|
||
fn main() {} |
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,21 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-91450-inner-ty-error.rs:4:13 | ||
| | ||
LL | fn foo() -> Option<_> {} | ||
| --- ^^^^^^^^^ expected enum `Option`, found `()` | ||
| | | ||
| implicitly returns `()` as its body has no tail or `return` expression | ||
| | ||
= note: expected enum `Option<_>` | ||
found unit type `()` | ||
|
||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types | ||
--> $DIR/issue-91450-inner-ty-error.rs:4:20 | ||
| | ||
LL | fn foo() -> Option<_> {} | ||
| ^ not allowed in type signatures | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0121, E0308. | ||
For more information about an error, try `rustc --explain E0121`. |