-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30b6c59
commit 95a3215
Showing
8 changed files
with
77 additions
and
29 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
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,29 @@ | ||
// Test that we mark enum discriminant values as having errors, even when the | ||
// diagnostic is deduplicated. | ||
|
||
struct F; | ||
struct T; | ||
|
||
impl F { | ||
const V: i32 = 0; | ||
} | ||
|
||
impl T { | ||
const V: i32 = 0; | ||
} | ||
|
||
macro_rules! mac { | ||
($( $v: ident = $s: ident,)*) => { | ||
enum E { | ||
$( $v = $s::V, )* | ||
//~^ ERROR mismatched types | ||
} | ||
} | ||
} | ||
|
||
mac! { | ||
A = F, | ||
B = T, | ||
} | ||
|
||
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,19 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/enum-discr-type-err.rs:18:21 | ||
| | ||
LL | $( $v = $s::V, )* | ||
| ^^^^^ expected isize, found i32 | ||
... | ||
LL | / mac! { | ||
LL | | A = F, | ||
LL | | B = T, | ||
LL | | } | ||
| |_- in this macro invocation | ||
help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit | ||
| | ||
LL | $( $v = $s::V.try_into().unwrap(), )* | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |