about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-01-12 13:59:30 +0000
committerbors <bors@rust-lang.org>2023-01-12 13:59:30 +0000
commit222d1ff68d5bfe1dc2d7f3f0c42811fe12964af9 (patch)
tree1a75241d0b3c0600dcb76bd03d07d9fad8f31062 /compiler/rustc_data_structures/src
parent606c3907251397a42e23d3e60de31be9d32525d5 (diff)
parent58782a8842bdd74e3304092251a1d06e5b6b550b (diff)
downloadrust-222d1ff68d5bfe1dc2d7f3f0c42811fe12964af9.tar.gz
rust-222d1ff68d5bfe1dc2d7f3f0c42811fe12964af9.zip
Auto merge of #105603 - oli-obk:non_repeatable_queries, r=petrochenkov
Harden the pre-tyctxt query system against accidental recomputation

While the current compiler has no issues where we `take` and then compute the query again, in https://github.com/rust-lang/rust/pull/105462 I accidentally introduced such a case.

I also took the opportunity to remove `peek_mut`, which is only ever used for `global_tcx` to then invoke `enter`. I added an `enter` method directly on the query.
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/steal.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs
index a3ece655047..9a0fd52677d 100644
--- a/compiler/rustc_data_structures/src/steal.rs
+++ b/compiler/rustc_data_structures/src/steal.rs
@@ -41,6 +41,11 @@ impl<T> Steal<T> {
     }
 
     #[track_caller]
+    pub fn get_mut(&mut self) -> &mut T {
+        self.value.get_mut().as_mut().expect("attempt to read from stolen value")
+    }
+
+    #[track_caller]
     pub fn steal(&self) -> T {
         let value_ref = &mut *self.value.try_write().expect("stealing value which is locked");
         let value = value_ref.take();