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#131843 - workingjubilee:thaw-impossible-reprs, r=lukas-code compiler: Error on layout of enums with invalid reprs Surprising no one, the ICEs with the same message have the same root cause. Invalid reprs can reach layout computation for various reasons. For instance, the compiler may want to use its layout computations to discern if a combination of layout-affecting attributes results in a valid type to begin with by e.g. computing its size. When the input is bad, return an error reflecting that the answer to the question is not a useful one.
- Loading branch information
Showing
8 changed files
with
125 additions
and
8 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
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`. |