Skip to content

Commit 2903604

Browse files
author
Lukas Markeffsky
committed
add test for coercing never to infinite type
1 parent cb2fc09 commit 2903604

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// build-fail
2+
//~^ ERROR cycle detected when computing layout of `Foo<()>`
3+
4+
// Regression test for a stack overflow: https://github.com/rust-lang/rust/issues/113197
5+
6+
trait A { type Assoc; }
7+
8+
impl A for () {
9+
type Assoc = Foo<()>;
10+
}
11+
12+
struct Foo<T: A>(T::Assoc);
13+
14+
fn main() {
15+
Foo::<()>(todo!());
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0391]: cycle detected when computing layout of `Foo<()>`
2+
|
3+
= note: ...which requires computing layout of `<() as A>::Assoc`...
4+
= note: ...which again requires computing layout of `Foo<()>`, completing the cycle
5+
note: cycle used when elaborating drops for `main`
6+
--> $DIR/recursive-type-coercion-from-never.rs:14:1
7+
|
8+
LL | fn main() {
9+
| ^^^^^^^^^
10+
= 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
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0391`.

0 commit comments

Comments
 (0)