1
Fork 0

Move methods from Map to TyCtxt, part 2.

Continuing the work started in #136466.

Every method gains a `hir_` prefix, though for the ones that already
have a `par_` or `try_par_` prefix I added the `hir_` after that.
This commit is contained in:
Nicholas Nethercote 2025-02-17 14:17:57 +11:00
parent ce36a966c7
commit fd7b4bf4e1
108 changed files with 314 additions and 346 deletions

View file

@ -16,7 +16,7 @@ pub(super) struct CheckForceInline;
impl<'tcx> MirLint<'tcx> for CheckForceInline {
fn run_lint(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
let def_id = body.source.def_id();
if !tcx.hir().body_owner_kind(def_id).is_fn_or_closure() || !def_id.is_local() {
if !tcx.hir_body_owner_kind(def_id).is_fn_or_closure() || !def_id.is_local() {
return;
}
let InlineAttr::Force { attr_span, .. } = tcx.codegen_fn_attrs(def_id).inline else {

View file

@ -113,7 +113,7 @@ fn required_panic_strategy(tcx: TyCtxt<'_>, _: LocalCrate) -> Option<PanicStrate
return Some(PanicStrategy::Abort);
}
for def_id in tcx.hir().body_owners() {
for def_id in tcx.hir_body_owners() {
if tcx.has_ffi_unwind_calls(def_id) {
// Given that this crate is compiled in `-C panic=unwind`, the `AbortUnwindingCalls`
// MIR pass will not be run on FFI-unwind call sites, therefore a foreign exception

View file

@ -463,7 +463,7 @@ fn inline<'tcx, T: Inliner<'tcx>>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> b
let def_id = body.source.def_id();
// Only do inlining into fn bodies.
if !tcx.hir().body_owner_kind(def_id).is_fn_or_closure() {
if !tcx.hir_body_owner_kind(def_id).is_fn_or_closure() {
return false;
}

View file

@ -36,7 +36,7 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify {
typing_env: body.typing_env(tcx),
};
let preserve_ub_checks =
attr::contains_name(tcx.hir().krate_attrs(), sym::rustc_preserve_ub_checks);
attr::contains_name(tcx.hir_krate_attrs(), sym::rustc_preserve_ub_checks);
for block in body.basic_blocks.as_mut() {
for statement in block.statements.iter_mut() {
match statement.kind {

View file

@ -314,11 +314,11 @@ fn is_mir_available(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
/// MIR associated with them.
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
// All body-owners have MIR associated with them.
let mut set: FxIndexSet<_> = tcx.hir().body_owners().collect();
let mut set: FxIndexSet<_> = tcx.hir_body_owners().collect();
// Coroutine-closures (e.g. async closures) have an additional by-move MIR
// body that isn't in the HIR.
for body_owner in tcx.hir().body_owners() {
for body_owner in tcx.hir_body_owners() {
if let DefKind::Closure = tcx.def_kind(body_owner)
&& tcx.needs_coroutine_by_move_body_def_id(body_owner.to_def_id())
{
@ -470,7 +470,7 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
}
let body = tcx.mir_drops_elaborated_and_const_checked(def);
let body = match tcx.hir().body_const_context(def) {
let body = match tcx.hir_body_const_context(def) {
// consts and statics do not have `optimized_mir`, so we can steal the body instead of
// cloning it.
Some(hir::ConstContext::Const { .. } | hir::ConstContext::Static(_)) => body.steal(),
@ -729,7 +729,7 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> {
return shim::build_adt_ctor(tcx, did.to_def_id());
}
match tcx.hir().body_const_context(did) {
match tcx.hir_body_const_context(did) {
// Run the `mir_for_ctfe` query, which depends on `mir_drops_elaborated_and_const_checked`
// which we are going to steal below. Thus we need to run `mir_for_ctfe` first, so it
// computes and caches its result.