Skip to content

Commit 5fdb9e4

Browse files
committed
no ensure
1 parent 78a46ef commit 5fdb9e4

File tree

1 file changed

+6
-3
lines changed
  • compiler/rustc_mir_build/src/build

1 file changed

+6
-3
lines changed

compiler/rustc_mir_build/src/build/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,18 @@ fn mir_build(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> Body<'_
4444
let body_owner_kind = tcx.hir().body_owner_kind(id);
4545
let typeck_results = tcx.typeck_opt_const_arg(def);
4646

47-
// Ensure unsafeck is ran before we steal the THIR.
47+
// Ensure unsafeck and abstract const building is ran before we steal the THIR.
48+
// We can't use `ensure()` for `thir_abstract_const` as it doesn't compute the query
49+
// if inputs are green. This can cause ICEs when calling `thir_abstract_const` after
50+
// THIR has been stolen if we haven't computed this query yet.
4851
match def {
4952
ty::WithOptConstParam { did, const_param_did: Some(const_param_did) } => {
5053
tcx.ensure().thir_check_unsafety_for_const_arg((did, const_param_did));
51-
tcx.ensure().thir_abstract_const_of_const_arg((did, const_param_did));
54+
drop(tcx.thir_abstract_const_of_const_arg((did, const_param_did)));
5255
}
5356
ty::WithOptConstParam { did, const_param_did: None } => {
5457
tcx.ensure().thir_check_unsafety(did);
55-
tcx.ensure().thir_abstract_const(did);
58+
drop(tcx.thir_abstract_const(did));
5659
}
5760
}
5861

0 commit comments

Comments
 (0)