add some more tests
This commit is contained in:
parent
0f2e45b18f
commit
8ec6c84bb3
10
src/test/ui/sized/recursive-type-1.rs
Normal file
10
src/test/ui/sized/recursive-type-1.rs
Normal 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() {}
|
13
src/test/ui/sized/recursive-type-2.rs
Normal file
13
src/test/ui/sized/recursive-type-2.rs
Normal 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<()>;
|
||||
}
|
12
src/test/ui/sized/recursive-type-2.stderr
Normal file
12
src/test/ui/sized/recursive-type-2.stderr
Normal 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`.
|
Loading…
x
Reference in New Issue
Block a user