1
Fork 0

rustc: hir().local_def_id_to_hir_id() -> tcx.local_def_id_to_hir_id() cleanup

This commit is contained in:
Vadim Petrochenkov 2023-11-24 19:28:19 +03:00
parent 9529a5d265
commit c697927f44
110 changed files with 189 additions and 199 deletions

View file

@ -451,7 +451,7 @@ fn construct_fn<'tcx>(
fn_sig: ty::FnSig<'tcx>,
) -> Body<'tcx> {
let span = tcx.def_span(fn_def);
let fn_id = tcx.hir().local_def_id_to_hir_id(fn_def);
let fn_id = tcx.local_def_id_to_hir_id(fn_def);
let coroutine_kind = tcx.coroutine_kind(fn_def);
// The representation of thir for `-Zunpretty=thir-tree` relies on
@ -569,7 +569,7 @@ fn construct_const<'a, 'tcx>(
expr: ExprId,
const_ty: Ty<'tcx>,
) -> Body<'tcx> {
let hir_id = tcx.hir().local_def_id_to_hir_id(def);
let hir_id = tcx.local_def_id_to_hir_id(def);
// Figure out what primary body this item has.
let (span, const_ty_span) = match tcx.hir().get(hir_id) {
@ -622,7 +622,7 @@ fn construct_const<'a, 'tcx>(
/// with type errors, but normal MIR construction can't handle that in general.
fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -> Body<'_> {
let span = tcx.def_span(def_id);
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let coroutine_kind = tcx.coroutine_kind(def_id);
let (inputs, output, yield_ty) = match tcx.def_kind(def_id) {

View file

@ -138,7 +138,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
// Runs all other queries that depend on THIR.
self.tcx.ensure_with_value().mir_built(def);
let inner_thir = &inner_thir.steal();
let hir_context = self.tcx.hir().local_def_id_to_hir_id(def);
let hir_context = self.tcx.local_def_id_to_hir_id(def);
let safety_context = mem::replace(&mut self.safety_context, SafetyContext::Safe);
let mut inner_visitor = UnsafetyVisitor {
thir: inner_thir,
@ -859,7 +859,7 @@ pub fn thir_check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
return;
}
let hir_id = tcx.hir().local_def_id_to_hir_id(def);
let hir_id = tcx.local_def_id_to_hir_id(def);
let safety_context = tcx.hir().fn_sig_by_hir_id(hir_id).map_or(SafetyContext::Safe, |fn_sig| {
if fn_sig.header.unsafety == hir::Unsafety::Unsafe {
SafetyContext::UnsafeFn

View file

@ -52,7 +52,7 @@ fn check_recursion<'tcx>(
vis.reachable_recursive_calls.sort();
let sp = tcx.def_span(def_id);
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let hir_id = tcx.local_def_id_to_hir_id(def_id);
tcx.emit_spanned_lint(
UNCONDITIONAL_RECURSION,
hir_id,

View file

@ -899,7 +899,7 @@ impl<'tcx> Cx<'tcx> {
}
Res::Def(DefKind::ConstParam, def_id) => {
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
let hir_id = self.tcx.local_def_id_to_hir_id(def_id.expect_local());
let generics = self.tcx.generics_of(hir_id.owner);
let index = generics.param_def_id_to_index[&def_id];
let name = self.tcx.hir().name(hir_id);

View file

@ -29,7 +29,7 @@ pub(crate) fn thir_body(
}
let expr = cx.mirror_expr(body.value);
let owner_id = hir.local_def_id_to_hir_id(owner_def);
let owner_id = tcx.local_def_id_to_hir_id(owner_def);
if let Some(fn_decl) = hir.fn_decl_by_hir_id(owner_id) {
let closure_env_param = cx.closure_env_param(owner_def, owner_id);
let explicit_params = cx.explicit_params(owner_id, fn_decl, body);
@ -72,7 +72,7 @@ impl<'tcx> Cx<'tcx> {
fn new(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Cx<'tcx> {
let typeck_results = tcx.typeck(def);
let hir = tcx.hir();
let hir_id = hir.local_def_id_to_hir_id(def);
let hir_id = tcx.local_def_id_to_hir_id(def);
let body_type = if hir.body_owner_kind(def).is_fn_or_closure() {
// fetch the fully liberated fn signature (that is, all bound

View file

@ -33,7 +33,7 @@ pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err
tcx,
thir: &*thir,
param_env: tcx.param_env(def_id),
lint_level: tcx.hir().local_def_id_to_hir_id(def_id),
lint_level: tcx.local_def_id_to_hir_id(def_id),
let_source: LetSource::None,
pattern_arena: &pattern_arena,
error: Ok(()),