Skip to content

Commit

Permalink
Add macro calls to else-no-if parser test
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 30, 2023
1 parent a6e3f13 commit ed5a1af
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 5 deletions.
30 changes: 30 additions & 0 deletions tests/ui/parser/else-no-if.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
macro_rules! falsy {
() => { false };
}

fn foo() {
if true {
} else false {
Expand Down Expand Up @@ -25,6 +29,32 @@ fn foo4() {
{}
}

fn foo5() {
if true {
} else falsy!() {
//~^ ERROR expected `{`, found `falsy`
}
}

fn foo6() {
if true {
} else falsy!();
//~^ ERROR expected `{`, found `falsy`
}

fn foo7() {
if true {
} else falsy! {} {
//~^ ERROR expected `{`, found `falsy`
}
}

fn foo8() {
if true {
} else falsy! {};
//~^ ERROR expected `{`, found `falsy`
}

fn falsy() -> bool {
false
}
Expand Down
58 changes: 53 additions & 5 deletions tests/ui/parser/else-no-if.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected `{`, found keyword `false`
--> $DIR/else-no-if.rs:3:12
--> $DIR/else-no-if.rs:7:12
|
LL | } else false {
| ---- ^^^^^
Expand All @@ -12,7 +12,7 @@ LL | } else if false {
| ++

error: expected `{`, found `falsy`
--> $DIR/else-no-if.rs:10:12
--> $DIR/else-no-if.rs:14:12
|
LL | } else falsy() {
| ---- ^^^^^
Expand All @@ -25,7 +25,7 @@ LL | } else if falsy() {
| ++

error: expected `{`, found `falsy`
--> $DIR/else-no-if.rs:17:12
--> $DIR/else-no-if.rs:21:12
|
LL | } else falsy();
| ^^^^^ expected `{`
Expand All @@ -36,7 +36,7 @@ LL | } else { falsy() };
| + +

error: expected `{`, found keyword `loop`
--> $DIR/else-no-if.rs:23:12
--> $DIR/else-no-if.rs:27:12
|
LL | } else loop{}
| ^^^^ expected `{`
Expand All @@ -46,5 +46,53 @@ help: try placing this code inside a block
LL | } else { loop{} }
| + +

error: aborting due to 4 previous errors
error: expected `{`, found `falsy`
--> $DIR/else-no-if.rs:34:12
|
LL | } else falsy!() {
| ---- ^^^^^
| |
| expected an `if` or a block after this `else`
|
help: add an `if` if this is the condition of a chained `else if` statement
|
LL | } else if falsy!() {
| ++

error: expected `{`, found `falsy`
--> $DIR/else-no-if.rs:41:12
|
LL | } else falsy!();
| ^^^^^ expected `{`
|
help: try placing this code inside a block
|
LL | } else { falsy!() };
| + +

error: expected `{`, found `falsy`
--> $DIR/else-no-if.rs:47:12
|
LL | } else falsy! {} {
| ---- ^^^^^
| |
| expected an `if` or a block after this `else`
|
help: add an `if` if this is the condition of a chained `else if` statement
|
LL | } else if falsy! {} {
| ++

error: expected `{`, found `falsy`
--> $DIR/else-no-if.rs:54:12
|
LL | } else falsy! {};
| ^^^^^ expected `{`
|
help: try placing this code inside a block
|
LL | } else { falsy! {} };
| + +

error: aborting due to 8 previous errors

0 comments on commit ed5a1af

Please sign in to comment.