Skip to content

Commit 1f76200

Browse files
authored
Error when else is used without @ (#462)
1 parent 678d62b commit 1f76200

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

maud/tests/warnings/keyword-without-at.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ use maud::html;
33
fn main() {
44
html! {
55
if {}
6+
else {}
7+
for {}
8+
while {}
9+
match {}
610
};
711
}
Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,39 @@
11
error: found keyword `if`
2-
--> $DIR/keyword-without-at.rs:5:9
2+
--> tests/warnings/keyword-without-at.rs:5:9
33
|
44
5 | if {}
55
| ^^
66
|
7-
= help: should this be a `@if`?
7+
= help: should this be `@if`?
8+
9+
error: found keyword `else`
10+
--> tests/warnings/keyword-without-at.rs:6:9
11+
|
12+
6 | else {}
13+
| ^^^^
14+
|
15+
= help: should this be `@else`?
16+
17+
error: found keyword `for`
18+
--> tests/warnings/keyword-without-at.rs:7:9
19+
|
20+
7 | for {}
21+
| ^^^
22+
|
23+
= help: should this be `@for`?
24+
25+
error: found keyword `while`
26+
--> tests/warnings/keyword-without-at.rs:8:9
27+
|
28+
8 | while {}
29+
| ^^^^^
30+
|
31+
= help: should this be `@while`?
32+
33+
error: found keyword `match`
34+
--> tests/warnings/keyword-without-at.rs:9:9
35+
|
36+
9 | match {}
37+
| ^^^^^
38+
|
39+
= help: should this be `@match`?

maud_macros/src/ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ impl<E: MaybeElement> Markup<E> {
6060
) -> syn::Result<Self> {
6161
if input.peek(Let)
6262
|| input.peek(If)
63+
|| input.peek(Else)
6364
|| input.peek(For)
6465
|| input.peek(While)
6566
|| input.peek(Match)
@@ -68,7 +69,7 @@ impl<E: MaybeElement> Markup<E> {
6869
diagnostics.push(
6970
kw.span()
7071
.error(format!("found keyword `{kw}`"))
71-
.help(format!("should this be a `@{kw}`?")),
72+
.help(format!("should this be `@{kw}`?")),
7273
);
7374
}
7475

0 commit comments

Comments
 (0)