aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2021-07-01 19:56:22 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-07-05 10:34:20 +0200
commitce4a0932d5d51645942ac5d9920e5246ade72586 (patch)
tree38504ce11dd62c83d032f790b8efb7c4c34bcc3a /askama_shared
parente9badca2573a8e6f89e14a75446e1c890ebd843f (diff)
downloadaskama-ce4a0932d5d51645942ac5d9920e5246ade72586.tar.gz
askama-ce4a0932d5d51645942ac5d9920e5246ade72586.tar.bz2
askama-ce4a0932d5d51645942ac5d9920e5246ade72586.zip
Prepare generator::visit_target() for nested targets
By now only non-nested tuples are accepted by the parser, but this will change. This change makes visit_target() call itself for items in a tuple. So enable the function to call itself, I needed to fix the lifetime annotation, because the references inside a Target instance may outlife a reference to instance itself.
Diffstat (limited to 'askama_shared')
-rw-r--r--askama_shared/src/generator.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs
index 8457400..36c1e6d 100644
--- a/askama_shared/src/generator.rs
+++ b/askama_shared/src/generator.rs
@@ -1533,7 +1533,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
DisplayWrap::Unwrapped
}
- fn visit_target(&mut self, buf: &mut Buffer, target: &'a Target<'_>) {
+ fn visit_target(&mut self, buf: &mut Buffer, target: &Target<'a>) {
match *target {
Target::Name(name) => {
let name = normalize_identifier(name);
@@ -1543,9 +1543,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
Target::Tuple(ref targets) => {
buf.write("(");
for name in targets {
- let name = normalize_identifier(name);
- self.locals.insert_with_default(name);
- buf.write(name);
+ self.visit_target(buf, &Target::Name(name));
buf.write(",");
}
buf.write(")");