mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-13 08:48:19 +00:00
wip
This commit is contained in:
parent
185c86bb5a
commit
c9426d2e4f
2 changed files with 11 additions and 15 deletions
|
@ -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 = <C::Input<'db>>::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
|
||||
|
|
|
@ -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<Jar> {}
|
||||
#[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<Self>,
|
||||
}
|
||||
|
||||
#[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);
|
||||
|
|
Loading…
Reference in a new issue