Skip to content

add test for coercing never to infinite type #119323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 26, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ error[E0391]: cycle detected when computing layout of `Foo<()>`
= note: ...which requires computing layout of `<() as A>::Assoc`...
= note: ...which again requires computing layout of `Foo<()>`, completing the cycle
note: cycle used when elaborating drops for `main`
--> $DIR/recursive-type-2.rs:11:1
--> $DIR/recursive-type-binding.rs:11:1
|
LL | fn main() {
| ^^^^^^^^^
Expand Down
16 changes: 16 additions & 0 deletions tests/ui/sized/recursive-type-coercion-from-never.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// build-fail
//~^ ERROR cycle detected when computing layout of `Foo<()>`

// Regression test for a stack overflow: https://github.com/rust-lang/rust/issues/113197

trait A { type Assoc; }

impl A for () {
type Assoc = Foo<()>;
}

struct Foo<T: A>(T::Assoc);

fn main() {
Foo::<()>(todo!());
}
14 changes: 14 additions & 0 deletions tests/ui/sized/recursive-type-coercion-from-never.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0391]: cycle detected when computing layout of `Foo<()>`
|
= note: ...which requires computing layout of `<() as A>::Assoc`...
= note: ...which again requires computing layout of `Foo<()>`, completing the cycle
note: cycle used when elaborating drops for `main`
--> $DIR/recursive-type-coercion-from-never.rs:14:1
|
LL | fn main() {
| ^^^^^^^^^
= 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

error: aborting due to 1 previous error

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