add test for coercing never to infinite type
This commit is contained in:
parent
cb2fc0967f
commit
29036045c3
16
tests/ui/sized/recursive-type-coercion-from-never.rs
Normal file
16
tests/ui/sized/recursive-type-coercion-from-never.rs
Normal 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!());
|
||||||
|
}
|
14
tests/ui/sized/recursive-type-coercion-from-never.stderr
Normal file
14
tests/ui/sized/recursive-type-coercion-from-never.stderr
Normal 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`.
|
Loading…
x
Reference in New Issue
Block a user