Skip to content

Commit 8ec6c84

Browse files
lcnrcompiler-errors
authored andcommitted
add some more tests
1 parent 0f2e45b commit 8ec6c84

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/test/ui/sized/recursive-type-1.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
trait A { type Assoc; }
3+
4+
impl A for () {
5+
// FIXME: it would be nice for this to at least cause a warning.
6+
type Assoc = Foo<()>;
7+
}
8+
struct Foo<T: A>(T::Assoc);
9+
10+
fn main() {}

src/test/ui/sized/recursive-type-2.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// build-fail
2+
//~^ ERROR cycle detected when computing layout of `Foo<()>`
3+
4+
trait A { type Assoc: ?Sized; }
5+
6+
impl A for () {
7+
type Assoc = Foo<()>;
8+
}
9+
struct Foo<T: A>(T::Assoc);
10+
11+
fn main() {
12+
let x: Foo<()>;
13+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0391]: cycle detected when computing layout of `Foo<()>`
2+
|
3+
= note: ...which again requires computing layout of `Foo<()>`, completing the cycle
4+
note: cycle used when optimizing MIR for `main`
5+
--> $DIR/recursive-type-2.rs:11:1
6+
|
7+
LL | fn main() {
8+
| ^^^^^^^^^
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0391`.

0 commit comments

Comments
 (0)