diff --git a/tests/ui/layout/uninitialized-gat-projection-cycle-issue-153205.rs b/tests/ui/layout/uninitialized-gat-projection-cycle-issue-153205.rs new file mode 100644 index 0000000000000..d37764238e6b4 --- /dev/null +++ b/tests/ui/layout/uninitialized-gat-projection-cycle-issue-153205.rs @@ -0,0 +1,27 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/153205. +//! An uninitialized recursive GAT projection used to hang during optimized MIR processing +//! instead of reporting the layout cycle. + +//@ build-fail +//@ compile-flags: -O + +trait Apply { + type Output; +} + +struct Identity; + +impl Apply for Identity { + type Output = T; +} + +struct Thing(A::Output); +//~^ ERROR cycle detected when computing layout of `Thing` + +fn foo() { + let _x: Thing; +} + +fn main() { + foo::(); +} diff --git a/tests/ui/layout/uninitialized-gat-projection-cycle-issue-153205.stderr b/tests/ui/layout/uninitialized-gat-projection-cycle-issue-153205.stderr new file mode 100644 index 0000000000000..b3246edfa751e --- /dev/null +++ b/tests/ui/layout/uninitialized-gat-projection-cycle-issue-153205.stderr @@ -0,0 +1,22 @@ +error[E0391]: cycle detected when computing layout of `Thing` + --> $DIR/uninitialized-gat-projection-cycle-issue-153205.rs:18:1 + | +LL | struct Thing(A::Output); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires computing layout of `::Output>`... + --> $DIR/uninitialized-gat-projection-cycle-issue-153205.rs:9:5 + | +LL | type Output; + | ^^^^^^^^^^^^^^ + = note: ...which again requires computing layout of `Thing`, completing the cycle +note: cycle used when optimizing MIR for `main` + --> $DIR/uninitialized-gat-projection-cycle-issue-153205.rs:25:1 + | +LL | fn main() { + | ^^^^^^^^^ + = note: for more information, see and + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`.