diff --git a/src/function/specify.rs b/src/function/specify.rs index a7047f6d..cbd1740f 100644 --- a/src/function/specify.rs +++ b/src/function/specify.rs @@ -29,7 +29,7 @@ where let (active_query_key, current_deps) = match runtime.active_query() { Some(v) => v, - None => panic!("can only use `specify` with an active query"), + None => panic!("can only use `specify` inside a tracked function"), }; // `specify` only works if the key is a tracked struct created in the current query. @@ -47,7 +47,7 @@ where let database_key_index = >::database_key_index(db.as_salsa_database(), key); let dependency_index = database_key_index.into(); if !runtime.is_output_of_active_query(dependency_index) { - panic!("can only use `specfiy` on entities created during current query"); + panic!("can only use `specify` on salsa structs created during the current tracked fn"); } // Subtle: we treat the "input" to a set query as if it were diff --git a/tests/specify-only-works-if-the-key-is-created-in-the-current-query.rs b/tests/specify-only-works-if-the-key-is-created-in-the-current-query.rs index 5b0ec7d2..f82a684c 100644 --- a/tests/specify-only-works-if-the-key-is-created-in-the-current-query.rs +++ b/tests/specify-only-works-if-the-key-is-created-in-the-current-query.rs @@ -2,16 +2,8 @@ //! compilation succeeds but execution panics #![allow(warnings)] -#[salsa::jar(db = Db)] -struct Jar( - MyInput, - MyTracked<'_>, - tracked_fn, - tracked_fn_extra, - tracked_struct_created_in_another_query, -); - -trait Db: salsa::DbWithJar {} +#[salsa::db] +trait Db: salsa::Database {} #[salsa::input] struct MyInput { @@ -37,23 +29,27 @@ fn tracked_fn<'db>(db: &'db dyn Db, input: MyInput) -> MyTracked<'db> { t } -#[salsa::tracked(jar = Jar, specify)] +#[salsa::tracked(specify)] fn tracked_fn_extra<'db>(_db: &'db dyn Db, _input: MyTracked<'db>) -> u32 { 0 } -#[salsa::db(Jar)] +#[salsa::db] #[derive(Default)] struct Database { storage: salsa::Storage, } +#[salsa::db] impl salsa::Database for Database {} +#[salsa::db] impl Db for Database {} #[test] -#[should_panic] +#[should_panic( + expected = "can only use `specify` on salsa structs created during the current tracked fn" +)] fn execute_when_specified() { let mut db = Database::default(); let input = MyInput::new(&db, 22);