Skip to content

Commit ed5a1af

Browse files
committed
Add macro calls to else-no-if parser test
1 parent a6e3f13 commit ed5a1af

File tree

2 files changed

+83
-5
lines changed

2 files changed

+83
-5
lines changed

tests/ui/parser/else-no-if.rs

+30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
macro_rules! falsy {
2+
() => { false };
3+
}
4+
15
fn foo() {
26
if true {
37
} else false {
@@ -25,6 +29,32 @@ fn foo4() {
2529
{}
2630
}
2731

32+
fn foo5() {
33+
if true {
34+
} else falsy!() {
35+
//~^ ERROR expected `{`, found `falsy`
36+
}
37+
}
38+
39+
fn foo6() {
40+
if true {
41+
} else falsy!();
42+
//~^ ERROR expected `{`, found `falsy`
43+
}
44+
45+
fn foo7() {
46+
if true {
47+
} else falsy! {} {
48+
//~^ ERROR expected `{`, found `falsy`
49+
}
50+
}
51+
52+
fn foo8() {
53+
if true {
54+
} else falsy! {};
55+
//~^ ERROR expected `{`, found `falsy`
56+
}
57+
2858
fn falsy() -> bool {
2959
false
3060
}

tests/ui/parser/else-no-if.stderr

+53-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected `{`, found keyword `false`
2-
--> $DIR/else-no-if.rs:3:12
2+
--> $DIR/else-no-if.rs:7:12
33
|
44
LL | } else false {
55
| ---- ^^^^^
@@ -12,7 +12,7 @@ LL | } else if false {
1212
| ++
1313

1414
error: expected `{`, found `falsy`
15-
--> $DIR/else-no-if.rs:10:12
15+
--> $DIR/else-no-if.rs:14:12
1616
|
1717
LL | } else falsy() {
1818
| ---- ^^^^^
@@ -25,7 +25,7 @@ LL | } else if falsy() {
2525
| ++
2626

2727
error: expected `{`, found `falsy`
28-
--> $DIR/else-no-if.rs:17:12
28+
--> $DIR/else-no-if.rs:21:12
2929
|
3030
LL | } else falsy();
3131
| ^^^^^ expected `{`
@@ -36,7 +36,7 @@ LL | } else { falsy() };
3636
| + +
3737

3838
error: expected `{`, found keyword `loop`
39-
--> $DIR/else-no-if.rs:23:12
39+
--> $DIR/else-no-if.rs:27:12
4040
|
4141
LL | } else loop{}
4242
| ^^^^ expected `{`
@@ -46,5 +46,53 @@ help: try placing this code inside a block
4646
LL | } else { loop{} }
4747
| + +
4848

49-
error: aborting due to 4 previous errors
49+
error: expected `{`, found `falsy`
50+
--> $DIR/else-no-if.rs:34:12
51+
|
52+
LL | } else falsy!() {
53+
| ---- ^^^^^
54+
| |
55+
| expected an `if` or a block after this `else`
56+
|
57+
help: add an `if` if this is the condition of a chained `else if` statement
58+
|
59+
LL | } else if falsy!() {
60+
| ++
61+
62+
error: expected `{`, found `falsy`
63+
--> $DIR/else-no-if.rs:41:12
64+
|
65+
LL | } else falsy!();
66+
| ^^^^^ expected `{`
67+
|
68+
help: try placing this code inside a block
69+
|
70+
LL | } else { falsy!() };
71+
| + +
72+
73+
error: expected `{`, found `falsy`
74+
--> $DIR/else-no-if.rs:47:12
75+
|
76+
LL | } else falsy! {} {
77+
| ---- ^^^^^
78+
| |
79+
| expected an `if` or a block after this `else`
80+
|
81+
help: add an `if` if this is the condition of a chained `else if` statement
82+
|
83+
LL | } else if falsy! {} {
84+
| ++
85+
86+
error: expected `{`, found `falsy`
87+
--> $DIR/else-no-if.rs:54:12
88+
|
89+
LL | } else falsy! {};
90+
| ^^^^^ expected `{`
91+
|
92+
help: try placing this code inside a block
93+
|
94+
LL | } else { falsy! {} };
95+
| + +
96+
97+
error: aborting due to 8 previous errors
5098

0 commit comments

Comments
 (0)