forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#119772 - oli-obk:whackamole, r=compiler-errors
Fix an ICE that occurs after an error has already been reported fixes rust-lang#117491 cc `@jswrenn`
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 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
26 changes: 26 additions & 0 deletions
26
tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_type.rs
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,26 @@ | ||
//~ ERROR: cycle detected | ||
//! Safe transmute did not handle cycle errors that could occur during | ||
//! layout computation. This test checks that we do not ICE in such | ||
//! situations (see #117491). | ||
#![crate_type = "lib"] | ||
#![feature(transmutability)] | ||
#![allow(dead_code, incomplete_features, non_camel_case_types)] | ||
|
||
mod assert { | ||
use std::mem::{Assume, BikeshedIntrinsicFrom}; | ||
pub struct Context; | ||
|
||
pub fn is_maybe_transmutable<Src, Dst>() | ||
where | ||
Dst: BikeshedIntrinsicFrom<Src, Context>, | ||
{ | ||
} | ||
} | ||
|
||
fn should_pad_explicitly_packed_field() { | ||
#[repr(C)] | ||
struct ExplicitlyPadded(ExplicitlyPadded); | ||
//~^ ERROR: recursive type | ||
|
||
assert::is_maybe_transmutable::<ExplicitlyPadded, ()>(); | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/ui/transmutability/structs/repr/transmute_infinitely_recursive_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,21 @@ | ||
error[E0072]: recursive type `ExplicitlyPadded` has infinite size | ||
--> $DIR/transmute_infinitely_recursive_type.rs:22:5 | ||
| | ||
LL | struct ExplicitlyPadded(ExplicitlyPadded); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ ---------------- recursive without indirection | ||
| | ||
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle | ||
| | ||
LL | struct ExplicitlyPadded(Box<ExplicitlyPadded>); | ||
| ++++ + | ||
|
||
error[E0391]: cycle detected when computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded` | ||
| | ||
= note: ...which immediately requires computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded` again | ||
= note: cycle used when evaluating trait selection obligation `(): core::mem::transmutability::BikeshedIntrinsicFrom<should_pad_explicitly_packed_field::ExplicitlyPadded, assert::Context, core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` | ||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0072, E0391. | ||
For more information about an error, try `rustc --explain E0072`. |