Rollup merge of #119323 - lukas-code:test-never-to-infinite, r=compiler-errors

add test for coercing never to infinite type

Closes https://github.com/rust-lang/rust/issues/113197.

This was fixed in https://github.com/rust-lang/rust/pull/118308, probably 1978168c13.
This commit is contained in:
Michael Goulet 2023-12-26 13:29:14 -05:00 committed by GitHub
commit a5b3d139b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 1 deletions

View File

@ -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() {
| ^^^^^^^^^

View File

@ -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!());
}

View File

@ -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`.