-
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.
compiler: Reject impossible reprs during enum layout
- Loading branch information
1 parent
68d1fd9
commit 9f4c915
Showing
6 changed files
with
121 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
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,68 @@ | ||
error[E0412]: cannot find type `Subset` in this scope | ||
--> $DIR/thaw-transmute-invalid-enum.rs:34:41 | ||
| | ||
LL | assert::is_transmutable::<Superset, Subset>(); | ||
| ^^^^^^ not found in this scope | ||
| | ||
help: you might be missing a type parameter | ||
| | ||
LL | fn test<Subset>() { | ||
| ++++++++ | ||
|
||
error[E0517]: attribute should be applied to a struct or union | ||
--> $DIR/thaw-transmute-invalid-enum.rs:21:11 | ||
| | ||
LL | #[repr(C, packed(2))] | ||
| ^^^^^^^^^ | ||
LL | | ||
LL | / enum OxFF { | ||
LL | | V = 0xFF, | ||
LL | | } | ||
| |_- not a struct or union | ||
|
||
error[E0658]: use of unstable library feature 'transmutability' | ||
--> $DIR/thaw-transmute-invalid-enum.rs:4:20 | ||
| | ||
LL | use std::mem::{Assume, TransmuteFrom}; | ||
| ^^^^^^ | ||
| | ||
= note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information | ||
= help: add `#![feature(transmutability)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: use of unstable library feature 'transmutability' | ||
--> $DIR/thaw-transmute-invalid-enum.rs:4:28 | ||
| | ||
LL | use std::mem::{Assume, TransmuteFrom}; | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information | ||
= help: add `#![feature(transmutability)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: use of unstable library feature 'transmutability' | ||
--> $DIR/thaw-transmute-invalid-enum.rs:10:14 | ||
| | ||
LL | Dst: TransmuteFrom<Src>, | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information | ||
= help: add `#![feature(transmutability)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union | ||
--> $DIR/thaw-transmute-invalid-enum.rs:29:9 | ||
| | ||
LL | a: Ox00, | ||
| ^^^^^^^ | ||
| | ||
= note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` | ||
help: wrap the field type in `ManuallyDrop<...>` | ||
| | ||
LL | a: std::mem::ManuallyDrop<Ox00>, | ||
| +++++++++++++++++++++++ + | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
Some errors have detailed explanations: E0412, E0517, E0658, E0740. | ||
For more information about an error, try `rustc --explain E0412`. |
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 @@ | ||
error[E0517]: attribute should be applied to a struct or union | ||
--> $DIR/thaw-validate-invalid-enum.rs:3:8 | ||
| | ||
LL | #[repr(packed)] | ||
| ^^^^^^ | ||
LL | #[repr(u32)] | ||
LL | / enum E { | ||
LL | | A, | ||
LL | | B, | ||
LL | | C, | ||
LL | | } | ||
| |_- not a struct or union | ||
|
||
error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union | ||
--> $DIR/thaw-validate-invalid-enum.rs:14:9 | ||
| | ||
LL | e: E, | ||
| ^^^^ | ||
| | ||
= note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` | ||
help: wrap the field type in `ManuallyDrop<...>` | ||
| | ||
LL | e: std::mem::ManuallyDrop<E>, | ||
| +++++++++++++++++++++++ + | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0517, E0740. | ||
For more information about an error, try `rustc --explain E0517`. |