From 268d8250fb0a9cdcbbd760bdf39424ed02fd1920 Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Sat, 17 Jul 2021 13:40:49 +0200 Subject: Use "target()" to parse "when" block `target()` as used in parsing "let" and "if let" implements parsing nested tuples and structs. But it does not implement parsing literals. The functions `match_variant()` and `with_parameters()` as used in parsing "when" blocks do not implement parsing nested structs, but it implements parsing literals. This PR combines `match_variant()` and `with_parameters()` into `target()`, so that all `{%when%}` support nested structs, too. --- testing/tests/ui/lit_on_assignment_lhs.rs | 11 +++++++++++ testing/tests/ui/lit_on_assignment_lhs.stderr | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 testing/tests/ui/lit_on_assignment_lhs.rs create mode 100644 testing/tests/ui/lit_on_assignment_lhs.stderr (limited to 'testing/tests/ui') diff --git a/testing/tests/ui/lit_on_assignment_lhs.rs b/testing/tests/ui/lit_on_assignment_lhs.rs new file mode 100644 index 0000000..1793770 --- /dev/null +++ b/testing/tests/ui/lit_on_assignment_lhs.rs @@ -0,0 +1,11 @@ +use askama::Template; + +#[derive(Template)] +#[template( + source = "{%let 7=x%}", + ext = "txt" +)] +struct MyTemplate; + +fn main() { +} diff --git a/testing/tests/ui/lit_on_assignment_lhs.stderr b/testing/tests/ui/lit_on_assignment_lhs.stderr new file mode 100644 index 0000000..fa488cb --- /dev/null +++ b/testing/tests/ui/lit_on_assignment_lhs.stderr @@ -0,0 +1,7 @@ +error: proc-macro derive panicked + --> $DIR/lit_on_assignment_lhs.rs:3:10 + | +3 | #[derive(Template)] + | ^^^^^^^^ + | + = help: message: Cannot have literals on the left-hand-side of an assignment. -- cgit