Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/ui/layout/uninitialized-gat-projection-cycle-issue-153205.rs
Original file line number Diff line number Diff line change
@@ -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<T>;
}

struct Identity;

impl Apply for Identity {
type Output<T> = T;
}

struct Thing<A: Apply>(A::Output<Self>);
//~^ ERROR cycle detected when computing layout of `Thing<Identity>`

fn foo<A: Apply>() {
let _x: Thing<A>;
}

fn main() {
foo::<Identity>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0391]: cycle detected when computing layout of `Thing<Identity>`
--> $DIR/uninitialized-gat-projection-cycle-issue-153205.rs:18:1
|
LL | struct Thing<A: Apply>(A::Output<Self>);
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires computing layout of `<Identity as Apply>::Output<Thing<Identity>>`...
--> $DIR/uninitialized-gat-projection-cycle-issue-153205.rs:9:5
|
LL | type Output<T>;
| ^^^^^^^^^^^^^^
= note: ...which again requires computing layout of `Thing<Identity>`, 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 <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
Loading