about summary refs log tree commit diff
diff options
context:
space:
mode:
authorthe8472 <the8472@users.noreply.github.com>2021-09-21 22:54:03 +0200
committerGitHub <noreply@github.com>2021-09-21 22:54:03 +0200
commitecfdadcef9070951adf10e116ef768e7846b7e5c (patch)
treebc7905d39044ab3b07d3ebba843c4f769adcaaed
parenta8633ebcac7087444b6fcca67a0e55f969756e3c (diff)
parent5fdb9e4cf43899eaab1121a77e19b20fac1835cb (diff)
downloadrust-ecfdadcef9070951adf10e116ef768e7846b7e5c.tar.gz
rust-ecfdadcef9070951adf10e116ef768e7846b7e5c.zip
Rollup merge of #89113 - BoxyUwU:incr-comp-thir-act, r=lcnr
dont `.ensure()` the `thir_abstract_const` query call in `mir_build`

might fix an ICE seen in #89022 (note: this PR does not close that issue) about attempting to read stolen thir. I couldn't repro the ICE but this `.ensure` seems sus anyway.

r? `@lcnr`
-rw-r--r--compiler/rustc_mir_build/src/build/mod.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs
index 0ee740a6463..4108ad50470 100644
--- a/compiler/rustc_mir_build/src/build/mod.rs
+++ b/compiler/rustc_mir_build/src/build/mod.rs
@@ -44,15 +44,18 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
     let body_owner_kind = tcx.hir().body_owner_kind(id);
     let typeck_results = tcx.typeck_opt_const_arg(def);
 
-    // Ensure unsafeck is ran before we steal the THIR.
+    // Ensure unsafeck and abstract const building is ran before we steal the THIR.
+    // We can't use `ensure()` for `thir_abstract_const` as it doesn't compute the query
+    // if inputs are green. This can cause ICEs when calling `thir_abstract_const` after
+    // THIR has been stolen if we haven't computed this query yet.
     match def {
         ty::WithOptConstParam { did, const_param_did: Some(const_param_did) } => {
             tcx.ensure().thir_check_unsafety_for_const_arg((did, const_param_did));
-            tcx.ensure().thir_abstract_const_of_const_arg((did, const_param_did));
+            drop(tcx.thir_abstract_const_of_const_arg((did, const_param_did)));
         }
         ty::WithOptConstParam { did, const_param_did: None } => {
             tcx.ensure().thir_check_unsafety(did);
-            tcx.ensure().thir_abstract_const(did);
+            drop(tcx.thir_abstract_const(did));
         }
     }