Skip to content

Commit 146d807

Browse files
committed
Auto merge of #111153 - Dylan-DPC:rollup-0pq0hh3, r=Dylan-DPC
Rollup of 11 pull requests Successful merges: - #107978 (Correctly convert an NT path to a Win32 path in `read_link`) - #110436 (Support loading version information from xz tarballs) - #110791 (Implement negative bounds for internal testing purposes) - #110874 (Adjust obligation cause code for `find_and_report_unsatisfied_index_impl`) - #110908 (resolve: One more attempt to simplify `module_children`) - #110943 (interpret: fail more gracefully on uninit unsized locals) - #111062 (Don't bail out early when checking invalid `repr` attr) - #111069 (remove pointless `FIXME` in `bootstrap::download`) - #111086 (Remove `MemEncoder`) - #111097 (Avoid ICEing miri on layout query cycles) - #111112 (Add some triagebot notifications for nnethercote.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents bd09236 + c63fac9 commit 146d807

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

tests/fail/layout_cycle.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//@error-pattern: a cycle occurred during layout computation
2+
//~^ ERROR: cycle detected when computing layout of
3+
4+
use std::mem;
5+
6+
pub struct S<T: Tr> {
7+
pub f: <T as Tr>::I,
8+
}
9+
10+
pub trait Tr {
11+
type I: Tr;
12+
}
13+
14+
impl<T: Tr> Tr for S<T> {
15+
type I = S<S<T>>;
16+
}
17+
18+
impl Tr for () {
19+
type I = ();
20+
}
21+
22+
fn foo<T: Tr>() -> usize {
23+
mem::size_of::<S<T>>()
24+
}
25+
26+
fn main() {
27+
println!("{}", foo::<S<()>>());
28+
}

tests/fail/layout_cycle.stderr

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0391]: cycle detected when computing layout of `S<S<()>>`
2+
|
3+
= note: ...which requires computing layout of `<S<()> as Tr>::I`...
4+
= note: ...which again requires computing layout of `S<S<()>>`, completing the cycle
5+
6+
error: post-monomorphization error: a cycle occurred during layout computation
7+
--> RUSTLIB/core/src/mem/mod.rs:LL:CC
8+
|
9+
LL | intrinsics::size_of::<T>()
10+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ a cycle occurred during layout computation
11+
|
12+
= note: inside `std::mem::size_of::<S<S<()>>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
13+
note: inside `foo::<S<()>>`
14+
--> $DIR/layout_cycle.rs:LL:CC
15+
|
16+
LL | mem::size_of::<S<T>>()
17+
| ^^^^^^^^^^^^^^^^^^^^^^
18+
note: inside `main`
19+
--> $DIR/layout_cycle.rs:LL:CC
20+
|
21+
LL | println!("{}", foo::<S<()>>());
22+
| ^^^^^^^^^^^^^^
23+
24+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
25+
26+
error: aborting due to 2 previous errors
27+
28+
For more information about this error, try `rustc --explain E0391`.

0 commit comments

Comments
 (0)