Skip to content

Commit b912bd9

Browse files
authored
Disallow elements in attributes (redux) (#460)
* Rename control flow nodes to avoid conflict with `syn` tokens * Remove calls to `Token!` * Disallow elements in attributes * Add test * Split `into_element` out of `MaybeElement` * Fix Clippy type complexity
1 parent 3eaa6e8 commit b912bd9

File tree

6 files changed

+282
-137
lines changed

6 files changed

+282
-137
lines changed

maud/tests/warnings/attribute-missing-value.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error: unexpected end of input, expected one of: curly braces, literal, parentheses, identifier, `.`, `#`, `@`, `;`
2-
--> $DIR/attribute-missing-value.rs:4:5
1+
error: unexpected end of input, expected one of: curly braces, literal, parentheses, `@`, `;`
2+
--> tests/warnings/attribute-missing-value.rs:4:5
33
|
44
4 | / html! {
55
5 | | a href=

maud/tests/warnings/class-shorthand-missing-value.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error: unexpected end of input, expected one of: curly braces, literal, parentheses, identifier, `.`, `#`, `@`, `;`
2-
--> $DIR/class-shorthand-missing-value.rs:4:5
1+
error: unexpected end of input, expected one of: curly braces, literal, parentheses, `@`, `;`
2+
--> tests/warnings/class-shorthand-missing-value.rs:4:5
33
|
44
4 | / html! {
55
5 | | p.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use maud::html;
2+
3+
fn main() {
4+
html! {
5+
a href={ b {} } {}
6+
};
7+
8+
html! {
9+
a href=.pinkie-pie {} {}
10+
};
11+
12+
html! {
13+
a .{ b {} } {}
14+
};
15+
16+
html! {
17+
a #{ b {} } {}
18+
};
19+
20+
html! {
21+
@if true {
22+
} @else if true {
23+
} @else {
24+
a href={ b #if-else {} } {}
25+
}
26+
};
27+
28+
html! {
29+
@for _ in 0..10 {
30+
a href={ b #for {} } {}
31+
}
32+
};
33+
34+
html! {
35+
@while false {
36+
a href={ b #while {} } {}
37+
}
38+
};
39+
40+
html! {
41+
@match () {
42+
() => a href={ b #match {} } {}
43+
}
44+
};
45+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
error: expected one of: curly braces, literal, parentheses, `@`, `;`
2+
--> tests/warnings/elements-in-attributes.rs:5:18
3+
|
4+
5 | a href={ b {} } {}
5+
| ^
6+
7+
error: expected one of: curly braces, literal, parentheses, `@`, `;`
8+
--> tests/warnings/elements-in-attributes.rs:9:16
9+
|
10+
9 | a href=.pinkie-pie {} {}
11+
| ^
12+
13+
error: expected one of: curly braces, literal, parentheses, `@`, `;`
14+
--> tests/warnings/elements-in-attributes.rs:13:14
15+
|
16+
13 | a .{ b {} } {}
17+
| ^
18+
19+
error: expected one of: curly braces, literal, parentheses, `@`, `;`
20+
--> tests/warnings/elements-in-attributes.rs:17:14
21+
|
22+
17 | a #{ b {} } {}
23+
| ^
24+
25+
error: expected one of: curly braces, literal, parentheses, `@`, `;`
26+
--> tests/warnings/elements-in-attributes.rs:24:22
27+
|
28+
24 | a href={ b #if-else {} } {}
29+
| ^
30+
31+
error: expected one of: curly braces, literal, parentheses, `@`, `;`
32+
--> tests/warnings/elements-in-attributes.rs:30:22
33+
|
34+
30 | a href={ b #for {} } {}
35+
| ^
36+
37+
error: expected one of: curly braces, literal, parentheses, `@`, `;`
38+
--> tests/warnings/elements-in-attributes.rs:36:22
39+
|
40+
36 | a href={ b #while {} } {}
41+
| ^
42+
43+
error: expected one of: curly braces, literal, parentheses, `@`, `;`
44+
--> tests/warnings/elements-in-attributes.rs:42:28
45+
|
46+
42 | () => a href={ b #match {} } {}
47+
| ^

0 commit comments

Comments
 (0)