rustc: hir().local_def_id_to_hir_id() -> tcx.local_def_id_to_hir_id() cleanup
This commit is contained in:
@@ -14,7 +14,7 @@ use rustc_span::{sym, Span};
|
||||
pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
||||
use rustc_hir::*;
|
||||
|
||||
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 node = tcx.hir().get(hir_id);
|
||||
let parent_def_id = match node {
|
||||
|
||||
@@ -105,7 +105,7 @@ pub(super) fn explicit_item_bounds(
|
||||
None => {}
|
||||
}
|
||||
|
||||
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 bounds = match tcx.hir().get(hir_id) {
|
||||
hir::Node::TraitItem(hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Type(bounds, _),
|
||||
|
||||
@@ -134,7 +134,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
||||
None => {}
|
||||
}
|
||||
|
||||
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 node = tcx.hir().get(hir_id);
|
||||
|
||||
let mut is_trait = None;
|
||||
@@ -412,7 +412,7 @@ fn const_evaluatable_predicates_of(
|
||||
}
|
||||
}
|
||||
|
||||
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 node = tcx.hir().get(hir_id);
|
||||
|
||||
let mut collector = ConstCollector { tcx, preds: FxIndexSet::default() };
|
||||
@@ -503,7 +503,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
|
||||
}
|
||||
} else {
|
||||
if matches!(def_kind, DefKind::AnonConst) && tcx.features().generic_const_exprs {
|
||||
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 parent_def_id = tcx.hir().get_parent_item(hir_id);
|
||||
|
||||
if let Some(defaulted_param_def_id) =
|
||||
@@ -571,7 +571,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
|
||||
// To fix this, we call `explicit_predicates_of` directly on `foo`, the parent's parent.
|
||||
|
||||
// In the above example this is `foo::{opaque#0}` or `impl Iterator`
|
||||
let parent_hir_id = tcx.hir().local_def_id_to_hir_id(parent_def_id.def_id);
|
||||
let parent_hir_id = tcx.local_def_id_to_hir_id(parent_def_id.def_id);
|
||||
|
||||
// In the above example this is the function `foo`
|
||||
let item_def_id = tcx.hir().get_parent_item(parent_hir_id);
|
||||
@@ -631,7 +631,7 @@ pub(super) fn implied_predicates_with_filter(
|
||||
return tcx.super_predicates_of(trait_def_id);
|
||||
};
|
||||
|
||||
let trait_hir_id = tcx.hir().local_def_id_to_hir_id(trait_def_id);
|
||||
let trait_hir_id = tcx.local_def_id_to_hir_id(trait_def_id);
|
||||
|
||||
let Node::Item(item) = tcx.hir().get(trait_hir_id) else {
|
||||
bug!("trait_node_id {} is not an item", trait_hir_id);
|
||||
@@ -691,7 +691,7 @@ pub(super) fn type_param_predicates(
|
||||
// written inline like `<T: Foo>` or in a where-clause like
|
||||
// `where T: Foo`.
|
||||
|
||||
let param_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let param_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
let param_owner = tcx.hir().ty_param_owner(def_id);
|
||||
let generics = tcx.generics_of(param_owner);
|
||||
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
|
||||
@@ -712,7 +712,7 @@ pub(super) fn type_param_predicates(
|
||||
.unwrap_or_default();
|
||||
let mut extend = None;
|
||||
|
||||
let item_hir_id = tcx.hir().local_def_id_to_hir_id(item_def_id);
|
||||
let item_hir_id = tcx.local_def_id_to_hir_id(item_def_id);
|
||||
let ast_generics = match tcx.hir().get(item_hir_id) {
|
||||
Node::TraitItem(item) => item.generics,
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ fn late_arg_as_bound_arg<'tcx>(
|
||||
) -> ty::BoundVariableKind {
|
||||
match arg {
|
||||
ResolvedArg::LateBound(_, _, def_id) => {
|
||||
let name = tcx.hir().name(tcx.hir().local_def_id_to_hir_id(def_id.expect_local()));
|
||||
let name = tcx.hir().name(tcx.local_def_id_to_hir_id(def_id.expect_local()));
|
||||
match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(*def_id, name))
|
||||
@@ -733,7 +733,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
||||
let def = self.map.defs.get(&lifetime.hir_id).cloned();
|
||||
let Some(ResolvedArg::LateBound(_, _, def_id)) = def else { continue };
|
||||
let Some(def_id) = def_id.as_local() else { continue };
|
||||
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
let hir_id = self.tcx.local_def_id_to_hir_id(def_id);
|
||||
// Ensure that the parent of the def is an item, not HRTB
|
||||
let parent_id = self.tcx.hir().parent_id(hir_id);
|
||||
if !parent_id.is_owner() {
|
||||
|
||||
@@ -18,7 +18,7 @@ mod opaque;
|
||||
fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
||||
use hir::*;
|
||||
use rustc_middle::ty::Ty;
|
||||
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 Node::AnonConst(_) = tcx.hir().get(hir_id) else { panic!() };
|
||||
|
||||
@@ -350,7 +350,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
||||
}
|
||||
}
|
||||
|
||||
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 icx = ItemCtxt::new(tcx, def_id);
|
||||
|
||||
@@ -517,7 +517,7 @@ pub(super) fn type_of_opaque(
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
use rustc_hir::*;
|
||||
|
||||
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);
|
||||
Ok(ty::EarlyBinder::bind(match tcx.hir().get(hir_id) {
|
||||
Node::Item(item) => match item.kind {
|
||||
ItemKind::OpaqueTy(OpaqueTy {
|
||||
|
||||
@@ -41,7 +41,7 @@ pub fn test_opaque_hidden_types(tcx: TyCtxt<'_>) {
|
||||
/// ```
|
||||
#[instrument(skip(tcx), level = "debug")]
|
||||
pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
|
||||
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 scope = tcx.hir().get_defining_scope(hir_id);
|
||||
let mut locator = TaitConstraintLocator { def_id, tcx, found: None, typeck_types: vec![] };
|
||||
|
||||
@@ -278,7 +278,7 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
|
||||
|
||||
let mir_opaque_ty = tcx.mir_borrowck(owner_def_id).concrete_opaque_types.get(&def_id).copied();
|
||||
if let Some(mir_opaque_ty) = mir_opaque_ty {
|
||||
let scope = tcx.hir().local_def_id_to_hir_id(owner_def_id);
|
||||
let scope = tcx.local_def_id_to_hir_id(owner_def_id);
|
||||
debug!(?scope);
|
||||
let mut locator = RpitConstraintChecker { def_id, tcx, found: mir_opaque_ty };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user