diff --git a/components/salsa-2022/src/function/specify.rs b/components/salsa-2022/src/function/specify.rs index 9195805e..047e2849 100644 --- a/components/salsa-2022/src/function/specify.rs +++ b/components/salsa-2022/src/function/specify.rs @@ -27,7 +27,7 @@ where }; let entity_index = key.database_key_index(db); - if !runtime.was_entity_created(entity_index) { + if !runtime.is_output_of_active_query(entity_index) { panic!("can only use `set` on entities created during current query"); } diff --git a/components/salsa-2022/src/runtime.rs b/components/salsa-2022/src/runtime.rs index 3c1500a3..e83a54b8 100644 --- a/components/salsa-2022/src/runtime.rs +++ b/components/salsa-2022/src/runtime.rs @@ -144,15 +144,15 @@ impl Runtime { } } - /// Adds `entity` to the lits of entities created by the current query. - /// Panics if `entity` was already added. - pub(crate) fn add_entity_created(&self, entity: DatabaseKeyIndex) { - self.local_state.add_entity_created(entity); + /// Adds `key` to the list of output created by the current query + /// (if not already present). + pub(crate) fn add_output(&self, key: DatabaseKeyIndex) { + self.local_state.add_output(key); } - /// Check whether `entity` is contained the list of entities created by the current query. - pub(super) fn was_entity_created(&self, entity: DatabaseKeyIndex) -> bool { - self.local_state.was_entity_created(entity) + /// Check whether `entity` is contained the list of outputs written by the current query. + pub(super) fn is_output_of_active_query(&self, entity: DatabaseKeyIndex) -> bool { + self.local_state.is_output(entity) } /// Called when the active queries creates an index from the diff --git a/components/salsa-2022/src/runtime/active_query.rs b/components/salsa-2022/src/runtime/active_query.rs index 4ef9c889..04337858 100644 --- a/components/salsa-2022/src/runtime/active_query.rs +++ b/components/salsa-2022/src/runtime/active_query.rs @@ -86,8 +86,7 @@ impl ActiveQuery { /// Adds a key to our list of outputs. pub(super) fn add_output(&mut self, key: DatabaseKeyIndex) { - let is_new = self.outputs.insert(key); - assert!(is_new); + self.outputs.insert(key); } /// True if the given key was output by this query. diff --git a/components/salsa-2022/src/runtime/local_state.rs b/components/salsa-2022/src/runtime/local_state.rs index ab47a2b7..6c5b7730 100644 --- a/components/salsa-2022/src/runtime/local_state.rs +++ b/components/salsa-2022/src/runtime/local_state.rs @@ -115,7 +115,7 @@ impl LocalState { }) } - pub(super) fn add_entity_created(&self, entity: DatabaseKeyIndex) { + pub(super) fn add_output(&self, entity: DatabaseKeyIndex) { self.with_query_stack(|stack| { if let Some(top_query) = stack.last_mut() { top_query.add_output(entity) @@ -123,7 +123,7 @@ impl LocalState { }) } - pub(super) fn was_entity_created(&self, entity: DatabaseKeyIndex) -> bool { + pub(super) fn is_output(&self, entity: DatabaseKeyIndex) -> bool { self.with_query_stack(|stack| { if let Some(top_query) = stack.last_mut() { top_query.is_output(entity) diff --git a/components/salsa-2022/src/tracked_struct.rs b/components/salsa-2022/src/tracked_struct.rs index 39d19548..0b326775 100644 --- a/components/salsa-2022/src/tracked_struct.rs +++ b/components/salsa-2022/src/tracked_struct.rs @@ -76,7 +76,7 @@ where data, }; let result = self.interned.intern(runtime, entity_key); - runtime.add_entity_created(self.database_key_index(result)); + runtime.add_output(self.database_key_index(result)); result }