diff options
| author | Catherine Flores <catherine.3.flores@gmail.com> | 2023-07-24 17:05:10 +0000 |
|---|---|---|
| committer | Catherine Flores <catherine.3.flores@gmail.com> | 2023-07-24 17:05:10 +0000 |
| commit | dece622ee48d9744d6e64891a734e8fd25eac903 (patch) | |
| tree | d8b35c977d78e486b19c40850f25abb52283b2ec /tests/ui/parser | |
| parent | 287db04636ffefa3fdaa39fe0fdcc3cf75b60444 (diff) | |
| download | rust-dece622ee48d9744d6e64891a734e8fd25eac903.tar.gz rust-dece622ee48d9744d6e64891a734e8fd25eac903.zip | |
Recover from some macros
Diffstat (limited to 'tests/ui/parser')
| -rw-r--r-- | tests/ui/parser/macro/macro-expand-to-field-2.rs | 16 | ||||
| -rw-r--r-- | tests/ui/parser/macro/macro-expand-to-field-2.stderr | 18 | ||||
| -rw-r--r-- | tests/ui/parser/macro/macro-expand-to-field-3.rs | 15 | ||||
| -rw-r--r-- | tests/ui/parser/macro/macro-expand-to-field-3.stderr | 19 | ||||
| -rw-r--r-- | tests/ui/parser/macro/macro-expand-to-field.rs | 41 | ||||
| -rw-r--r-- | tests/ui/parser/macro/macro-expand-to-field.stderr | 63 | ||||
| -rw-r--r-- | tests/ui/parser/macro/macro-expand-to-match-arm.rs | 2 |
7 files changed, 88 insertions, 86 deletions
diff --git a/tests/ui/parser/macro/macro-expand-to-field-2.rs b/tests/ui/parser/macro/macro-expand-to-field-2.rs deleted file mode 100644 index 2f806bcea84..00000000000 --- a/tests/ui/parser/macro/macro-expand-to-field-2.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![no_main] - -macro_rules! field { - ($name:ident:$type:ty) => { - $name:$type - }; -} - -enum EnumVariantField { - Named { //~ NOTE while parsing this struct - field!(oopsies:()), //~ NOTE macros cannot expand to struct fields - //~^ ERROR expected `:`, found `!` - //~^^ ERROR expected `,`, or `}`, found `(` - //~^^^ NOTE expected `:` - }, -} diff --git a/tests/ui/parser/macro/macro-expand-to-field-2.stderr b/tests/ui/parser/macro/macro-expand-to-field-2.stderr deleted file mode 100644 index 8c3758173fe..00000000000 --- a/tests/ui/parser/macro/macro-expand-to-field-2.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: expected `:`, found `!` - --> $DIR/macro-expand-to-field-2.rs:11:14 - | -LL | field!(oopsies:()), - | ^ expected `:` - | - = note: macros cannot expand to struct fields - -error: expected `,`, or `}`, found `(` - --> $DIR/macro-expand-to-field-2.rs:11:15 - | -LL | Named { - | ----- while parsing this struct -LL | field!(oopsies:()), - | ^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/parser/macro/macro-expand-to-field-3.rs b/tests/ui/parser/macro/macro-expand-to-field-3.rs deleted file mode 100644 index 0a8b655e0dc..00000000000 --- a/tests/ui/parser/macro/macro-expand-to-field-3.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![no_main] - -macro_rules! field { - ($name:ident:$type:ty) => { - $name:$type - }; -} - -union EnumVariantField { //~ NOTE while parsing this union - A: u32, - field!(oopsies:()), //~ NOTE macros cannot expand to union fields - //~^ ERROR expected `:`, found `!` - //~^^ ERROR expected `,`, or `}`, found `(` - //~^^^ NOTE expected `:` -} diff --git a/tests/ui/parser/macro/macro-expand-to-field-3.stderr b/tests/ui/parser/macro/macro-expand-to-field-3.stderr deleted file mode 100644 index 360b2bf793b..00000000000 --- a/tests/ui/parser/macro/macro-expand-to-field-3.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: expected `:`, found `!` - --> $DIR/macro-expand-to-field-3.rs:11:10 - | -LL | field!(oopsies:()), - | ^ expected `:` - | - = note: macros cannot expand to union fields - -error: expected `,`, or `}`, found `(` - --> $DIR/macro-expand-to-field-3.rs:11:11 - | -LL | union EnumVariantField { - | ---------------- while parsing this union -LL | A: u32, -LL | field!(oopsies:()), - | ^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/parser/macro/macro-expand-to-field.rs b/tests/ui/parser/macro/macro-expand-to-field.rs index 38055a3bbb2..fd1d408e726 100644 --- a/tests/ui/parser/macro/macro-expand-to-field.rs +++ b/tests/ui/parser/macro/macro-expand-to-field.rs @@ -12,15 +12,46 @@ macro_rules! variant { } } -struct Struct { //~ NOTE while parsing this struct +struct Struct { field!(bar:u128), //~ NOTE macros cannot expand to struct fields - //~^ ERROR expected `:`, found `!` - //~^^ NOTE expected `:` - //~^^^ ERROR expected `,`, or `}`, found `(` + //~^ ERROR unexpected token: `!` + //~^^ NOTE unexpected token after this + a: u32, + b: u32, + field!(recovers:()), //~ NOTE macros cannot expand to struct fields + //~^ ERROR unexpected token: `!` + //~^^ NOTE unexpected token after this } -enum EnumVariant { //~ NOTE while parsing this enum +enum EnumVariant { variant!(whoops), //~ NOTE macros cannot expand to enum variants //~^ ERROR unexpected token: `!` //~^^ NOTE unexpected token after this + U32, + F64, + variant!(recovers), //~ NOTE macros cannot expand to enum variants + //~^ ERROR unexpected token: `!` + //~^^ NOTE unexpected token after this +} + +enum EnumVariantField { + Named { + field!(oopsies:()), //~ NOTE macros cannot expand to struct fields + //~^ ERROR unexpected token: `!` + //~^^ unexpected token after this + field!(oopsies2:()), //~ NOTE macros cannot expand to struct fields + //~^ ERROR unexpected token: `!` + //~^^ unexpected token after this + }, +} + +union Union { + A: u32, + field!(oopsies:()), //~ NOTE macros cannot expand to union fields + //~^ ERROR unexpected token: `!` + //~^^ unexpected token after this + B: u32, + field!(recovers:()), //~ NOTE macros cannot expand to union fields + //~^ ERROR unexpected token: `!` + //~^^ unexpected token after this } diff --git a/tests/ui/parser/macro/macro-expand-to-field.stderr b/tests/ui/parser/macro/macro-expand-to-field.stderr index 3f7fad334ec..108b68b481f 100644 --- a/tests/ui/parser/macro/macro-expand-to-field.stderr +++ b/tests/ui/parser/macro/macro-expand-to-field.stderr @@ -1,29 +1,66 @@ -error: expected `:`, found `!` +error: unexpected token: `!` --> $DIR/macro-expand-to-field.rs:16:10 | LL | field!(bar:u128), - | ^ expected `:` + | ^ unexpected token after this | = note: macros cannot expand to struct fields -error: expected `,`, or `}`, found `(` - --> $DIR/macro-expand-to-field.rs:16:11 +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:21:10 | -LL | struct Struct { - | ------ while parsing this struct -LL | field!(bar:u128), - | ^ +LL | field!(recovers:()), + | ^ unexpected token after this + | + = note: macros cannot expand to struct fields error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:23:12 + --> $DIR/macro-expand-to-field.rs:27:12 | -LL | enum EnumVariant { - | ----------- while parsing this enum LL | variant!(whoops), | ^ unexpected token after this | = note: macros cannot expand to enum variants - = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` -error: aborting due to 3 previous errors +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:32:12 + | +LL | variant!(recovers), + | ^ unexpected token after this + | + = note: macros cannot expand to enum variants + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:39:14 + | +LL | field!(oopsies:()), + | ^ unexpected token after this + | + = note: macros cannot expand to struct fields + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:42:14 + | +LL | field!(oopsies2:()), + | ^ unexpected token after this + | + = note: macros cannot expand to struct fields + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:50:10 + | +LL | field!(oopsies:()), + | ^ unexpected token after this + | + = note: macros cannot expand to union fields + +error: unexpected token: `!` + --> $DIR/macro-expand-to-field.rs:54:10 + | +LL | field!(recovers:()), + | ^ unexpected token after this + | + = note: macros cannot expand to union fields + +error: aborting due to 8 previous errors diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.rs b/tests/ui/parser/macro/macro-expand-to-match-arm.rs index 043bf371902..c176e8bbd9d 100644 --- a/tests/ui/parser/macro/macro-expand-to-match-arm.rs +++ b/tests/ui/parser/macro/macro-expand-to-match-arm.rs @@ -10,6 +10,8 @@ fn main() { Some(1) => {}, arm!(None => {}), //~ NOTE macros cannot expand to match arms //~^ ERROR unexpected `,` in pattern + // doesn't recover + Some(2) => {}, _ => {}, }; } |
