Skip to content

Commit 61dd7f0

Browse files
authored
Unrolled build for rust-lang#119772
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`
2 parents 9273d63 + 4f0869e commit 61dd7f0

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

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,26 @@
1+
//~ ERROR: cycle detected
2+
//! Safe transmute did not handle cycle errors that could occur during
3+
//! layout computation. This test checks that we do not ICE in such
4+
//! situations (see #117491).
5+
#![crate_type = "lib"]
6+
#![feature(transmutability)]
7+
#![allow(dead_code, incomplete_features, non_camel_case_types)]
8+
9+
mod assert {
10+
use std::mem::{Assume, BikeshedIntrinsicFrom};
11+
pub struct Context;
12+
13+
pub fn is_maybe_transmutable<Src, Dst>()
14+
where
15+
Dst: BikeshedIntrinsicFrom<Src, Context>,
16+
{
17+
}
18+
}
19+
20+
fn should_pad_explicitly_packed_field() {
21+
#[repr(C)]
22+
struct ExplicitlyPadded(ExplicitlyPadded);
23+
//~^ ERROR: recursive type
24+
25+
assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0072]: recursive type `ExplicitlyPadded` has infinite size
2+
--> $DIR/transmute_infinitely_recursive_type.rs:22: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)