add some more tests

This commit is contained in:
lcnr 2021-04-27 14:24:19 +02:00 committed by Michael Goulet
parent 0f2e45b18f
commit 8ec6c84bb3
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,10 @@
// check-pass
trait A { type Assoc; }
impl A for () {
// FIXME: it would be nice for this to at least cause a warning.
type Assoc = Foo<()>;
}
struct Foo<T: A>(T::Assoc);
fn main() {}

View File

@ -0,0 +1,13 @@
// build-fail
//~^ ERROR cycle detected when computing layout of `Foo<()>`
trait A { type Assoc: ?Sized; }
impl A for () {
type Assoc = Foo<()>;
}
struct Foo<T: A>(T::Assoc);
fn main() {
let x: Foo<()>;
}

View File

@ -0,0 +1,12 @@
error[E0391]: cycle detected when computing layout of `Foo<()>`
|
= note: ...which again requires computing layout of `Foo<()>`, completing the cycle
note: cycle used when optimizing MIR for `main`
--> $DIR/recursive-type-2.rs:11:1
|
LL | fn main() {
| ^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0391`.