Skip to content

Commit eefffcf

Browse files
committed
Fix an ICE that occurs after an error has already been reported
1 parent be00c5a commit eefffcf

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

Diff for: compiler/rustc_transmute/src/layout/tree.rs

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ pub(crate) mod rustc {
199199
match err {
200200
LayoutError::Unknown(..) | LayoutError::ReferencesError(..) => Self::UnknownLayout,
201201
LayoutError::SizeOverflow(..) => Self::SizeOverflow,
202+
LayoutError::Cycle(err) => Self::TypeError(*err),
202203
err => unimplemented!("{:?}", err),
203204
}
204205
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//~ ERROR: cycle detected
2+
#![crate_type = "lib"]
3+
#![feature(transmutability)]
4+
#![allow(dead_code, incomplete_features, non_camel_case_types)]
5+
6+
mod assert {
7+
use std::mem::{Assume, BikeshedIntrinsicFrom};
8+
pub struct Context;
9+
10+
pub fn is_maybe_transmutable<Src, Dst>()
11+
where
12+
Dst: BikeshedIntrinsicFrom<Src, Context>,
13+
{
14+
}
15+
}
16+
17+
fn should_pad_explicitly_packed_field() {
18+
#[repr(C)]
19+
struct ExplicitlyPadded(ExplicitlyPadded);
20+
//~^ ERROR: recursive type
21+
22+
assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0072]: recursive type `ExplicitlyPadded` has infinite size
2+
--> $DIR/unhandled_error_ice_117491.rs:19:5
3+
|
4+
LL | struct ExplicitlyPadded(ExplicitlyPadded);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ ---------------- recursive without indirection
6+
|
7+
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
8+
|
9+
LL | struct ExplicitlyPadded(Box<ExplicitlyPadded>);
10+
| ++++ +
11+
12+
error[E0391]: cycle detected when computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded`
13+
|
14+
= note: ...which immediately requires computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded` again
15+
= 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 }>`
16+
= 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
17+
18+
error: aborting due to 2 previous errors
19+
20+
Some errors have detailed explanations: E0072, E0391.
21+
For more information about an error, try `rustc --explain E0072`.

0 commit comments

Comments
 (0)