forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#112810 - compiler-errors:dont-ice-on-bad-la…
…yout, r=wesleywiser Don't ICE on unnormalized struct tail in layout computation 1. We try to compute a `SizeSkeleton` even if a layout error occurs, but we really only need to do this if we get `LayoutError::Unknown`, since that means our type is too polymorphic to actually compute the full layout. If we have other errors, like `LayoutError::NormalizationError` or `LayoutError::Cycle`, then we can't really make any progress, since this represents an actual error. 2. Avoid using `normalize_erasing_regions` and `struct_tail_erasing_lifetimes` since those ICE on normalization errors, and since we may call `layout_of` in HIR typeck, we don't know for certain that we're on the happy path. Fixes rust-lang#112736
- Loading branch information
Showing
6 changed files
with
80 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
trait Trait { | ||
type RefTarget; | ||
} | ||
|
||
impl Trait for () | ||
where | ||
Missing: Trait, | ||
//~^ ERROR cannot find type `Missing` in this scope | ||
{ | ||
type RefTarget = (); | ||
} | ||
|
||
struct Other { | ||
data: <() as Trait>::RefTarget, | ||
} | ||
|
||
fn main() { | ||
unsafe { | ||
std::mem::transmute::<Option<()>, Option<&Other>>(None); | ||
//~^ ERROR cannot transmute between types of different sizes, or dependently-sized types | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/ui/layout/cannot-transmute-unnormalizable-type.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,19 @@ | ||
error[E0412]: cannot find type `Missing` in this scope | ||
--> $DIR/cannot-transmute-unnormalizable-type.rs:7:5 | ||
| | ||
LL | Missing: Trait, | ||
| ^^^^^^^ not found in this scope | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/cannot-transmute-unnormalizable-type.rs:19:9 | ||
| | ||
LL | std::mem::transmute::<Option<()>, Option<&Other>>(None); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `Option<()>` (8 bits) | ||
= note: target type: `Option<&Other>` (unable to determine layout for `Other` because `<() as Trait>::RefTarget` cannot be normalized) | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0412, E0512. | ||
For more information about an error, try `rustc --explain E0412`. |