diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs index b2379f389..4e2a3afcb 100644 --- a/askama_derive/src/lib.rs +++ b/askama_derive/src/lib.rs @@ -65,7 +65,7 @@ fn build_template(ast: &syn::DeriveInput) -> Result { eprintln!("{:?}", parsed[&input.path]); } - let code = generator::generate(&input, &contexts, &heritage, INTEGRATIONS)?; + let code = generator::generate(&input, &contexts, heritage.as_ref(), INTEGRATIONS)?; if input.print == Print::Code || input.print == Print::All { eprintln!("{}", code); } diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index cd18819b3..262de4794 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -15,7 +15,7 @@ use std::{cmp, hash, mem, str}; pub fn generate( input: &TemplateInput<'_>, contexts: &HashMap<&PathBuf, Context<'_>, S>, - heritage: &Option>, + heritage: Option<&Heritage<'_>>, integrations: Integrations, ) -> Result { Generator::new(input, contexts, heritage, integrations, MapChain::new()) @@ -28,7 +28,7 @@ struct Generator<'a, S: std::hash::BuildHasher> { // All contexts, keyed by the package-relative template path contexts: &'a HashMap<&'a PathBuf, Context<'a>, S>, // The heritage contains references to blocks and their ancestry - heritage: &'a Option>, + heritage: Option<&'a Heritage<'a>>, // What integrations need to be generated integrations: Integrations, // Variables accessible directly from the current scope (not redirected to context) @@ -52,7 +52,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { fn new<'n>( input: &'n TemplateInput<'_>, contexts: &'n HashMap<&'n PathBuf, Context<'n>, S>, - heritage: &'n Option>, + heritage: Option<&'n Heritage<'_>>, integrations: Integrations, locals: MapChain<'n, &'n str, LocalMeta>, ) -> Generator<'n, S> { diff --git a/askama_shared/src/heritage.rs b/askama_shared/src/heritage.rs index 95057b81b..12d16d05f 100644 --- a/askama_shared/src/heritage.rs +++ b/askama_shared/src/heritage.rs @@ -10,9 +10,9 @@ pub struct Heritage<'a> { } impl Heritage<'_> { - pub fn new<'n>( + pub fn new<'n, S: std::hash::BuildHasher>( mut ctx: &'n Context<'n>, - contexts: &'n HashMap<&'n PathBuf, Context<'n>>, + contexts: &'n HashMap<&'n PathBuf, Context<'n>, S>, ) -> Heritage<'n> { let mut blocks: BlockAncestry<'n> = ctx .blocks