From f1a141a6c036c0a09d66999b29b6396b8e1bd847 Mon Sep 17 00:00:00 2001 From: DropDemBits Date: Sun, 18 Jun 2023 00:13:54 -0400 Subject: [PATCH] Update "Jars and Ingredients" to reflect the in-place init changes --- book/src/plumbing/jars_and_ingredients.md | 6 +++--- components/salsa-2022-macros/src/jar.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/book/src/plumbing/jars_and_ingredients.md b/book/src/plumbing/jars_and_ingredients.md index 506a460f..2928bac3 100644 --- a/book/src/plumbing/jars_and_ingredients.md +++ b/book/src/plumbing/jars_and_ingredients.md @@ -195,16 +195,16 @@ The `Default` implementation for `Storage` does the work: First, it creates an empty `Routes` instance. Then it invokes the `DB::create_jars` method. -The implementation of this method is defined by the `#[salsa::db]` macro; it simply invokes the `Jar::create_jar` method on each of the jars: +The implementation of this method is defined by the `#[salsa::db]` macro; it invokes `salsa::plumbing::create_jars_inplace` to allocate memory for the jars, and then invokes the `Jar::init_jar` method on each of the jars to initialize them: ```rust,ignore {{#include ../../../components/salsa-2022-macros/src/db.rs:create_jars}} ``` -This implementation for `create_jar` is geneated by the `#[salsa::jar]` macro, and simply walks over the representative type for each salsa item and asks *it* to create its ingredients +This implementation for `init_jar` is generated by the `#[salsa::jar]` macro, and simply walks over the representative type for each salsa item and asks *it* to create its ingredients ```rust,ignore -{{#include ../../../components/salsa-2022-macros/src/jar.rs:create_jar}} +{{#include ../../../components/salsa-2022-macros/src/jar.rs:init_jar}} ``` The code to create the ingredients for any particular item is generated by their associated macros (e.g., `#[salsa::tracked]`, `#[salsa::input]`), but it always follows a particular structure. diff --git a/components/salsa-2022-macros/src/jar.rs b/components/salsa-2022-macros/src/jar.rs index a0b2358e..44b9fbdd 100644 --- a/components/salsa-2022-macros/src/jar.rs +++ b/components/salsa-2022-macros/src/jar.rs @@ -108,7 +108,7 @@ pub(crate) fn jar_impl( .zip(0..) .map(|(f, i)| syn::LitInt::new(&format!("{}", i), f.ty.span())) .collect(); - // ANCHOR: create_jar + // ANCHOR: init_jar quote! { unsafe impl<'salsa_db> salsa::jar::Jar<'salsa_db> for #jar_struct { type DynDb = dyn #jar_trait + 'salsa_db; @@ -126,7 +126,7 @@ pub(crate) fn jar_impl( } } } - // ANCHOR_END: create_jar + // ANCHOR_END: init_jar } pub(crate) fn jar_struct(input: &ItemStruct) -> ItemStruct {