forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#106960 - estebank:parse-anon-enums, r=cjgillot
Teach parser to understand fake anonymous enum syntax Parse `Ty | OtherTy` in function argument and return types. Parse type ascription in top level patterns. Minimally address rust-lang#100741.
- Loading branch information
Showing
9 changed files
with
266 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
fn foo(x: bool | i32) -> i32 | f64 { | ||
//~^ ERROR anonymous enums are not supported | ||
//~| ERROR anonymous enums are not supported | ||
match x { | ||
x: i32 => x, //~ ERROR expected | ||
true => 42., | ||
false => 0.333, | ||
} | ||
} | ||
|
||
fn main() { | ||
match foo(true) { | ||
42: i32 => (), //~ ERROR expected | ||
_: f64 => (), //~ ERROR expected | ||
x: i32 => (), //~ ERROR expected | ||
} | ||
} |
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,68 @@ | ||
error: anonymous enums are not supported | ||
--> $DIR/anon-enums.rs:1:16 | ||
| | ||
LL | fn foo(x: bool | i32) -> i32 | f64 { | ||
| ---- ^ --- | ||
| | ||
= help: create a named `enum` and use it here instead: | ||
enum Name { | ||
Variant1(bool), | ||
Variant2(i32), | ||
} | ||
|
||
error: anonymous enums are not supported | ||
--> $DIR/anon-enums.rs:1:30 | ||
| | ||
LL | fn foo(x: bool | i32) -> i32 | f64 { | ||
| --- ^ --- | ||
| | ||
= help: create a named `enum` and use it here instead: | ||
enum Name { | ||
Variant1(i32), | ||
Variant2(f64), | ||
} | ||
|
||
error: expected one of `@` or `|`, found `:` | ||
--> $DIR/anon-enums.rs:5:10 | ||
| | ||
LL | x: i32 => x, | ||
| ^ --- specifying the type of a pattern isn't supported | ||
| | | ||
| expected one of `@` or `|` | ||
| | ||
help: maybe write a path separator here | ||
| | ||
LL | x::i32 => x, | ||
| ~~ | ||
|
||
error: expected one of `...`, `..=`, `..`, or `|`, found `:` | ||
--> $DIR/anon-enums.rs:13:11 | ||
| | ||
LL | 42: i32 => (), | ||
| ^ --- specifying the type of a pattern isn't supported | ||
| | | ||
| expected one of `...`, `..=`, `..`, or `|` | ||
|
||
error: expected `|`, found `:` | ||
--> $DIR/anon-enums.rs:14:10 | ||
| | ||
LL | _: f64 => (), | ||
| ^ --- specifying the type of a pattern isn't supported | ||
| | | ||
| expected `|` | ||
|
||
error: expected one of `@` or `|`, found `:` | ||
--> $DIR/anon-enums.rs:15:10 | ||
| | ||
LL | x: i32 => (), | ||
| ^ --- specifying the type of a pattern isn't supported | ||
| | | ||
| expected one of `@` or `|` | ||
| | ||
help: maybe write a path separator here | ||
| | ||
LL | x::i32 => (), | ||
| ~~ | ||
|
||
error: aborting due to 6 previous errors | ||
|
Oops, something went wrong.