forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Identify missing ambiguous case with best effort suggestion
- Loading branch information
Showing
4 changed files
with
132 additions
and
51 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,14 @@ | ||
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] | ||
enum E { | ||
V { field: bool } | ||
} | ||
fn test_E(x: E) { | ||
let field = true; | ||
if x == E::V { field } {} | ||
//~^ ERROR expected value, found struct variant `E::V` | ||
//~| ERROR mismatched types | ||
let y: usize = (); | ||
//~^ ERROR mismatched types | ||
} | ||
|
||
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,33 @@ | ||
error[E0423]: expected value, found struct variant `E::V` | ||
--> $DIR/struct-literal-variant-in-if.rs:7:13 | ||
| | ||
LL | if x == E::V { field } {} | ||
| ^^^^---------- | ||
| | | ||
| help: surround the struct literal with parenthesis: `(E::V { field })` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/struct-literal-variant-in-if.rs:7:20 | ||
| | ||
LL | fn test_E(x: E) { | ||
| - help: try adding a return type: `-> bool` | ||
LL | let field = true; | ||
LL | if x == E::V { field } {} | ||
| ^^^^^ expected (), found bool | ||
| | ||
= note: expected type `()` | ||
found type `bool` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/struct-literal-variant-in-if.rs:10:20 | ||
| | ||
LL | let y: usize = (); | ||
| ^^ expected usize, found () | ||
| | ||
= note: expected type `usize` | ||
found type `()` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors occurred: E0308, E0423. | ||
For more information about an error, try `rustc --explain E0308`. |