Auto merge of #118500 - ZetaNumbers:tcx_hir_refactor, r=petrochenkov
Move some methods from `tcx.hir()` to `tcx` https://github.com/rust-lang/rust/pull/118256#issuecomment-1826442834 Renamed: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id
This commit is contained in:
commit
56d25ba5ea
122 changed files with 390 additions and 393 deletions
|
@ -24,7 +24,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
..
|
||||
}),
|
||||
..
|
||||
}) = tcx.hir().get_by_def_id(parent_id)
|
||||
}) = tcx.hir_node_by_def_id(parent_id)
|
||||
&& self_ty.hir_id == impl_self_ty.hir_id
|
||||
{
|
||||
if !of_trait_ref.trait_def_id().is_some_and(|def_id| def_id.is_local()) {
|
||||
|
|
|
@ -2715,7 +2715,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let hir = tcx.hir();
|
||||
|
||||
let hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), ident, .. }) =
|
||||
hir.get(fn_hir_id)
|
||||
tcx.hir_node(fn_hir_id)
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
|
|
|
@ -504,7 +504,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
|||
let origin = tcx.opaque_type_origin(id.owner_id.def_id);
|
||||
if let hir::OpaqueTyOrigin::FnReturn(fn_def_id)
|
||||
| hir::OpaqueTyOrigin::AsyncFn(fn_def_id) = origin
|
||||
&& let hir::Node::TraitItem(trait_item) = tcx.hir().get_by_def_id(fn_def_id)
|
||||
&& let hir::Node::TraitItem(trait_item) = tcx.hir_node_by_def_id(fn_def_id)
|
||||
&& let (_, hir::TraitFn::Required(..)) = trait_item.expect_fn()
|
||||
{
|
||||
// Skip opaques from RPIT in traits with no default body.
|
||||
|
@ -1173,7 +1173,7 @@ fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
|
|||
ty::VariantDiscr::Explicit(discr_def_id) => {
|
||||
// In the case the discriminant is both a duplicate and overflowed, let the user know
|
||||
if let hir::Node::AnonConst(expr) =
|
||||
tcx.hir().get_by_def_id(discr_def_id.expect_local())
|
||||
tcx.hir_node_by_def_id(discr_def_id.expect_local())
|
||||
&& let hir::ExprKind::Lit(lit) = &tcx.hir().body(expr.body).value.kind
|
||||
&& let rustc_ast::LitKind::Int(lit_value, _int_kind) = &lit.node
|
||||
&& *lit_value != dis.val
|
||||
|
|
|
@ -2181,7 +2181,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||
let impl_ty_span = if impl_ty.is_impl_trait_in_trait() {
|
||||
tcx.def_span(impl_ty_def_id)
|
||||
} else {
|
||||
match tcx.hir().get_by_def_id(impl_ty_def_id) {
|
||||
match tcx.hir_node_by_def_id(impl_ty_def_id) {
|
||||
hir::Node::TraitItem(hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Type(_, Some(ty)),
|
||||
..
|
||||
|
|
|
@ -278,7 +278,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
|
|||
}
|
||||
|
||||
let (span, impl_return_span, pre, post) =
|
||||
match tcx.hir().get_by_def_id(impl_m_def_id.expect_local()).fn_decl().unwrap().output {
|
||||
match tcx.hir_node_by_def_id(impl_m_def_id.expect_local()).fn_decl().unwrap().output {
|
||||
hir::FnRetTy::DefaultReturn(span) => (tcx.def_span(impl_m_def_id), span, "-> ", " "),
|
||||
hir::FnRetTy::Return(ty) => (ty.span, ty.span, "", ""),
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
return None;
|
||||
}
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
|
||||
match tcx.hir().find(hir_id) {
|
||||
match tcx.opt_hir_node(hir_id) {
|
||||
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })) => {
|
||||
generics.params.is_empty().not().then_some(generics.span)
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
return None;
|
||||
}
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
|
||||
match tcx.hir().find(hir_id) {
|
||||
match tcx.opt_hir_node(hir_id) {
|
||||
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })) => {
|
||||
Some(generics.where_clause_span)
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
return None;
|
||||
}
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
|
||||
match tcx.hir().find(hir_id) {
|
||||
match tcx.opt_hir_node(hir_id) {
|
||||
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(fn_sig, _, _), .. })) => {
|
||||
Some(fn_sig.decl.output.span())
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
|||
let start_t = tcx.type_of(start_def_id).instantiate_identity();
|
||||
match start_t.kind() {
|
||||
ty::FnDef(..) => {
|
||||
if let Some(Node::Item(it)) = tcx.hir().find(start_id) {
|
||||
if let Some(Node::Item(it)) = tcx.opt_hir_node(start_id) {
|
||||
if let hir::ItemKind::Fn(sig, generics, _) = &it.kind {
|
||||
let mut error = false;
|
||||
if !generics.params.is_empty() {
|
||||
|
|
|
@ -130,7 +130,7 @@ fn get_owner_return_paths(
|
|||
) -> Option<(LocalDefId, ReturnsVisitor<'_>)> {
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
let parent_id = tcx.hir().get_parent_item(hir_id).def_id;
|
||||
tcx.hir().find_by_def_id(parent_id).and_then(|node| node.body_id()).map(|body_id| {
|
||||
tcx.opt_hir_node_by_def_id(parent_id).and_then(|node| node.body_id()).map(|body_id| {
|
||||
let body = tcx.hir().body(body_id);
|
||||
let mut visitor = ReturnsVisitor::default();
|
||||
visitor.visit_body(body);
|
||||
|
|
|
@ -793,7 +793,7 @@ fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool {
|
|||
/// When this is done, suggest using `Self` instead.
|
||||
fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem<'_>) {
|
||||
let (trait_name, trait_def_id) =
|
||||
match tcx.hir().get_by_def_id(tcx.hir().get_parent_item(item.hir_id()).def_id) {
|
||||
match tcx.hir_node_by_def_id(tcx.hir().get_parent_item(item.hir_id()).def_id) {
|
||||
hir::Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Trait(..) => (item.ident, item.owner_id),
|
||||
_ => return,
|
||||
|
@ -1019,7 +1019,7 @@ fn check_type_defn<'tcx>(
|
|||
for field in &variant.fields {
|
||||
let field_id = field.did.expect_local();
|
||||
let hir::FieldDef { ty: hir_ty, .. } =
|
||||
tcx.hir().get_by_def_id(field_id).expect_field();
|
||||
tcx.hir_node_by_def_id(field_id).expect_field();
|
||||
let ty = wfcx.normalize(
|
||||
hir_ty.span,
|
||||
None,
|
||||
|
@ -1057,7 +1057,7 @@ fn check_type_defn<'tcx>(
|
|||
let last = idx == variant.fields.len() - 1;
|
||||
let field_id = field.did.expect_local();
|
||||
let hir::FieldDef { ty: hir_ty, .. } =
|
||||
tcx.hir().get_by_def_id(field_id).expect_field();
|
||||
tcx.hir_node_by_def_id(field_id).expect_field();
|
||||
let ty = wfcx.normalize(
|
||||
hir_ty.span,
|
||||
None,
|
||||
|
@ -1882,7 +1882,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
|
|||
// Match the existing behavior.
|
||||
if pred.is_global() && !pred.has_type_flags(TypeFlags::HAS_BINDER_VARS) {
|
||||
let pred = self.normalize(span, None, pred);
|
||||
let hir_node = tcx.hir().find_by_def_id(self.body_def_id);
|
||||
let hir_node = tcx.opt_hir_node_by_def_id(self.body_def_id);
|
||||
|
||||
// only use the span of the predicate clause (#90869)
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ pub(crate) fn placeholder_type_error_diag<'tcx>(
|
|||
|
||||
// Check if parent is const or static
|
||||
let parent_id = tcx.hir().parent_id(hir_ty.hir_id);
|
||||
let parent_node = tcx.hir().get(parent_id);
|
||||
let parent_node = tcx.hir_node(parent_id);
|
||||
|
||||
is_const_or_static = matches!(
|
||||
parent_node,
|
||||
|
@ -354,7 +354,7 @@ impl<'tcx> ItemCtxt<'tcx> {
|
|||
}
|
||||
|
||||
pub fn node(&self) -> hir::Node<'tcx> {
|
||||
self.tcx.hir().get(self.hir_id())
|
||||
self.tcx.hir_node(self.hir_id())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -835,8 +835,7 @@ fn convert_variant(
|
|||
fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
|
||||
use rustc_hir::*;
|
||||
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
let Node::Item(item) = tcx.hir().get(hir_id) else {
|
||||
let Node::Item(item) = tcx.hir_node_by_def_id(def_id) else {
|
||||
bug!();
|
||||
};
|
||||
|
||||
|
@ -1105,7 +1104,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<ty::PolyFnSig<
|
|||
|
||||
let icx = ItemCtxt::new(tcx, def_id);
|
||||
|
||||
let output = match tcx.hir().get(hir_id) {
|
||||
let output = match tcx.hir_node(hir_id) {
|
||||
TraitItem(hir::TraitItem {
|
||||
kind: TraitItemKind::Fn(sig, TraitFn::Provided(_)),
|
||||
generics,
|
||||
|
@ -1551,7 +1550,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
|||
}
|
||||
|
||||
fn coroutine_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<hir::CoroutineKind> {
|
||||
match tcx.hir().get_by_def_id(def_id) {
|
||||
match tcx.hir_node_by_def_id(def_id) {
|
||||
Node::Expr(&rustc_hir::Expr {
|
||||
kind: rustc_hir::ExprKind::Closure(&rustc_hir::Closure { body, .. }),
|
||||
..
|
||||
|
@ -1561,7 +1560,7 @@ fn coroutine_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<hir::CoroutineK
|
|||
}
|
||||
|
||||
fn is_type_alias_impl_trait<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool {
|
||||
match tcx.hir().get_by_def_id(def_id) {
|
||||
match tcx.hir_node_by_def_id(def_id) {
|
||||
Node::Item(hir::Item { kind: hir::ItemKind::OpaqueTy(opaque), .. }) => {
|
||||
matches!(opaque.origin, hir::OpaqueTyOrigin::TyAlias { .. })
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
|
||||
let node = tcx.hir().get(hir_id);
|
||||
let node = tcx.hir_node(hir_id);
|
||||
let parent_def_id = match node {
|
||||
Node::ImplItem(_)
|
||||
| Node::TraitItem(_)
|
||||
|
|
|
@ -83,7 +83,7 @@ pub(super) fn explicit_item_bounds(
|
|||
// RPITIT's bounds are the same as opaque type bounds, but with
|
||||
// a projection self type.
|
||||
Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => {
|
||||
let item = tcx.hir().get_by_def_id(opaque_def_id.expect_local()).expect_item();
|
||||
let item = tcx.hir_node_by_def_id(opaque_def_id.expect_local()).expect_item();
|
||||
let opaque_ty = item.expect_opaque_ty();
|
||||
return ty::EarlyBinder::bind(opaque_type_bounds(
|
||||
tcx,
|
||||
|
@ -102,8 +102,7 @@ pub(super) fn explicit_item_bounds(
|
|||
None => {}
|
||||
}
|
||||
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
let bounds = match tcx.hir().get(hir_id) {
|
||||
let bounds = match tcx.hir_node_by_def_id(def_id) {
|
||||
hir::Node::TraitItem(hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Type(bounds, _),
|
||||
span,
|
||||
|
|
|
@ -135,7 +135,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
}
|
||||
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
let node = tcx.hir().get(hir_id);
|
||||
let node = tcx.hir_node(hir_id);
|
||||
|
||||
let mut is_trait = None;
|
||||
let mut is_default_impl_trait = None;
|
||||
|
@ -337,7 +337,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
// and the duplicated parameter, to ensure that they do not get out of sync.
|
||||
if let Node::Item(&Item { kind: ItemKind::OpaqueTy(..), .. }) = node {
|
||||
let opaque_ty_id = tcx.hir().parent_id(hir_id);
|
||||
let opaque_ty_node = tcx.hir().get(opaque_ty_id);
|
||||
let opaque_ty_node = tcx.hir_node(opaque_ty_id);
|
||||
let Node::Ty(&Ty { kind: TyKind::OpaqueDef(_, lifetimes, _), .. }) = opaque_ty_node else {
|
||||
bug!("unexpected {opaque_ty_node:?}")
|
||||
};
|
||||
|
@ -413,7 +413,7 @@ fn const_evaluatable_predicates_of(
|
|||
}
|
||||
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
let node = tcx.hir().get(hir_id);
|
||||
let node = tcx.hir_node(hir_id);
|
||||
|
||||
let mut collector = ConstCollector { tcx, preds: FxIndexSet::default() };
|
||||
if let hir::Node::Item(item) = node
|
||||
|
@ -633,7 +633,7 @@ pub(super) fn implied_predicates_with_filter(
|
|||
|
||||
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 {
|
||||
let Node::Item(item) = tcx.hir_node(trait_hir_id) else {
|
||||
bug!("trait_node_id {} is not an item", trait_hir_id);
|
||||
};
|
||||
|
||||
|
@ -713,7 +713,7 @@ pub(super) fn type_param_predicates(
|
|||
let mut extend = None;
|
||||
|
||||
let item_hir_id = tcx.local_def_id_to_hir_id(item_def_id);
|
||||
let ast_generics = match tcx.hir().get(item_hir_id) {
|
||||
let ast_generics = match tcx.hir_node(item_hir_id) {
|
||||
Node::TraitItem(item) => item.generics,
|
||||
|
||||
Node::ImplItem(item) => item.generics,
|
||||
|
|
|
@ -748,7 +748,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
}
|
||||
if let hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::OpaqueTy { .. }, ..
|
||||
}) = self.tcx.hir().get(parent_id)
|
||||
}) = self.tcx.hir_node(parent_id)
|
||||
{
|
||||
let mut err = self.tcx.sess.struct_span_err(
|
||||
lifetime.ident.span,
|
||||
|
@ -1004,7 +1004,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
|
||||
fn object_lifetime_default(tcx: TyCtxt<'_>, param_def_id: LocalDefId) -> ObjectLifetimeDefault {
|
||||
debug_assert_eq!(tcx.def_kind(param_def_id), DefKind::TyParam);
|
||||
let hir::Node::GenericParam(param) = tcx.hir().get_by_def_id(param_def_id) else {
|
||||
let hir::Node::GenericParam(param) = tcx.hir_node_by_def_id(param_def_id) else {
|
||||
bug!("expected GenericParam for object_lifetime_default");
|
||||
};
|
||||
match param.source {
|
||||
|
@ -1305,7 +1305,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
def = ResolvedArg::Error(guar);
|
||||
} else if let Some(body_id) = outermost_body {
|
||||
let fn_id = self.tcx.hir().body_owner(body_id);
|
||||
match self.tcx.hir().get(fn_id) {
|
||||
match self.tcx.hir_node(fn_id) {
|
||||
Node::Item(hir::Item { owner_id, kind: hir::ItemKind::Fn(..), .. })
|
||||
| Node::TraitItem(hir::TraitItem {
|
||||
owner_id,
|
||||
|
@ -2122,7 +2122,7 @@ pub fn deny_non_region_late_bound(
|
|||
let mut first = true;
|
||||
|
||||
for (var, arg) in bound_vars {
|
||||
let Node::GenericParam(param) = tcx.hir().get_by_def_id(*var) else {
|
||||
let Node::GenericParam(param) = tcx.hir_node_by_def_id(*var) else {
|
||||
bug!();
|
||||
};
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
|||
use rustc_middle::ty::Ty;
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
|
||||
let Node::AnonConst(_) = tcx.hir().get(hir_id) else { panic!() };
|
||||
let Node::AnonConst(_) = tcx.hir_node(hir_id) else { panic!() };
|
||||
|
||||
let parent_node_id = tcx.hir().parent_id(hir_id);
|
||||
let parent_node = tcx.hir().get(parent_node_id);
|
||||
let parent_node = tcx.hir_node(parent_node_id);
|
||||
|
||||
let (generics, arg_idx) = match parent_node {
|
||||
// Easy case: arrays repeat expressions.
|
||||
|
@ -61,7 +61,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
|||
}
|
||||
|
||||
Node::TypeBinding(binding @ &TypeBinding { hir_id: binding_id, .. })
|
||||
if let Node::TraitRef(trait_ref) = tcx.hir().get(tcx.hir().parent_id(binding_id)) =>
|
||||
if let Node::TraitRef(trait_ref) = tcx.hir_node(tcx.hir().parent_id(binding_id)) =>
|
||||
{
|
||||
let Some(trait_def_id) = trait_ref.trait_def_id() else {
|
||||
return Ty::new_error_with_message(
|
||||
|
@ -354,7 +354,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
|||
|
||||
let icx = ItemCtxt::new(tcx, def_id);
|
||||
|
||||
let output = match tcx.hir().get(hir_id) {
|
||||
let output = match tcx.hir_node(hir_id) {
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Fn(..) => {
|
||||
let args = ty::GenericArgs::identity_for_item(tcx, def_id);
|
||||
|
@ -517,8 +517,7 @@ pub(super) fn type_of_opaque(
|
|||
if let Some(def_id) = def_id.as_local() {
|
||||
use rustc_hir::*;
|
||||
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
Ok(ty::EarlyBinder::bind(match tcx.hir().get(hir_id) {
|
||||
Ok(ty::EarlyBinder::bind(match tcx.hir_node_by_def_id(def_id) {
|
||||
Node::Item(item) => match item.kind {
|
||||
ItemKind::OpaqueTy(OpaqueTy {
|
||||
origin: hir::OpaqueTyOrigin::TyAlias { .. },
|
||||
|
|
|
@ -50,8 +50,8 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local
|
|||
if scope == hir::CRATE_HIR_ID {
|
||||
tcx.hir().walk_toplevel_module(&mut locator);
|
||||
} else {
|
||||
trace!("scope={:#?}", tcx.hir().get(scope));
|
||||
match tcx.hir().get(scope) {
|
||||
trace!("scope={:#?}", tcx.hir_node(scope));
|
||||
match tcx.hir_node(scope) {
|
||||
// We explicitly call `visit_*` methods, instead of using `intravisit::walk_*` methods
|
||||
// This allows our visitor to process the defining item itself, causing
|
||||
// it to pick up any 'sibling' defining uses.
|
||||
|
@ -95,7 +95,7 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local
|
|||
let reported = tcx.sess.emit_err(UnconstrainedOpaqueType {
|
||||
span: tcx.def_span(def_id),
|
||||
name: tcx.item_name(parent_def_id.to_def_id()),
|
||||
what: match tcx.hir().get(scope) {
|
||||
what: match tcx.hir_node(scope) {
|
||||
_ if scope == hir::CRATE_HIR_ID => "module",
|
||||
Node::Item(hir::Item { kind: hir::ItemKind::Mod(_), .. }) => "module",
|
||||
Node::Item(hir::Item { kind: hir::ItemKind::Impl(_), .. }) => "impl",
|
||||
|
@ -282,7 +282,7 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
|
|||
debug!(?scope);
|
||||
let mut locator = RpitConstraintChecker { def_id, tcx, found: mir_opaque_ty };
|
||||
|
||||
match tcx.hir().get(scope) {
|
||||
match tcx.hir_node(scope) {
|
||||
Node::Item(it) => intravisit::walk_item(&mut locator, it),
|
||||
Node::ImplItem(it) => intravisit::walk_impl_item(&mut locator, it),
|
||||
Node::TraitItem(it) => intravisit::walk_trait_item(&mut locator, it),
|
||||
|
|
|
@ -122,7 +122,7 @@ fn diagnostic_hir_wf_check<'tcx>(
|
|||
// We will walk 'into' this type to try to find
|
||||
// a more precise span for our predicate.
|
||||
let tys = match loc {
|
||||
WellFormedLoc::Ty(_) => match hir.get(hir_id) {
|
||||
WellFormedLoc::Ty(_) => match tcx.hir_node(hir_id) {
|
||||
hir::Node::ImplItem(item) => match item.kind {
|
||||
hir::ImplItemKind::Type(ty) => vec![ty],
|
||||
hir::ImplItemKind::Const(ty, _) => vec![ty],
|
||||
|
|
|
@ -41,7 +41,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clau
|
|||
}
|
||||
}
|
||||
|
||||
match tcx.hir().get(id) {
|
||||
match tcx.hir_node(id) {
|
||||
Node::Item(item) => match item.kind {
|
||||
hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => {
|
||||
let crate_map = tcx.inferred_outlives_crate(());
|
||||
|
|
|
@ -137,10 +137,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
// is from the 'of_trait' field of the enclosing impl
|
||||
|
||||
let parent = self.tcx.hir().get_parent(self.path_segment.hir_id);
|
||||
let parent_item = self
|
||||
.tcx
|
||||
.hir()
|
||||
.get_by_def_id(self.tcx.hir().get_parent_item(self.path_segment.hir_id).def_id);
|
||||
let parent_item = self.tcx.hir_node_by_def_id(
|
||||
self.tcx.hir().get_parent_item(self.path_segment.hir_id).def_id,
|
||||
);
|
||||
|
||||
// Get the HIR id of the trait ref
|
||||
let hir::Node::TraitRef(hir::TraitRef { hir_ref_id: trait_ref_id, .. }) = parent else {
|
||||
|
@ -774,7 +773,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
);
|
||||
|
||||
if let Some(parent_node) = self.tcx.hir().opt_parent_id(self.path_segment.hir_id)
|
||||
&& let Some(parent_node) = self.tcx.hir().find(parent_node)
|
||||
&& let Some(parent_node) = self.tcx.opt_hir_node(parent_node)
|
||||
&& let hir::Node::Expr(expr) = parent_node
|
||||
{
|
||||
match &expr.kind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue