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#106201 - estebank:verbose-transparent, r=co…
…mpiler-errors Emit fewer errors on invalid `#[repr(transparent)]` on `enum` Fix rust-lang#68420.
- Loading branch information
Showing
3 changed files
with
23 additions
and
4 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 @@ | ||
use std::mem::size_of; | ||
|
||
#[repr(transparent)] | ||
enum Foo { //~ ERROR E0731 | ||
A(u8), B(u8), | ||
} | ||
|
||
fn main() { | ||
println!("Foo: {}", size_of::<Foo>()); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/repr/transparent-enum-too-many-variants.stderr
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,11 @@ | ||
error[E0731]: transparent enum needs exactly one variant, but has 2 | ||
--> $DIR/transparent-enum-too-many-variants.rs:4:1 | ||
| | ||
LL | enum Foo { | ||
| ^^^^^^^^ needs exactly one variant, but has 2 | ||
LL | A(u8), B(u8), | ||
| - - too many variants in `Foo` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0731`. |