Skip to content

Commit c3df832

Browse files
committed
Add test for type alias mutual recursion
1 parent c861964 commit c3df832

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type X1 = X2;
2+
//~^ ERROR cycle detected when expanding type alias `X1`
3+
type X2 = X3;
4+
type X3 = X1;
5+
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0391]: cycle detected when expanding type alias `X1`
2+
--> $DIR/infinite-type-alias-mutual-recursion.rs:1:11
3+
|
4+
LL | type X1 = X2;
5+
| ^^
6+
|
7+
note: ...which requires expanding type alias `X2`...
8+
--> $DIR/infinite-type-alias-mutual-recursion.rs:3:11
9+
|
10+
LL | type X2 = X3;
11+
| ^^
12+
note: ...which requires expanding type alias `X3`...
13+
--> $DIR/infinite-type-alias-mutual-recursion.rs:4:11
14+
|
15+
LL | type X3 = X1;
16+
| ^^
17+
= note: ...which again requires expanding type alias `X1`, completing the cycle
18+
= note: type aliases cannot be recursive
19+
= help: consider using a struct, enum, or union instead to break the cycle
20+
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
21+
note: cycle used when collecting item types in top-level module
22+
--> $DIR/infinite-type-alias-mutual-recursion.rs:1:1
23+
|
24+
LL | / type X1 = X2;
25+
LL | |
26+
LL | | type X2 = X3;
27+
LL | | type X3 = X1;
28+
LL | |
29+
LL | | fn main() {}
30+
| |____________^
31+
32+
error: aborting due to previous error
33+
34+
For more information about this error, try `rustc --explain E0391`.

0 commit comments

Comments
 (0)