1
Fork 0

Replace mir_built query with a hook and use mir_const everywhere instead

This commit is contained in:
Oli Scherer 2024-03-19 10:17:15 +00:00
parent 91b87c4f45
commit 36728f1cdd
15 changed files with 56 additions and 73 deletions

View file

@ -497,8 +497,8 @@ fn mir_unsafety_check_result(tcx: TyCtxt<'_>, def: LocalDefId) -> &UnsafetyCheck
debug!("unsafety_violations({:?})", def);
// N.B., this borrow is valid because all the consumers of
// `mir_built` force this.
let body = &tcx.mir_built(def).borrow();
// `mir_const` force this.
let body = &tcx.mir_const(def).borrow();
if body.is_custom_mir() || body.tainted_by_errors.is_some() {
return tcx.arena.alloc(UnsafetyCheckResult {

View file

@ -53,7 +53,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
return false;
}
let body = &*tcx.mir_built(local_def_id).borrow();
let body = &*tcx.mir_const(local_def_id).borrow();
let body_ty = tcx.type_of(def_id).skip_binder();
let body_abi = match body_ty.kind() {

View file

@ -288,10 +288,7 @@ fn mir_const(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal<Body<'_>> {
tcx.ensure_with_value().mir_unsafety_check_result(def);
}
// has_ffi_unwind_calls query uses the raw mir, so make sure it is run.
tcx.ensure_with_value().has_ffi_unwind_calls(def);
let mut body = tcx.mir_built(def).steal();
let mut body = tcx.build_mir(def);
pass_manager::dump_mir_for_phase_change(tcx, &body);
@ -339,6 +336,8 @@ fn mir_promoted(
| DefKind::AnonConst => tcx.mir_const_qualif(def),
_ => ConstQualifs::default(),
};
// has_ffi_unwind_calls query uses the raw mir, so make sure it is run.
tcx.ensure_with_value().has_ffi_unwind_calls(def);
let mut body = tcx.mir_const(def).steal();
if let Some(error_reported) = const_qualifs.tainted_by_errors {
body.tainted_by_errors = Some(error_reported);