-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #113201 - oli-obk:recursive_type_alias, r=estebank,comp…
…iler-errors Permit recursive weak type aliases I saw #63097 and thought "we can do ~~better~~ funnier". So here it is. It's not useful, but it's certainly something. This may actually become feasible with lazy norm (so in 5 years (constant, not reducing over time)). r? `@estebank` cc `@GuillaumeGomez`
- Loading branch information
Showing
9 changed files
with
103 additions
and
21 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
27 changes: 27 additions & 0 deletions
27
tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error[E0275]: overflow evaluating the requirement `X2` | ||
--> $DIR/infinite-type-alias-mutual-recursion.rs:6:11 | ||
| | ||
LL | type X1 = X2; | ||
| ^^ | ||
| | ||
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead | ||
|
||
error[E0275]: overflow evaluating the requirement `X3` | ||
--> $DIR/infinite-type-alias-mutual-recursion.rs:9:11 | ||
| | ||
LL | type X2 = X3; | ||
| ^^ | ||
| | ||
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead | ||
|
||
error[E0275]: overflow evaluating the requirement `X1` | ||
--> $DIR/infinite-type-alias-mutual-recursion.rs:11:11 | ||
| | ||
LL | type X3 = X1; | ||
| ^^ | ||
| | ||
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0275`. |
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,14 @@ | ||
// revisions: feature gated | ||
|
||
#![cfg_attr(feature, feature(lazy_type_alias))] | ||
#![allow(incomplete_features)] | ||
|
||
type X1 = X2; | ||
//~^ ERROR cycle detected when expanding type alias `X1` | ||
//[gated]~^ ERROR cycle detected when expanding type alias `X1` | ||
//[feature]~^^ ERROR: overflow evaluating the requirement `X2` | ||
type X2 = X3; | ||
//[feature]~^ ERROR: overflow evaluating the requirement `X3` | ||
type X3 = X1; | ||
//[feature]~^ ERROR: overflow evaluating the requirement `X1` | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui/infinite/infinite-vec-type-recursion.feature.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0275]: overflow evaluating the requirement `X` | ||
--> $DIR/infinite-vec-type-recursion.rs:6:10 | ||
| | ||
LL | type X = Vec<X>; | ||
| ^^^^^^ | ||
| | ||
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0275`. |
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,4 +1,11 @@ | ||
// revisions: feature gated | ||
|
||
#![cfg_attr(feature, feature(lazy_type_alias))] | ||
#![allow(incomplete_features)] | ||
|
||
type X = Vec<X>; | ||
//~^ ERROR cycle detected | ||
//[gated]~^ ERROR cycle detected | ||
//[feature]~^^ ERROR: overflow evaluating the requirement `X` | ||
|
||
#[rustfmt::skip] | ||
fn main() { let b: X = Vec::new(); } |