-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing type alias cycle detection
- Loading branch information
1 parent
9e7f02b
commit c383c9d
Showing
9 changed files
with
74 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
type X1 = X2; | ||
//~^ ERROR cycle detected when expanding type alias `X1` | ||
//~^ ERROR cycle detected when expanding type alias | ||
type X2 = X3; | ||
//~^ ERROR cycle detected when expanding type alias | ||
type X3 = X1; | ||
//~^ ERROR cycle detected when expanding type alias | ||
|
||
fn main() {} |
42 changes: 14 additions & 28 deletions
42
src/test/ui/infinite/infinite-type-alias-mutual-recursion.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,20 @@ | ||
error[E0391]: cycle detected when expanding type alias `X1` | ||
--> $DIR/infinite-type-alias-mutual-recursion.rs:1:11 | ||
| | ||
LL | type X1 = X2; | ||
| ^^ | ||
| | ||
note: ...which requires expanding type alias `X2`... | ||
--> $DIR/infinite-type-alias-mutual-recursion.rs:3:11 | ||
| | ||
LL | type X2 = X3; | ||
| ^^ | ||
note: ...which requires expanding type alias `X3`... | ||
--> $DIR/infinite-type-alias-mutual-recursion.rs:4:11 | ||
error: cycle detected when expanding type alias | ||
--> $DIR/infinite-type-alias-mutual-recursion.rs:5:1 | ||
| | ||
LL | type X3 = X1; | ||
| ^^ | ||
= note: ...which again requires expanding type alias `X1`, completing the cycle | ||
= note: type aliases cannot be recursive | ||
= help: consider using a struct, enum, or union instead to break the cycle | ||
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information | ||
note: cycle used when collecting item types in top-level module | ||
| ^^^^^^^ | ||
|
||
error: cycle detected when expanding type alias | ||
--> $DIR/infinite-type-alias-mutual-recursion.rs:1:1 | ||
| | ||
LL | / type X1 = X2; | ||
LL | | | ||
LL | | type X2 = X3; | ||
LL | | type X3 = X1; | ||
LL | | | ||
LL | | fn main() {} | ||
| |____________^ | ||
LL | type X1 = X2; | ||
| ^^^^^^^ | ||
|
||
error: cycle detected when expanding type alias | ||
--> $DIR/infinite-type-alias-mutual-recursion.rs:3:1 | ||
| | ||
LL | type X2 = X3; | ||
| ^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0391`. |