rustc: hir().local_def_id_to_hir_id()
-> tcx.local_def_id_to_hir_id()
cleanup
This commit is contained in:
parent
9529a5d265
commit
c697927f44
110 changed files with 189 additions and 199 deletions
|
@ -116,7 +116,7 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
|
|||
|
||||
let parent_id = parent_id.map_or(CRATE_OWNER_ID, |local_def_index| {
|
||||
let def_id = LocalDefId { local_def_index };
|
||||
self.map.local_def_id_to_hir_id(def_id).owner
|
||||
self.map.tcx.local_def_id_to_hir_id(def_id).owner
|
||||
});
|
||||
self.current_id = HirId::make_owner(parent_id.def_id);
|
||||
|
||||
|
@ -168,14 +168,9 @@ impl<'hir> Map<'hir> {
|
|||
self.tcx.definitions_untracked().def_path_hash(def_id)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn local_def_id_to_hir_id(self, def_id: impl Into<LocalDefId>) -> HirId {
|
||||
self.tcx.local_def_id_to_hir_id(def_id.into())
|
||||
}
|
||||
|
||||
/// Do not call this function directly. The query should be called.
|
||||
pub(super) fn def_kind(self, local_def_id: LocalDefId) -> DefKind {
|
||||
let hir_id = self.local_def_id_to_hir_id(local_def_id);
|
||||
let hir_id = self.tcx.local_def_id_to_hir_id(local_def_id);
|
||||
let node = match self.find(hir_id) {
|
||||
Some(node) => node,
|
||||
None => match self.def_key(local_def_id).disambiguated_data.data {
|
||||
|
@ -415,7 +410,7 @@ impl<'hir> Map<'hir> {
|
|||
#[track_caller]
|
||||
pub fn body_owned_by(self, id: LocalDefId) -> BodyId {
|
||||
self.maybe_body_owned_by(id).unwrap_or_else(|| {
|
||||
let hir_id = self.local_def_id_to_hir_id(id);
|
||||
let hir_id = self.tcx.local_def_id_to_hir_id(id);
|
||||
span_bug!(
|
||||
self.span(hir_id),
|
||||
"body_owned_by: {} has no associated body",
|
||||
|
|
|
@ -166,7 +166,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
providers.hir_owner_parent = |tcx, id| {
|
||||
// Accessing the local_parent is ok since its value is hashed as part of `id`'s DefPathHash.
|
||||
tcx.opt_local_parent(id.def_id).map_or(CRATE_HIR_ID, |parent| {
|
||||
let mut parent_hir_id = tcx.hir().local_def_id_to_hir_id(parent);
|
||||
let mut parent_hir_id = tcx.local_def_id_to_hir_id(parent);
|
||||
parent_hir_id.local_id =
|
||||
tcx.hir_crate(()).owners[parent_hir_id.owner.def_id].unwrap().parenting[&id.def_id];
|
||||
parent_hir_id
|
||||
|
@ -176,16 +176,16 @@ pub fn provide(providers: &mut Providers) {
|
|||
tcx.hir_crate(()).owners[id.def_id].as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs)
|
||||
};
|
||||
providers.def_span = |tcx, 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.hir().opt_span(hir_id).unwrap_or(DUMMY_SP)
|
||||
};
|
||||
providers.def_ident_span = |tcx, 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.hir().opt_ident_span(hir_id)
|
||||
};
|
||||
providers.fn_arg_names = |tcx, def_id| {
|
||||
let hir = tcx.hir();
|
||||
let hir_id = hir.local_def_id_to_hir_id(def_id);
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
if let Some(body_id) = hir.maybe_body_owned_by(def_id) {
|
||||
tcx.arena.alloc_from_iter(hir.body_param_names(body_id))
|
||||
} else if let Node::TraitItem(&TraitItem {
|
||||
|
|
|
@ -110,7 +110,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let Some(local_def_id) = ct.def.as_local() else { return };
|
||||
self.struct_span_lint_hir(
|
||||
lint::builtin::CONST_EVALUATABLE_UNCHECKED,
|
||||
self.hir().local_def_id_to_hir_id(local_def_id),
|
||||
self.local_def_id_to_hir_id(local_def_id),
|
||||
self.def_span(ct.def),
|
||||
"cannot use constants which depend on generic parameters in types",
|
||||
|err| err,
|
||||
|
|
|
@ -72,7 +72,7 @@ impl OverlapMode {
|
|||
.as_local()
|
||||
.into_iter()
|
||||
.flat_map(|local_def_id| {
|
||||
tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(local_def_id))
|
||||
tcx.hir().attrs(tcx.local_def_id_to_hir_id(local_def_id))
|
||||
})
|
||||
.find(|attr| attr.has_name(sym::rustc_strict_coherence))
|
||||
.map(|attr| attr.span);
|
||||
|
|
|
@ -262,7 +262,7 @@ fn closure_typeinfo<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> ClosureTypeInfo
|
|||
let user_provided_sig = typeck_results.user_provided_sigs[&def];
|
||||
let captures = typeck_results.closure_min_captures_flattened(def);
|
||||
let captures = tcx.arena.alloc_from_iter(captures);
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def);
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def);
|
||||
let kind_origin = typeck_results.closure_kind_origins().get(hir_id);
|
||||
ClosureTypeInfo { user_provided_sig, captures, kind_origin }
|
||||
}
|
||||
|
|
|
@ -1131,7 +1131,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self,
|
||||
scope_def_id: LocalDefId,
|
||||
) -> Vec<&'tcx hir::Ty<'tcx>> {
|
||||
let hir_id = self.hir().local_def_id_to_hir_id(scope_def_id);
|
||||
let hir_id = self.local_def_id_to_hir_id(scope_def_id);
|
||||
let Some(hir::FnDecl { output: hir::FnRetTy::Return(hir_output), .. }) =
|
||||
self.hir().fn_decl_by_hir_id(hir_id)
|
||||
else {
|
||||
|
@ -1150,7 +1150,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self,
|
||||
scope_def_id: LocalDefId,
|
||||
) -> Option<(Vec<&'tcx hir::Ty<'tcx>>, Span, Option<Span>)> {
|
||||
let hir_id = self.hir().local_def_id_to_hir_id(scope_def_id);
|
||||
let hir_id = self.local_def_id_to_hir_id(scope_def_id);
|
||||
let mut v = TraitObjectVisitor(vec![], self.hir());
|
||||
// when the return type is a type alias
|
||||
if let Some(hir::FnDecl { output: hir::FnRetTy::Return(hir_output), .. }) = self.hir().fn_decl_by_hir_id(hir_id)
|
||||
|
|
|
@ -2273,7 +2273,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
// FIXME(@lcnr): Remove this function.
|
||||
pub fn get_attrs_unchecked(self, did: DefId) -> &'tcx [ast::Attribute] {
|
||||
if let Some(did) = did.as_local() {
|
||||
self.hir().attrs(self.hir().local_def_id_to_hir_id(did))
|
||||
self.hir().attrs(self.local_def_id_to_hir_id(did))
|
||||
} else {
|
||||
self.item_attrs(did)
|
||||
}
|
||||
|
@ -2288,7 +2288,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let did: DefId = did.into();
|
||||
let filter_fn = move |a: &&ast::Attribute| a.has_name(attr);
|
||||
if let Some(did) = did.as_local() {
|
||||
self.hir().attrs(self.hir().local_def_id_to_hir_id(did)).iter().filter(filter_fn)
|
||||
self.hir().attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn)
|
||||
} else if cfg!(debug_assertions) && rustc_feature::is_builtin_only_local(attr) {
|
||||
bug!("tried to access the `only_local` attribute `{}` from an extern crate", attr);
|
||||
} else {
|
||||
|
@ -2306,7 +2306,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
{
|
||||
let filter_fn = move |a: &&ast::Attribute| a.path_matches(attr);
|
||||
if let Some(did) = did.as_local() {
|
||||
self.hir().attrs(self.hir().local_def_id_to_hir_id(did)).iter().filter(filter_fn)
|
||||
self.hir().attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn)
|
||||
} else {
|
||||
self.item_attrs(did).iter().filter(filter_fn)
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ pub fn recursive_type_error(
|
|||
let (_, field_id) = item_and_field_ids[i];
|
||||
let (next_item_id, _) = item_and_field_ids[(i + 1) % cycle_len];
|
||||
// Find the span(s) that contain the next item in the cycle
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(field_id);
|
||||
let hir_id = tcx.local_def_id_to_hir_id(field_id);
|
||||
let hir::Node::Field(field) = tcx.hir().get(hir_id) else { bug!("expected field") };
|
||||
let mut found = Vec::new();
|
||||
find_item_ty_spans(tcx, field.ty, next_item_id, &mut found, representable_ids);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue