diff --git a/components/salsa-macros/src/database_storage.rs b/components/salsa-macros/src/database_storage.rs index 1111f531..102320d2 100644 --- a/components/salsa-macros/src/database_storage.rs +++ b/components/salsa-macros/src/database_storage.rs @@ -108,7 +108,7 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream { impl ::salsa::plumbing::DatabaseOps for #database_name { fn for_each_query( &self, - mut op: impl FnMut(&dyn $crate::plumbing::QueryStorageMassOps), + mut op: impl FnMut(&dyn salsa::plumbing::QueryStorageMassOps), ) { #for_each_ops } @@ -123,9 +123,9 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream { { for_each_query_desc.extend(quote! { __SalsaQueryDescriptorKind::#query_name(key) => { - let runtime = $crate::Database::salsa_runtime(db); + let runtime = salsa::Database::salsa_runtime(db); let storage = &runtime.storage().#query_name; - <_ as $crate::plumbing::QueryStorageOps<#database_name, #query_type>>::maybe_changed_since( + <_ as salsa::plumbing::QueryStorageOps<#database_name, #query_type>>::maybe_changed_since( storage, db, revision, @@ -141,7 +141,7 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream { fn maybe_changed_since( &self, db: &#database_name, - revision: $crate::plumbing::Revision, + revision: salsa::plumbing::Revision, ) -> bool { match &self.kind { #for_each_query_desc @@ -157,13 +157,13 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream { } in each_query() { for_each_query_table.extend(quote! { - impl $crate::plumbing::GetQueryTable<#query_type> for #database_name { + impl salsa::plumbing::GetQueryTable<#query_type> for #database_name { fn get_query_table( db: &Self, - ) -> $crate::QueryTable<'_, Self, #query_type> { - $crate::QueryTable::new( + ) -> salsa::QueryTable<'_, Self, #query_type> { + salsa::QueryTable::new( db, - &$crate::Database::salsa_runtime(db) + &salsa::Database::salsa_runtime(db) .storage() .#query_name, ) @@ -171,11 +171,11 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream { fn get_query_table_mut( db: &mut Self, - ) -> $crate::QueryTableMut<'_, Self, #query_type> { + ) -> salsa::QueryTableMut<'_, Self, #query_type> { let db = &*db; - $crate::QueryTableMut::new( + salsa::QueryTableMut::new( db, - &$crate::Database::salsa_runtime(db) + &salsa::Database::salsa_runtime(db) .storage() .#query_name, ) @@ -183,8 +183,8 @@ pub(crate) fn database_storage(input: TokenStream) -> TokenStream { fn descriptor( db: &Self, - key: <#query_type as $crate::Query>::Key, - ) -> ::QueryDescriptor { + key: <#query_type as salsa::Query>::Key, + ) -> ::QueryDescriptor { __SalsaQueryDescriptor { kind: __SalsaQueryDescriptorKind::#query_name(key), } diff --git a/examples/hello_world/main.rs b/examples/hello_world/main.rs index b206e7e8..979d8bdb 100644 --- a/examples/hello_world/main.rs +++ b/examples/hello_world/main.rs @@ -85,7 +85,9 @@ salsa::database_storage! { fn main() { let mut db = DatabaseStruct::default(); - println!("Initially, the length is {}.", db.length(())); + // You cannot access input_string yet, because it does not have a value. If you do, it will + // panic. You could create an Option interface by maintaining a HashSet of inserted keys. + // println!("Initially, the length is {}.", db.length(())); db.query_mut(InputString) .set((), Arc::new(format!("Hello, world"))); diff --git a/src/lib.rs b/src/lib.rs index 111e650a..fea68f39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -500,7 +500,7 @@ where /// [`salsa::Runtime`]: struct.Runtime.html /// [hw]: https://github.com/salsa-rs/salsa/tree/master/examples/hello_world #[macro_export] -macro_rules! database_storage { +macro_rules! database_storage_old { ( $(#[$attr:meta])* $v:vis struct $Storage:ident for $Database:ty {