1
Fork 0

Move methods from Map to TyCtxt, part 3.

Continuing the work from #137162.

Every method gains a `hir_` prefix.
This commit is contained in:
Nicholas Nethercote 2025-02-21 07:54:35 +11:00
parent 43c2b0086a
commit 806be25fc9
105 changed files with 243 additions and 273 deletions

View file

@ -48,7 +48,7 @@ fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>)
match impl_item.kind {
hir::ImplItemKind::Const(..) => Target::AssocConst,
hir::ImplItemKind::Fn(..) => {
let parent_def_id = tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
let parent_def_id = tcx.hir_get_parent_item(impl_item.hir_id()).def_id;
let containing_item = tcx.hir().expect_item(parent_def_id);
let containing_impl_is_for_trait = match &containing_item.kind {
hir::ItemKind::Impl(impl_) => impl_.of_trait.is_some(),
@ -868,7 +868,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
let span = meta.span();
if let Some(location) = match target {
Target::AssocTy => {
let parent_def_id = self.tcx.hir().get_parent_item(hir_id).def_id;
let parent_def_id = self.tcx.hir_get_parent_item(hir_id).def_id;
let containing_item = self.tcx.hir().expect_item(parent_def_id);
if Target::from_item(containing_item) == Target::Impl {
Some("type alias in implementation block")
@ -877,7 +877,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
}
Target::AssocConst => {
let parent_def_id = self.tcx.hir().get_parent_item(hir_id).def_id;
let parent_def_id = self.tcx.hir_get_parent_item(hir_id).def_id;
let containing_item = self.tcx.hir().expect_item(parent_def_id);
// We can't link to trait impl's consts.
let err = "associated constant in trait implementation block";
@ -1161,7 +1161,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
// insert a bang between `#` and `[...`
let bang_span = attr.span.lo() + BytePos(1);
let sugg = (attr.style == AttrStyle::Outer
&& self.tcx.hir().get_parent_item(hir_id) == CRATE_OWNER_ID)
&& self.tcx.hir_get_parent_item(hir_id) == CRATE_OWNER_ID)
.then_some(errors::AttrCrateLevelOnlySugg {
attr: attr.span.with_lo(bang_span).with_hi(bang_span),
});
@ -1449,7 +1449,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
// `#[must_use]` can be applied to a trait method definition with a default body
if let Target::Method(MethodKind::Trait { body: true }) = target
&& let parent_def_id = self.tcx.hir().get_parent_item(hir_id).def_id
&& let parent_def_id = self.tcx.hir_get_parent_item(hir_id).def_id
&& let containing_item = self.tcx.hir().expect_item(parent_def_id)
&& let hir::ItemKind::Trait(..) = containing_item.kind
{
@ -2580,7 +2580,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
..
})
);
let parent_did = self.tcx.hir().get_parent_item(hir_id).to_def_id();
let parent_did = self.tcx.hir_get_parent_item(hir_id).to_def_id();
let parent_span = self.tcx.def_span(parent_did);
let parent_force_inline_attr =
self.tcx.get_attr(parent_did, sym::rustc_force_inline);

View file

@ -1623,7 +1623,7 @@ impl<'tcx> Liveness<'_, 'tcx> {
&& let hir::Node::Pat(pat) = self.ir.tcx.hir_node(var_hid)
&& let hir::Node::Param(hir::Param { ty_span, .. }) =
self.ir.tcx.parent_hir_node(pat.hir_id)
&& let item_id = self.ir.tcx.hir().get_parent_item(pat.hir_id)
&& let item_id = self.ir.tcx.hir_get_parent_item(pat.hir_id)
&& let item = self.ir.tcx.hir_owner_node(item_id)
&& let Some(fn_decl) = item.fn_decl()
&& let hir::PatKind::Binding(hir::BindingMode::MUT, _hir_id, ident, _) = pat.kind

View file

@ -645,7 +645,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
}
fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) {
let impl_def_id = self.tcx.hir().get_parent_item(ii.hir_id());
let impl_def_id = self.tcx.hir_get_parent_item(ii.hir_id());
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
self.check_missing_stability(ii.owner_id.def_id, ii.span);
self.check_missing_const_stability(ii.owner_id.def_id, ii.span);