File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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`.
You can’t perform that action at this time.
0 commit comments