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#80613 - bugadani:issue-80607, r=matthewjasper
Diag: print enum variant instead of enum type Closes rust-lang#80607
- Loading branch information
Showing
3 changed files
with
60 additions
and
13 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,10 @@ | ||
// This tests makes sure the diagnostics print the offending enum variant, not just the type. | ||
pub enum Enum { | ||
V1(i32), | ||
} | ||
|
||
pub fn foo(x: i32) -> Enum { | ||
Enum::V1 { x } //~ ERROR `Enum::V1` has no field named `x` | ||
} | ||
|
||
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,14 @@ | ||
error[E0559]: variant `Enum::V1` has no field named `x` | ||
--> $DIR/issue-80607.rs:7:16 | ||
| | ||
LL | V1(i32), | ||
| -- `Enum::V1` defined here | ||
... | ||
LL | Enum::V1 { x } | ||
| -------- ^ field does not exist | ||
| | | ||
| `Enum::V1` is a tuple variant, use the appropriate syntax: `Enum::V1(/* fields */)` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0559`. |