Skip to content

Commit

Permalink
Disallow elements in attributes (redux) (#460)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lambda-fairy authored Jan 7, 2025
1 parent 3eaa6e8 commit b912bd9
Show file tree
Hide file tree
Showing 6 changed files with 282 additions and 137 deletions.
4 changes: 2 additions & 2 deletions maud/tests/warnings/attribute-missing-value.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unexpected end of input, expected one of: curly braces, literal, parentheses, identifier, `.`, `#`, `@`, `;`
--> $DIR/attribute-missing-value.rs:4:5
error: unexpected end of input, expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/attribute-missing-value.rs:4:5
|
4 | / html! {
5 | | a href=
Expand Down
4 changes: 2 additions & 2 deletions maud/tests/warnings/class-shorthand-missing-value.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unexpected end of input, expected one of: curly braces, literal, parentheses, identifier, `.`, `#`, `@`, `;`
--> $DIR/class-shorthand-missing-value.rs:4:5
error: unexpected end of input, expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/class-shorthand-missing-value.rs:4:5
|
4 | / html! {
5 | | p.
Expand Down
45 changes: 45 additions & 0 deletions maud/tests/warnings/elements-in-attributes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use maud::html;

fn main() {
html! {
a href={ b {} } {}
};

html! {
a href=.pinkie-pie {} {}
};

html! {
a .{ b {} } {}
};

html! {
a #{ b {} } {}
};

html! {
@if true {
} @else if true {
} @else {
a href={ b #if-else {} } {}
}
};

html! {
@for _ in 0..10 {
a href={ b #for {} } {}
}
};

html! {
@while false {
a href={ b #while {} } {}
}
};

html! {
@match () {
() => a href={ b #match {} } {}
}
};
}
47 changes: 47 additions & 0 deletions maud/tests/warnings/elements-in-attributes.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
error: expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/elements-in-attributes.rs:5:18
|
5 | a href={ b {} } {}
| ^

error: expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/elements-in-attributes.rs:9:16
|
9 | a href=.pinkie-pie {} {}
| ^

error: expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/elements-in-attributes.rs:13:14
|
13 | a .{ b {} } {}
| ^

error: expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/elements-in-attributes.rs:17:14
|
17 | a #{ b {} } {}
| ^

error: expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/elements-in-attributes.rs:24:22
|
24 | a href={ b #if-else {} } {}
| ^

error: expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/elements-in-attributes.rs:30:22
|
30 | a href={ b #for {} } {}
| ^

error: expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/elements-in-attributes.rs:36:22
|
36 | a href={ b #while {} } {}
| ^

error: expected one of: curly braces, literal, parentheses, `@`, `;`
--> tests/warnings/elements-in-attributes.rs:42:28
|
42 | () => a href={ b #match {} } {}
| ^
Loading

0 comments on commit b912bd9

Please sign in to comment.