From ce4a0932d5d51645942ac5d9920e5246ade72586 Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Thu, 1 Jul 2021 19:56:22 +0200 Subject: 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. --- askama_shared/src/generator.rs | 6 ++---- 1 file 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(")"); -- cgit