forked from rinja-rs/rinja
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rinja-rs#118 from Kijewski/pr-end
parser: tell user proper keyword to end node
- Loading branch information
Showing
6 changed files
with
124 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use rinja::Template; | ||
|
||
#[derive(Template)] | ||
#[template(source = "{% for _ in 1..=10 %}{% end %}", ext = "txt")] | ||
struct For; | ||
|
||
#[derive(Template)] | ||
#[template(source = "{% macro test() %}{% end %}", ext = "txt")] | ||
struct Macro; | ||
|
||
#[derive(Template)] | ||
#[template(source = "{% filter upper %}{% end %}", ext = "txt")] | ||
struct Filter; | ||
|
||
#[derive(Template)] | ||
#[template(source = "{% match () %}{% when () %}{% end %}", ext = "txt")] | ||
struct Match; | ||
|
||
#[derive(Template)] | ||
#[template(source = "{% block body %}{% end %}", ext = "txt")] | ||
struct Block; | ||
|
||
#[derive(Template)] | ||
#[template(source = "{% if true %}{% end %}", ext = "txt")] | ||
struct If; | ||
|
||
#[derive(Template)] | ||
#[template(source = "{% if true %}{% endfor %}", ext = "txt")] | ||
struct IfFor; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
error: expected `endfor` to terminate `for` node, found `end` | ||
--> <source attribute>:1:23 | ||
" end %}" | ||
--> tests/ui/wrong-end.rs:4:21 | ||
| | ||
4 | #[template(source = "{% for _ in 1..=10 %}{% end %}", ext = "txt")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: expected `endmacro` to terminate `macro` node, found `end` | ||
--> <source attribute>:1:20 | ||
" end %}" | ||
--> tests/ui/wrong-end.rs:8:21 | ||
| | ||
8 | #[template(source = "{% macro test() %}{% end %}", ext = "txt")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: expected `endfilter` to terminate `filter` node, found `end` | ||
--> <source attribute>:1:20 | ||
" end %}" | ||
--> tests/ui/wrong-end.rs:12:21 | ||
| | ||
12 | #[template(source = "{% filter upper %}{% end %}", ext = "txt")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: expected `endmatch` to terminate `match` node, found `end` | ||
--> <source attribute>:1:30 | ||
"end %}" | ||
--> tests/ui/wrong-end.rs:16:21 | ||
| | ||
16 | #[template(source = "{% match () %}{% when () %}{% end %}", ext = "txt")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: expected `endblock` to terminate `block` node, found `end` | ||
--> <source attribute>:1:18 | ||
" end %}" | ||
--> tests/ui/wrong-end.rs:20:21 | ||
| | ||
20 | #[template(source = "{% block body %}{% end %}", ext = "txt")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: expected `endif` to terminate `if` node, found `end` | ||
--> <source attribute>:1:15 | ||
" end %}" | ||
--> tests/ui/wrong-end.rs:24:21 | ||
| | ||
24 | #[template(source = "{% if true %}{% end %}", ext = "txt")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: expected `endif` to terminate `if` node, found `endfor` | ||
--> <source attribute>:1:15 | ||
" endfor %}" | ||
--> tests/ui/wrong-end.rs:28:21 | ||
| | ||
28 | #[template(source = "{% if true %}{% endfor %}", ext = "txt")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |