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

@ -413,7 +413,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
(None, &[][..], 0) (None, &[][..], 0)
}; };
if let Some(def_id) = def_id if let Some(def_id) = def_id
&& let Some(node) = hir.find(hir.local_def_id_to_hir_id(def_id)) && let Some(node) = hir.find(self.infcx.tcx.local_def_id_to_hir_id(def_id))
&& let Some(fn_sig) = node.fn_sig() && let Some(fn_sig) = node.fn_sig()
&& let Some(ident) = node.ident() && let Some(ident) = node.ident()
&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id) && let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
@ -3243,7 +3243,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
) -> Option<AnnotatedBorrowFnSignature<'tcx>> { ) -> Option<AnnotatedBorrowFnSignature<'tcx>> {
debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig); debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
let is_closure = self.infcx.tcx.is_closure(did.to_def_id()); let is_closure = self.infcx.tcx.is_closure(did.to_def_id());
let fn_hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(did); let fn_hir_id = self.infcx.tcx.local_def_id_to_hir_id(did);
let fn_decl = self.infcx.tcx.hir().fn_decl_by_hir_id(fn_hir_id)?; let fn_decl = self.infcx.tcx.hir().fn_decl_by_hir_id(fn_hir_id)?;
// We need to work out which arguments to highlight. We do this by looking // We need to work out which arguments to highlight. We do this by looking

View file

@ -958,7 +958,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
"closure_span: def_id={:?} target_place={:?} places={:?}", "closure_span: def_id={:?} target_place={:?} places={:?}",
def_id, target_place, places def_id, target_place, places
); );
let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = self.infcx.tcx.local_def_id_to_hir_id(def_id);
let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind; let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind;
debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr); debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr);
if let hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, .. }) = expr { if let hir::ExprKind::Closure(&hir::Closure { body, fn_decl_span, .. }) = expr {

View file

@ -661,7 +661,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
} }
let hir_map = self.infcx.tcx.hir(); let hir_map = self.infcx.tcx.hir();
let my_def = self.body.source.def_id(); let my_def = self.body.source.def_id();
let my_hir = hir_map.local_def_id_to_hir_id(my_def.as_local().unwrap()); let my_hir = self.infcx.tcx.local_def_id_to_hir_id(my_def.as_local().unwrap());
let Some(td) = let Some(td) =
self.infcx.tcx.impl_of_method(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x)) self.infcx.tcx.impl_of_method(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x))
else { else {

View file

@ -215,7 +215,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
.map(|placeholder| { .map(|placeholder| {
if let Some(id) = placeholder.bound.kind.get_id() if let Some(id) = placeholder.bound.kind.get_id()
&& let Some(placeholder_id) = id.as_local() && let Some(placeholder_id) = id.as_local()
&& let gat_hir_id = hir.local_def_id_to_hir_id(placeholder_id) && let gat_hir_id = self.infcx.tcx.local_def_id_to_hir_id(placeholder_id)
&& let Some(generics_impl) = hir.get_parent(gat_hir_id).generics() && let Some(generics_impl) = hir.get_parent(gat_hir_id).generics()
{ {
Some((gat_hir_id, generics_impl)) Some((gat_hir_id, generics_impl))
@ -236,7 +236,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}; };
if bound_generic_params if bound_generic_params
.iter() .iter()
.rfind(|bgp| hir.local_def_id_to_hir_id(bgp.def_id) == *gat_hir_id) .rfind(|bgp| self.infcx.tcx.local_def_id_to_hir_id(bgp.def_id) == *gat_hir_id)
.is_some() .is_some()
{ {
for bound in *bounds { for bound in *bounds {

View file

@ -199,7 +199,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
} }
pub(crate) fn mir_hir_id(&self) -> hir::HirId { pub(crate) fn mir_hir_id(&self) -> hir::HirId {
self.infcx.tcx.hir().local_def_id_to_hir_id(self.mir_def_id()) self.infcx.tcx.local_def_id_to_hir_id(self.mir_def_id())
} }
/// Generate a synthetic region named `'N`, where `N` is the next value of the counter. Then, /// Generate a synthetic region named `'N`, where `N` is the next value of the counter. Then,

View file

@ -134,7 +134,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
return tcx.arena.alloc(result); return tcx.arena.alloc(result);
} }
let hir_owner = tcx.hir().local_def_id_to_hir_id(def).owner; let hir_owner = tcx.local_def_id_to_hir_id(def).owner;
let infcx = let infcx =
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id)).build(); tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id)).build();

View file

@ -928,7 +928,7 @@ fn for_each_late_bound_region_in_item<'tcx>(
return; return;
} }
for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(mir_def_id)) { for bound_var in tcx.late_bound_vars(tcx.local_def_id_to_hir_id(mir_def_id)) {
let ty::BoundVariableKind::Region(bound_region) = bound_var else { let ty::BoundVariableKind::Region(bound_region) = bound_var else {
continue; continue;
}; };

View file

@ -57,7 +57,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
); );
} }
let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(did)); let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(did));
let mut codegen_fn_attrs = CodegenFnAttrs::new(); let mut codegen_fn_attrs = CodegenFnAttrs::new();
if tcx.should_inherit_track_caller(did) { if tcx.should_inherit_track_caller(did) {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER; codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER;
@ -572,7 +572,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
if !codegen_fn_attrs.no_sanitize.is_empty() { if !codegen_fn_attrs.no_sanitize.is_empty() {
if codegen_fn_attrs.inline == InlineAttr::Always { if codegen_fn_attrs.inline == InlineAttr::Always {
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) { if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
let hir_id = tcx.hir().local_def_id_to_hir_id(did); let hir_id = tcx.local_def_id_to_hir_id(did);
tcx.struct_span_lint_hir( tcx.struct_span_lint_hir(
lint::builtin::INLINE_NO_SANITIZE, lint::builtin::INLINE_NO_SANITIZE,
hir_id, hir_id,

View file

@ -456,7 +456,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
self.stack() self.stack()
.iter() .iter()
.find_map(|frame| frame.body.source.def_id().as_local()) .find_map(|frame| frame.body.source.def_id().as_local())
.map_or(CRATE_HIR_ID, |def_id| self.tcx.hir().local_def_id_to_hir_id(def_id)) .map_or(CRATE_HIR_ID, |def_id| self.tcx.local_def_id_to_hir_id(def_id))
} }
/// Turn the given error into a human-readable string. Expects the string to be printed, so if /// Turn the given error into a human-readable string. Expects the string to be printed, so if

View file

@ -82,7 +82,7 @@ pub fn rustc_allow_const_fn_unstable(
def_id: LocalDefId, def_id: LocalDefId,
feature_gate: Symbol, feature_gate: Symbol,
) -> bool { ) -> bool {
let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(def_id)); let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(def_id));
attr::rustc_allow_const_fn_unstable(tcx.sess, attrs).any(|name| name == feature_gate) attr::rustc_allow_const_fn_unstable(tcx.sess, attrs).any(|name| name == feature_gate)
} }

View file

@ -119,7 +119,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
match self_ty.kind() { match self_ty.kind() {
Param(param_ty) => { Param(param_ty) => {
debug!(?param_ty); debug!(?param_ty);
let caller_hir_id = tcx.hir().local_def_id_to_hir_id(caller); let caller_hir_id = tcx.local_def_id_to_hir_id(caller);
if let Some(generics) = tcx.hir().get(caller_hir_id).generics() { if let Some(generics) = tcx.hir().get(caller_hir_id).generics() {
let constraint = with_no_trimmed_paths!(format!( let constraint = with_no_trimmed_paths!(format!(
"~const {}", "~const {}",

View file

@ -201,7 +201,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
); );
let hir = self.tcx().hir(); let hir = self.tcx().hir();
if let Some(def_id) = ty_param_def_id if let Some(def_id) = ty_param_def_id
&& let parent = hir.get_parent_item(hir.local_def_id_to_hir_id(def_id)) && let parent = hir.get_parent_item(self.tcx().local_def_id_to_hir_id(def_id))
&& let Some(generics) = hir.get_generics(parent.def_id) && let Some(generics) = hir.get_generics(parent.def_id)
{ {
if generics.bounds_for_param(def_id).flat_map(|pred| pred.bounds.iter()).any( if generics.bounds_for_param(def_id).flat_map(|pred| pred.bounds.iter()).any(

View file

@ -239,7 +239,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
def: Option<&ty::GenericParamDef>, def: Option<&ty::GenericParamDef>,
) -> ty::Region<'tcx> { ) -> ty::Region<'tcx> {
let tcx = self.tcx(); let tcx = self.tcx();
let lifetime_name = |def_id| tcx.hir().name(tcx.hir().local_def_id_to_hir_id(def_id)); let lifetime_name = |def_id| tcx.hir().name(tcx.local_def_id_to_hir_id(def_id));
match tcx.named_bound_var(lifetime.hir_id) { match tcx.named_bound_var(lifetime.hir_id) {
Some(rbv::ResolvedArg::StaticLifetime) => tcx.lifetimes.re_static, Some(rbv::ResolvedArg::StaticLifetime) => tcx.lifetimes.re_static,
@ -1872,7 +1872,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let parent_def_id = def_id let parent_def_id = def_id
.as_local() .as_local()
.map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id)) .map(|def_id| tcx.local_def_id_to_hir_id(def_id))
.map(|hir_id| tcx.hir().get_parent_item(hir_id).to_def_id()); .map(|hir_id| tcx.hir().get_parent_item(hir_id).to_def_id());
debug!("qpath_to_ty: parent_def_id={:?}", parent_def_id); debug!("qpath_to_ty: parent_def_id={:?}", parent_def_id);

View file

@ -188,7 +188,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
if layout.abi.is_uninhabited() { if layout.abi.is_uninhabited() {
tcx.struct_span_lint_hir( tcx.struct_span_lint_hir(
UNINHABITED_STATIC, UNINHABITED_STATIC,
tcx.hir().local_def_id_to_hir_id(def_id), tcx.local_def_id_to_hir_id(def_id),
span, span,
"static of uninhabited type", "static of uninhabited type",
|lint| { |lint| {
@ -753,8 +753,7 @@ fn check_impl_items_against_trait<'tcx>(
leaf_def.as_ref().is_some_and(|node_item| !node_item.defining_node.is_from_trait()); leaf_def.as_ref().is_some_and(|node_item| !node_item.defining_node.is_from_trait());
if !is_implemented_here { if !is_implemented_here {
let full_impl_span = let full_impl_span = tcx.hir().span_with_body(tcx.local_def_id_to_hir_id(impl_id));
tcx.hir().span_with_body(tcx.hir().local_def_id_to_hir_id(impl_id));
match tcx.eval_default_body_stability(trait_item_id, full_impl_span) { match tcx.eval_default_body_stability(trait_item_id, full_impl_span) {
EvalResult::Deny { feature, reason, issue, .. } => default_body_is_unstable( EvalResult::Deny { feature, reason, issue, .. } => default_body_is_unstable(
tcx, tcx,
@ -811,8 +810,7 @@ fn check_impl_items_against_trait<'tcx>(
} }
if !missing_items.is_empty() { if !missing_items.is_empty() {
let full_impl_span = let full_impl_span = tcx.hir().span_with_body(tcx.local_def_id_to_hir_id(impl_id));
tcx.hir().span_with_body(tcx.hir().local_def_id_to_hir_id(impl_id));
missing_items_err(tcx, impl_id, &missing_items, full_impl_span); missing_items_err(tcx, impl_id, &missing_items, full_impl_span);
} }
@ -1083,7 +1081,7 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
if non_trivial_count > 0 || prev_non_exhaustive_1zst { if non_trivial_count > 0 || prev_non_exhaustive_1zst {
tcx.struct_span_lint_hir( tcx.struct_span_lint_hir(
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS, REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
tcx.hir().local_def_id_to_hir_id(adt.did().expect_local()), tcx.local_def_id_to_hir_id(adt.did().expect_local()),
span, span,
"zero-sized fields in `repr(transparent)` cannot \ "zero-sized fields in `repr(transparent)` cannot \
contain external non-exhaustive types", contain external non-exhaustive types",

View file

@ -380,7 +380,7 @@ fn compare_method_predicate_entailment<'tcx>(
if !errors.is_empty() { if !errors.is_empty() {
match check_implied_wf { match check_implied_wf {
CheckImpliedWfMode::Check => { CheckImpliedWfMode::Check => {
let impl_m_hir_id = tcx.hir().local_def_id_to_hir_id(impl_m_def_id); let impl_m_hir_id = tcx.local_def_id_to_hir_id(impl_m_def_id);
return compare_method_predicate_entailment( return compare_method_predicate_entailment(
tcx, tcx,
impl_m, impl_m,
@ -410,7 +410,7 @@ fn compare_method_predicate_entailment<'tcx>(
if !errors.is_empty() { if !errors.is_empty() {
// FIXME(compiler-errors): This can be simplified when IMPLIED_BOUNDS_ENTAILMENT // FIXME(compiler-errors): This can be simplified when IMPLIED_BOUNDS_ENTAILMENT
// becomes a hard error (i.e. ideally we'd just call `resolve_regions_and_report_errors` // becomes a hard error (i.e. ideally we'd just call `resolve_regions_and_report_errors`
let impl_m_hir_id = tcx.hir().local_def_id_to_hir_id(impl_m_def_id); let impl_m_hir_id = tcx.local_def_id_to_hir_id(impl_m_def_id);
match check_implied_wf { match check_implied_wf {
CheckImpliedWfMode::Check => { CheckImpliedWfMode::Check => {
return compare_method_predicate_entailment( return compare_method_predicate_entailment(
@ -667,7 +667,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
let trait_to_impl_args = impl_trait_ref.args; let trait_to_impl_args = impl_trait_ref.args;
let impl_m_hir_id = tcx.hir().local_def_id_to_hir_id(impl_m_def_id); let impl_m_hir_id = tcx.local_def_id_to_hir_id(impl_m_def_id);
let return_span = tcx.hir().fn_decl_by_hir_id(impl_m_hir_id).unwrap().output.span(); let return_span = tcx.hir().fn_decl_by_hir_id(impl_m_hir_id).unwrap().output.span();
let cause = ObligationCause::new( let cause = ObligationCause::new(
return_span, return_span,

View file

@ -42,7 +42,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
if !def_id.is_local() { if !def_id.is_local() {
return None; return None;
} }
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); let hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
match tcx.hir().find(hir_id) { match tcx.hir().find(hir_id) {
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })) => { Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })) => {
generics.params.is_empty().not().then_some(generics.span) generics.params.is_empty().not().then_some(generics.span)
@ -57,7 +57,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
if !def_id.is_local() { if !def_id.is_local() {
return None; return None;
} }
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); let hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
match tcx.hir().find(hir_id) { match tcx.hir().find(hir_id) {
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })) => { Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })) => {
Some(generics.where_clause_span) Some(generics.where_clause_span)
@ -79,7 +79,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
if !def_id.is_local() { if !def_id.is_local() {
return None; return None;
} }
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); let hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
match tcx.hir().find(hir_id) { match tcx.hir().find(hir_id) {
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(fn_sig, _, _), .. })) => { Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(fn_sig, _, _), .. })) => {
Some(fn_sig.decl.output.span()) Some(fn_sig.decl.output.span())
@ -194,7 +194,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) { fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
let start_def_id = start_def_id.expect_local(); let start_def_id = start_def_id.expect_local();
let start_id = tcx.hir().local_def_id_to_hir_id(start_def_id); let start_id = tcx.local_def_id_to_hir_id(start_def_id);
let start_span = tcx.def_span(start_def_id); let start_span = tcx.def_span(start_def_id);
let start_t = tcx.type_of(start_def_id).instantiate_identity(); let start_t = tcx.type_of(start_def_id).instantiate_identity();
match start_t.kind() { match start_t.kind() {

View file

@ -128,7 +128,7 @@ fn get_owner_return_paths(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
def_id: LocalDefId, def_id: LocalDefId,
) -> Option<(LocalDefId, ReturnsVisitor<'_>)> { ) -> Option<(LocalDefId, ReturnsVisitor<'_>)> {
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_id = tcx.hir().get_parent_item(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.hir().find_by_def_id(parent_id).and_then(|node| node.body_id()).map(|body_id| {
let body = tcx.hir().body(body_id); let body = tcx.hir().body(body_id);

View file

@ -497,7 +497,7 @@ fn lint_auto_trait_impl<'tcx>(
tcx.struct_span_lint_hir( tcx.struct_span_lint_hir(
lint::builtin::SUSPICIOUS_AUTO_TRAIT_IMPLS, lint::builtin::SUSPICIOUS_AUTO_TRAIT_IMPLS,
tcx.hir().local_def_id_to_hir_id(impl_def_id), tcx.local_def_id_to_hir_id(impl_def_id),
tcx.def_span(impl_def_id), tcx.def_span(impl_def_id),
DelayDm(|| { DelayDm(|| {
format!( format!(

View file

@ -350,7 +350,7 @@ impl<'tcx> ItemCtxt<'tcx> {
} }
pub fn hir_id(&self) -> hir::HirId { pub fn hir_id(&self) -> hir::HirId {
self.tcx.hir().local_def_id_to_hir_id(self.item_def_id) self.tcx.local_def_id_to_hir_id(self.item_def_id)
} }
pub fn node(&self) -> hir::Node<'tcx> { pub fn node(&self) -> hir::Node<'tcx> {
@ -835,7 +835,7 @@ fn convert_variant(
fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> { fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> {
use rustc_hir::*; 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::Item(item) = tcx.hir().get(hir_id) else { let Node::Item(item) = tcx.hir().get(hir_id) else {
bug!(); bug!();
}; };
@ -1101,7 +1101,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<ty::PolyFnSig<
use rustc_hir::Node::*; use rustc_hir::Node::*;
use rustc_hir::*; 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 icx = ItemCtxt::new(tcx, def_id); let icx = ItemCtxt::new(tcx, def_id);
@ -1186,7 +1186,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
def_id: LocalDefId, def_id: LocalDefId,
icx: &ItemCtxt<'tcx>, icx: &ItemCtxt<'tcx>,
) -> ty::PolyFnSig<'tcx> { ) -> ty::PolyFnSig<'tcx> {
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);
match get_infer_ret_ty(&sig.decl.output) { match get_infer_ret_ty(&sig.decl.output) {
Some(ty) => { Some(ty) => {
@ -1519,7 +1519,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
} else { } else {
hir::Unsafety::Unsafe hir::Unsafety::Unsafe
}; };
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 fty = let fty =
ItemCtxt::new(tcx, def_id).astconv().ty_of_fn(hir_id, unsafety, abi, decl, None, None); ItemCtxt::new(tcx, def_id).astconv().ty_of_fn(hir_id, unsafety, abi, decl, None, None);

View file

@ -14,7 +14,7 @@ use rustc_span::{sym, Span};
pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
use rustc_hir::*; 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 node = tcx.hir().get(hir_id);
let parent_def_id = match node { let parent_def_id = match node {

View file

@ -105,7 +105,7 @@ pub(super) fn explicit_item_bounds(
None => {} 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) { let bounds = match tcx.hir().get(hir_id) {
hir::Node::TraitItem(hir::TraitItem { hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Type(bounds, _), kind: hir::TraitItemKind::Type(bounds, _),

View file

@ -134,7 +134,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
None => {} 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 node = tcx.hir().get(hir_id);
let mut is_trait = None; 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 node = tcx.hir().get(hir_id);
let mut collector = ConstCollector { tcx, preds: FxIndexSet::default() }; let mut collector = ConstCollector { tcx, preds: FxIndexSet::default() };
@ -503,7 +503,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
} }
} else { } else {
if matches!(def_kind, DefKind::AnonConst) && tcx.features().generic_const_exprs { 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); let parent_def_id = tcx.hir().get_parent_item(hir_id);
if let Some(defaulted_param_def_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. // 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` // 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` // In the above example this is the function `foo`
let item_def_id = tcx.hir().get_parent_item(parent_hir_id); 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); 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 { let Node::Item(item) = tcx.hir().get(trait_hir_id) else {
bug!("trait_node_id {} is not an item", trait_hir_id); 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 // written inline like `<T: Foo>` or in a where-clause like
// `where T: Foo`. // `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 param_owner = tcx.hir().ty_param_owner(def_id);
let generics = tcx.generics_of(param_owner); let generics = tcx.generics_of(param_owner);
let index = generics.param_def_id_to_index[&def_id.to_def_id()]; 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(); .unwrap_or_default();
let mut extend = None; 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) { let ast_generics = match tcx.hir().get(item_hir_id) {
Node::TraitItem(item) => item.generics, Node::TraitItem(item) => item.generics,

View file

@ -295,7 +295,7 @@ fn late_arg_as_bound_arg<'tcx>(
) -> ty::BoundVariableKind { ) -> ty::BoundVariableKind {
match arg { match arg {
ResolvedArg::LateBound(_, _, def_id) => { 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 { match param.kind {
GenericParamKind::Lifetime { .. } => { GenericParamKind::Lifetime { .. } => {
ty::BoundVariableKind::Region(ty::BrNamed(*def_id, name)) 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 def = self.map.defs.get(&lifetime.hir_id).cloned();
let Some(ResolvedArg::LateBound(_, _, def_id)) = def else { continue }; let Some(ResolvedArg::LateBound(_, _, def_id)) = def else { continue };
let Some(def_id) = def_id.as_local() 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 // Ensure that the parent of the def is an item, not HRTB
let parent_id = self.tcx.hir().parent_id(hir_id); let parent_id = self.tcx.hir().parent_id(hir_id);
if !parent_id.is_owner() { if !parent_id.is_owner() {

View file

@ -18,7 +18,7 @@ mod opaque;
fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
use hir::*; use hir::*;
use rustc_middle::ty::Ty; 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!() }; 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); 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() { if let Some(def_id) = def_id.as_local() {
use rustc_hir::*; 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) { Ok(ty::EarlyBinder::bind(match tcx.hir().get(hir_id) {
Node::Item(item) => match item.kind { Node::Item(item) => match item.kind {
ItemKind::OpaqueTy(OpaqueTy { ItemKind::OpaqueTy(OpaqueTy {

View file

@ -41,7 +41,7 @@ pub fn test_opaque_hidden_types(tcx: TyCtxt<'_>) {
/// ``` /// ```
#[instrument(skip(tcx), level = "debug")] #[instrument(skip(tcx), level = "debug")]
pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { 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 scope = tcx.hir().get_defining_scope(hir_id);
let mut locator = TaitConstraintLocator { def_id, tcx, found: None, typeck_types: vec![] }; 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(); 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 { 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); debug!(?scope);
let mut locator = RpitConstraintChecker { def_id, tcx, found: mir_opaque_ty }; let mut locator = RpitConstraintChecker { def_id, tcx, found: mir_opaque_ty };

View file

@ -25,7 +25,7 @@ fn diagnostic_hir_wf_check<'tcx>(
WellFormedLoc::Ty(def_id) => def_id, WellFormedLoc::Ty(def_id) => def_id,
WellFormedLoc::Param { function, param_idx: _ } => function, WellFormedLoc::Param { function, param_idx: _ } => function,
}; };
let hir_id = hir.local_def_id_to_hir_id(def_id); let hir_id = tcx.local_def_id_to_hir_id(def_id);
// HIR wfcheck should only ever happen as part of improving an existing error // HIR wfcheck should only ever happen as part of improving an existing error
tcx.sess tcx.sess

View file

@ -18,7 +18,7 @@ pub fn provide(providers: &mut Providers) {
} }
fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clause<'_>, Span)] { fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clause<'_>, Span)] {
let id = tcx.hir().local_def_id_to_hir_id(item_def_id); let id = tcx.local_def_id_to_hir_id(item_def_id);
if matches!(tcx.def_kind(item_def_id), hir::def::DefKind::AnonConst) if matches!(tcx.def_kind(item_def_id), hir::def::DefKind::AnonConst)
&& tcx.features().generic_const_exprs && tcx.features().generic_const_exprs

View file

@ -34,7 +34,7 @@ pub(super) fn check_fn<'a, 'tcx>(
can_be_coroutine: Option<hir::Movability>, can_be_coroutine: Option<hir::Movability>,
params_can_be_unsized: bool, params_can_be_unsized: bool,
) -> Option<CoroutineTypes<'tcx>> { ) -> Option<CoroutineTypes<'tcx>> {
let fn_id = fcx.tcx.hir().local_def_id_to_hir_id(fn_def_id); let fn_id = fcx.tcx.local_def_id_to_hir_id(fn_def_id);
let tcx = fcx.tcx; let tcx = fcx.tcx;
let hir = tcx.hir(); let hir = tcx.hir();

View file

@ -624,7 +624,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
trace!("decl = {:#?}", decl); trace!("decl = {:#?}", decl);
debug!(?body.coroutine_kind); debug!(?body.coroutine_kind);
let hir_id = self.tcx.hir().local_def_id_to_hir_id(expr_def_id); let hir_id = self.tcx.local_def_id_to_hir_id(expr_def_id);
let bound_vars = self.tcx.late_bound_vars(hir_id); let bound_vars = self.tcx.late_bound_vars(hir_id);
// First, convert the types that the user supplied (if any). // First, convert the types that the user supplied (if any).

View file

@ -883,7 +883,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let container_id = pick.item.container_id(self.tcx); let container_id = pick.item.container_id(self.tcx);
let container = with_no_trimmed_paths!(self.tcx.def_path_str(container_id)); let container = with_no_trimmed_paths!(self.tcx.def_path_str(container_id));
for def_id in pick.import_ids { for def_id in pick.import_ids {
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);
path_span.push_span_label( path_span.push_span_label(
self.tcx.hir().span(hir_id), self.tcx.hir().span(hir_id),
format!("`{container}` imported here"), format!("`{container}` imported here"),

View file

@ -2344,7 +2344,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
match deref_base_ty.kind() { match deref_base_ty.kind() {
ty::Adt(base_def, args) if !base_def.is_enum() => { ty::Adt(base_def, args) if !base_def.is_enum() => {
debug!("struct named {:?}", deref_base_ty); debug!("struct named {:?}", deref_base_ty);
let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(self.body_id); let body_hir_id = self.tcx.local_def_id_to_hir_id(self.body_id);
let (ident, def_scope) = let (ident, def_scope) =
self.tcx.adjust_ident_and_get_scope(field, base_def.did(), body_hir_id); self.tcx.adjust_ident_and_get_scope(field, base_def.did(), body_hir_id);
let fields = &base_def.non_enum_variant().fields; let fields = &base_def.non_enum_variant().fields;
@ -2691,7 +2691,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
let param_def_id = generic_param.def_id; let param_def_id = generic_param.def_id;
let param_hir_id = match param_def_id.as_local() { let param_hir_id = match param_def_id.as_local() {
Some(x) => self.tcx.hir().local_def_id_to_hir_id(x), Some(x) => self.tcx.local_def_id_to_hir_id(x),
None => return, None => return,
}; };
let param_span = self.tcx.hir().span(param_hir_id); let param_span = self.tcx.hir().span(param_hir_id);
@ -3268,7 +3268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
match container.kind() { match container.kind() {
ty::Adt(container_def, args) if container_def.is_enum() => { ty::Adt(container_def, args) if container_def.is_enum() => {
let block = self.tcx.hir().local_def_id_to_hir_id(self.body_id); let block = self.tcx.local_def_id_to_hir_id(self.body_id);
let (ident, _def_scope) = let (ident, _def_scope) =
self.tcx.adjust_ident_and_get_scope(field, container_def.did(), block); self.tcx.adjust_ident_and_get_scope(field, container_def.did(), block);
@ -3350,7 +3350,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
continue; continue;
} }
ty::Adt(container_def, args) => { ty::Adt(container_def, args) => {
let block = self.tcx.hir().local_def_id_to_hir_id(self.body_id); let block = self.tcx.local_def_id_to_hir_id(self.body_id);
let (ident, def_scope) = let (ident, def_scope) =
self.tcx.adjust_ident_and_get_scope(field, container_def.did(), block); self.tcx.adjust_ident_and_get_scope(field, container_def.did(), block);

View file

@ -848,7 +848,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
// be a local variable // be a local variable
PlaceBase::Local(*var_hir_id) PlaceBase::Local(*var_hir_id)
}; };
let closure_hir_id = tcx.hir().local_def_id_to_hir_id(closure_def_id); let closure_hir_id = tcx.local_def_id_to_hir_id(closure_def_id);
let place_with_id = PlaceWithHirId::new( let place_with_id = PlaceWithHirId::new(
capture_info capture_info
.path_expr_id .path_expr_id

View file

@ -43,7 +43,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.typeck_results self.typeck_results
.borrow() .borrow()
.liberated_fn_sigs() .liberated_fn_sigs()
.get(self.tcx.hir().local_def_id_to_hir_id(self.body_id)) .get(self.tcx.local_def_id_to_hir_id(self.body_id))
.copied() .copied()
} }

View file

@ -75,7 +75,7 @@ impl<'tcx> Deref for Inherited<'tcx> {
impl<'tcx> Inherited<'tcx> { impl<'tcx> Inherited<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self { pub fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
let hir_owner = tcx.hir().local_def_id_to_hir_id(def_id).owner; let hir_owner = tcx.local_def_id_to_hir_id(def_id).owner;
let infcx = tcx let infcx = tcx
.infer_ctxt() .infer_ctxt()

View file

@ -146,7 +146,7 @@ fn typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckResults<'tc
/// Currently only used for type inference of `static`s and `const`s to avoid type cycle errors. /// Currently only used for type inference of `static`s and `const`s to avoid type cycle errors.
fn diagnostic_only_typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckResults<'tcx> { fn diagnostic_only_typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckResults<'tcx> {
let fallback = move || { let fallback = move || {
let span = tcx.hir().span(tcx.hir().local_def_id_to_hir_id(def_id)); let span = tcx.hir().span(tcx.local_def_id_to_hir_id(def_id));
Ty::new_error_with_message(tcx, span, "diagnostic only typeck table used") Ty::new_error_with_message(tcx, span, "diagnostic only typeck table used")
}; };
typeck_with_fallback(tcx, def_id, fallback) typeck_with_fallback(tcx, def_id, fallback)
@ -165,7 +165,7 @@ fn typeck_with_fallback<'tcx>(
return tcx.typeck(typeck_root_def_id); return tcx.typeck(typeck_root_def_id);
} }
let id = tcx.hir().local_def_id_to_hir_id(def_id); let id = tcx.local_def_id_to_hir_id(def_id);
let node = tcx.hir().get(id); let node = tcx.hir().get(id);
let span = tcx.hir().span(id); let span = tcx.hir().span(id);

View file

@ -619,7 +619,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
fn push_candidate(&mut self, candidate: Candidate<'tcx>, is_inherent: bool) { fn push_candidate(&mut self, candidate: Candidate<'tcx>, is_inherent: bool) {
let is_accessible = if let Some(name) = self.method_name { let is_accessible = if let Some(name) = self.method_name {
let item = candidate.item; let item = candidate.item;
let hir_id = self.tcx.hir().local_def_id_to_hir_id(self.body_id); let hir_id = self.tcx.local_def_id_to_hir_id(self.body_id);
let def_scope = let def_scope =
self.tcx.adjust_ident_and_get_scope(name, item.container_id(self.tcx), hir_id).1; self.tcx.adjust_ident_and_get_scope(name, item.container_id(self.tcx), hir_id).1;
item.visibility(self.tcx).is_accessible_from(def_scope, self.tcx) item.visibility(self.tcx).is_accessible_from(def_scope, self.tcx)
@ -1939,7 +1939,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
let Some(local_def_id) = def_id.as_local() else { let Some(local_def_id) = def_id.as_local() else {
return false; return false;
}; };
let hir_id = self.fcx.tcx.hir().local_def_id_to_hir_id(local_def_id); let hir_id = self.fcx.tcx.local_def_id_to_hir_id(local_def_id);
let attrs = self.fcx.tcx.hir().attrs(hir_id); let attrs = self.fcx.tcx.hir().attrs(hir_id);
for attr in attrs { for attr in attrs {
let sym::doc = attr.name_or_empty() else { let sym::doc = attr.name_or_empty() else {

View file

@ -2867,7 +2867,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let id = item let id = item
.def_id .def_id
.as_local() .as_local()
.map(|def_id| self.tcx.hir().local_def_id_to_hir_id(def_id)); .map(|def_id| self.tcx.local_def_id_to_hir_id(def_id));
if let Some(hir::Node::TraitItem(hir::TraitItem { if let Some(hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Fn(fn_sig, method), kind: hir::TraitItemKind::Fn(fn_sig, method),
.. ..
@ -2957,7 +2957,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let type_param = generics.type_param(param, self.tcx); let type_param = generics.type_param(param, self.tcx);
let hir = self.tcx.hir(); let hir = self.tcx.hir();
if let Some(def_id) = type_param.def_id.as_local() { if let Some(def_id) = type_param.def_id.as_local() {
let id = hir.local_def_id_to_hir_id(def_id); let id = self.tcx.local_def_id_to_hir_id(def_id);
// Get the `hir::Param` to verify whether it already has any bounds. // Get the `hir::Param` to verify whether it already has any bounds.
// We do this to avoid suggesting code that ends up as `T: FooBar`, // We do this to avoid suggesting code that ends up as `T: FooBar`,
// instead we suggest `T: Foo + Bar` in that case. // instead we suggest `T: Foo + Bar` in that case.

View file

@ -221,7 +221,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.compute_min_captures(closure_def_id, capture_information, span); self.compute_min_captures(closure_def_id, capture_information, span);
let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(closure_def_id); let closure_hir_id = self.tcx.local_def_id_to_hir_id(closure_def_id);
if should_do_rust_2021_incompatible_closure_captures_analysis(self.tcx, closure_hir_id) { if should_do_rust_2021_incompatible_closure_captures_analysis(self.tcx, closure_hir_id) {
self.perform_2229_migration_analysis(closure_def_id, body_id, capture_clause, span); self.perform_2229_migration_analysis(closure_def_id, body_id, capture_clause, span);
@ -763,7 +763,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let (migration_string, migrated_variables_concat) = let (migration_string, migrated_variables_concat) =
migration_suggestion_for_2229(self.tcx, &need_migrations); migration_suggestion_for_2229(self.tcx, &need_migrations);
let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(closure_def_id); let closure_hir_id = self.tcx.local_def_id_to_hir_id(closure_def_id);
let closure_head_span = self.tcx.def_span(closure_def_id); let closure_head_span = self.tcx.def_span(closure_def_id);
self.tcx.struct_span_lint_hir( self.tcx.struct_span_lint_hir(
lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,

View file

@ -47,7 +47,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Type only exists for constants and statics, not functions. // Type only exists for constants and statics, not functions.
match self.tcx.hir().body_owner_kind(item_def_id) { match self.tcx.hir().body_owner_kind(item_def_id) {
hir::BodyOwnerKind::Const { .. } | hir::BodyOwnerKind::Static(_) => { hir::BodyOwnerKind::Const { .. } | hir::BodyOwnerKind::Static(_) => {
let item_hir_id = self.tcx.hir().local_def_id_to_hir_id(item_def_id); let item_hir_id = self.tcx.local_def_id_to_hir_id(item_def_id);
wbcx.visit_node_id(body.value.span, item_hir_id); wbcx.visit_node_id(body.value.span, item_hir_id);
} }
hir::BodyOwnerKind::Closure | hir::BodyOwnerKind::Fn => (), hir::BodyOwnerKind::Closure | hir::BodyOwnerKind::Fn => (),
@ -382,7 +382,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
.to_sorted(hcx, false) .to_sorted(hcx, false)
.into_iter() .into_iter()
.map(|(&closure_def_id, data)| { .map(|(&closure_def_id, data)| {
let closure_hir_id = self.tcx().hir().local_def_id_to_hir_id(closure_def_id); let closure_hir_id = self.tcx().local_def_id_to_hir_id(closure_def_id);
let data = self.resolve(*data, &closure_hir_id); let data = self.resolve(*data, &closure_hir_id);
(closure_def_id, data) (closure_def_id, data)
}) })
@ -407,7 +407,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
.map(|captured_place| { .map(|captured_place| {
let locatable = let locatable =
captured_place.info.path_expr_id.unwrap_or_else(|| { captured_place.info.path_expr_id.unwrap_or_else(|| {
self.tcx().hir().local_def_id_to_hir_id(closure_def_id) self.tcx().local_def_id_to_hir_id(closure_def_id)
}); });
self.resolve(captured_place.clone(), &locatable) self.resolve(captured_place.clone(), &locatable)
}) })
@ -433,7 +433,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
let resolved_fake_reads = fake_reads let resolved_fake_reads = fake_reads
.iter() .iter()
.map(|(place, cause, hir_id)| { .map(|(place, cause, hir_id)| {
let locatable = self.tcx().hir().local_def_id_to_hir_id(closure_def_id); let locatable = self.tcx().local_def_id_to_hir_id(closure_def_id);
let resolved_fake_read = self.resolve(place.clone(), &locatable); let resolved_fake_read = self.resolve(place.clone(), &locatable);
(resolved_fake_read, *cause, *hir_id) (resolved_fake_read, *cause, *hir_id)
}) })

View file

@ -122,7 +122,7 @@ impl<'tcx> IfThisChanged<'tcx> {
fn process_attrs(&mut self, def_id: LocalDefId) { fn process_attrs(&mut self, def_id: LocalDefId) {
let def_path_hash = self.tcx.def_path_hash(def_id.to_def_id()); let def_path_hash = self.tcx.def_path_hash(def_id.to_def_id());
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);
let attrs = self.tcx.hir().attrs(hir_id); let attrs = self.tcx.hir().attrs(hir_id);
for attr in attrs { for attr in attrs {
if attr.has_name(sym::rustc_if_this_changed) { if attr.has_name(sym::rustc_if_this_changed) {

View file

@ -363,7 +363,7 @@ impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
return false; return false;
}; };
let hir_id = self.tcx.hir().local_def_id_to_hir_id(anon_reg.def_id); let hir_id = self.tcx.local_def_id_to_hir_id(anon_reg.def_id);
let node = self.tcx.hir().get(hir_id); let node = self.tcx.hir().get(hir_id);
let is_impl = matches!(&node, hir::Node::ImplItem(_)); let is_impl = matches!(&node, hir::Node::ImplItem(_));

View file

@ -26,7 +26,7 @@ pub fn find_anon_type<'tcx>(
br: &ty::BoundRegionKind, br: &ty::BoundRegionKind,
) -> Option<(&'tcx hir::Ty<'tcx>, &'tcx hir::FnSig<'tcx>)> { ) -> Option<(&'tcx hir::Ty<'tcx>, &'tcx hir::FnSig<'tcx>)> {
let anon_reg = tcx.is_suitable_region(region)?; let anon_reg = tcx.is_suitable_region(region)?;
let hir_id = tcx.hir().local_def_id_to_hir_id(anon_reg.def_id); let hir_id = tcx.local_def_id_to_hir_id(anon_reg.def_id);
let fn_sig = tcx.hir().get(hir_id).fn_sig()?; let fn_sig = tcx.hir().get(hir_id).fn_sig()?;
fn_sig fn_sig

View file

@ -101,7 +101,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
ty::AssocKind::Fn => { ty::AssocKind::Fn => {
let hir = self.tcx().hir(); let hir = self.tcx().hir();
if let Some(hir_id) = if let Some(hir_id) =
assoc_item.def_id.as_local().map(|id| hir.local_def_id_to_hir_id(id)) assoc_item.def_id.as_local().map(|id| self.tcx().local_def_id_to_hir_id(id))
{ {
if let Some(decl) = hir.fn_decl_by_hir_id(hir_id) { if let Some(decl) = hir.fn_decl_by_hir_id(hir_id) {
visitor.visit_fn_decl(decl); visitor.visit_fn_decl(decl);

View file

@ -50,7 +50,7 @@ pub fn find_param_with_region<'tcx>(
let hir = &tcx.hir(); let hir = &tcx.hir();
let def_id = id.as_local()?; let def_id = id.as_local()?;
let hir_id = hir.local_def_id_to_hir_id(def_id); let hir_id = tcx.local_def_id_to_hir_id(def_id);
// FIXME: use def_kind // FIXME: use def_kind
// Don't perform this on closures // Don't perform this on closures

View file

@ -105,7 +105,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
); );
} }
p_def_id.as_local().and_then(|id| { p_def_id.as_local().and_then(|id| {
let local_id = tcx.hir().local_def_id_to_hir_id(id); let local_id = tcx.local_def_id_to_hir_id(id);
let generics = tcx.hir().find_parent(local_id)?.generics()?; let generics = tcx.hir().find_parent(local_id)?.generics()?;
Some((id, generics)) Some((id, generics))
}) })

View file

@ -374,7 +374,7 @@ impl<'tcx> InferCtxt<'tcx> {
/// in its defining scope. /// in its defining scope.
#[instrument(skip(self), level = "trace", ret)] #[instrument(skip(self), level = "trace", ret)]
pub fn opaque_type_origin(&self, def_id: LocalDefId) -> Option<OpaqueTyOrigin> { pub fn opaque_type_origin(&self, def_id: LocalDefId) -> Option<OpaqueTyOrigin> {
let opaque_hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id); let opaque_hir_id = self.tcx.local_def_id_to_hir_id(def_id);
let parent_def_id = match self.defining_use_anchor { let parent_def_id = match self.defining_use_anchor {
DefiningAnchor::Bubble | DefiningAnchor::Error => return None, DefiningAnchor::Bubble | DefiningAnchor::Error => return None,
DefiningAnchor::Bind(bind) => bind, DefiningAnchor::Bind(bind) => bind,
@ -671,7 +671,7 @@ impl<'tcx> InferCtxt<'tcx> {
/// and `opaque_hir_id` is the `HirId` of the definition of the opaque type `Baz`. /// and `opaque_hir_id` is the `HirId` of the definition of the opaque type `Baz`.
/// For the above example, this function returns `true` for `f1` and `false` for `f2`. /// For the above example, this function returns `true` for `f1` and `false` for `f2`.
fn may_define_opaque_type(tcx: TyCtxt<'_>, def_id: LocalDefId, opaque_hir_id: hir::HirId) -> bool { fn may_define_opaque_type(tcx: TyCtxt<'_>, def_id: LocalDefId, opaque_hir_id: hir::HirId) -> bool {
let mut hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let mut hir_id = tcx.local_def_id_to_hir_id(def_id);
// Named opaque types can be defined by any siblings or children of siblings. // Named opaque types can be defined by any siblings or children of siblings.
let scope = tcx.hir().get_defining_scope(opaque_hir_id); let scope = tcx.hir().get_defining_scope(opaque_hir_id);

View file

@ -507,7 +507,7 @@ impl MissingDoc {
} }
} }
let attrs = cx.tcx.hir().attrs(cx.tcx.hir().local_def_id_to_hir_id(def_id)); let attrs = cx.tcx.hir().attrs(cx.tcx.local_def_id_to_hir_id(def_id));
let has_doc = attrs.iter().any(has_doc); let has_doc = attrs.iter().any(has_doc);
if !has_doc { if !has_doc {
cx.emit_spanned_lint( cx.emit_spanned_lint(

View file

@ -356,7 +356,7 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
cached_typeck_results: Cell::new(None), cached_typeck_results: Cell::new(None),
param_env: ty::ParamEnv::empty(), param_env: ty::ParamEnv::empty(),
effective_visibilities: tcx.effective_visibilities(()), effective_visibilities: tcx.effective_visibilities(()),
last_node_with_lint_attrs: tcx.hir().local_def_id_to_hir_id(module_def_id), last_node_with_lint_attrs: tcx.local_def_id_to_hir_id(module_def_id.into()),
generics: None, generics: None,
only_module: true, only_module: true,
}; };

View file

@ -1811,7 +1811,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
// so we manually encode just the information that we need // so we manually encode just the information that we need
for &proc_macro in &tcx.resolutions(()).proc_macros { for &proc_macro in &tcx.resolutions(()).proc_macros {
let id = proc_macro; let id = proc_macro;
let proc_macro = hir.local_def_id_to_hir_id(proc_macro); let proc_macro = tcx.local_def_id_to_hir_id(proc_macro);
let mut name = hir.name(proc_macro); let mut name = hir.name(proc_macro);
let span = hir.span(proc_macro); let span = hir.span(proc_macro);
// Proc-macros may have attributes like `#[allow_internal_unstable]`, // Proc-macros may have attributes like `#[allow_internal_unstable]`,

View file

@ -116,7 +116,7 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
let parent_id = parent_id.map_or(CRATE_OWNER_ID, |local_def_index| { let parent_id = parent_id.map_or(CRATE_OWNER_ID, |local_def_index| {
let def_id = LocalDefId { 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); 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) 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. /// Do not call this function directly. The query should be called.
pub(super) fn def_kind(self, local_def_id: LocalDefId) -> DefKind { 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) { let node = match self.find(hir_id) {
Some(node) => node, Some(node) => node,
None => match self.def_key(local_def_id).disambiguated_data.data { None => match self.def_key(local_def_id).disambiguated_data.data {
@ -415,7 +410,7 @@ impl<'hir> Map<'hir> {
#[track_caller] #[track_caller]
pub fn body_owned_by(self, id: LocalDefId) -> BodyId { pub fn body_owned_by(self, id: LocalDefId) -> BodyId {
self.maybe_body_owned_by(id).unwrap_or_else(|| { 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!( span_bug!(
self.span(hir_id), self.span(hir_id),
"body_owned_by: {} has no associated body", "body_owned_by: {} has no associated body",

View file

@ -166,7 +166,7 @@ pub fn provide(providers: &mut Providers) {
providers.hir_owner_parent = |tcx, id| { providers.hir_owner_parent = |tcx, id| {
// Accessing the local_parent is ok since its value is hashed as part of `id`'s DefPathHash. // 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| { 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 = parent_hir_id.local_id =
tcx.hir_crate(()).owners[parent_hir_id.owner.def_id].unwrap().parenting[&id.def_id]; tcx.hir_crate(()).owners[parent_hir_id.owner.def_id].unwrap().parenting[&id.def_id];
parent_hir_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) tcx.hir_crate(()).owners[id.def_id].as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs)
}; };
providers.def_span = |tcx, def_id| { 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) tcx.hir().opt_span(hir_id).unwrap_or(DUMMY_SP)
}; };
providers.def_ident_span = |tcx, def_id| { 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) tcx.hir().opt_ident_span(hir_id)
}; };
providers.fn_arg_names = |tcx, def_id| { providers.fn_arg_names = |tcx, def_id| {
let hir = tcx.hir(); 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) { if let Some(body_id) = hir.maybe_body_owned_by(def_id) {
tcx.arena.alloc_from_iter(hir.body_param_names(body_id)) tcx.arena.alloc_from_iter(hir.body_param_names(body_id))
} else if let Node::TraitItem(&TraitItem { } else if let Node::TraitItem(&TraitItem {

View file

@ -110,7 +110,7 @@ impl<'tcx> TyCtxt<'tcx> {
let Some(local_def_id) = ct.def.as_local() else { return }; let Some(local_def_id) = ct.def.as_local() else { return };
self.struct_span_lint_hir( self.struct_span_lint_hir(
lint::builtin::CONST_EVALUATABLE_UNCHECKED, 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), self.def_span(ct.def),
"cannot use constants which depend on generic parameters in types", "cannot use constants which depend on generic parameters in types",
|err| err, |err| err,

View file

@ -72,7 +72,7 @@ impl OverlapMode {
.as_local() .as_local()
.into_iter() .into_iter()
.flat_map(|local_def_id| { .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)) .find(|attr| attr.has_name(sym::rustc_strict_coherence))
.map(|attr| attr.span); .map(|attr| attr.span);

View file

@ -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 user_provided_sig = typeck_results.user_provided_sigs[&def];
let captures = typeck_results.closure_min_captures_flattened(def); let captures = typeck_results.closure_min_captures_flattened(def);
let captures = tcx.arena.alloc_from_iter(captures); 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); let kind_origin = typeck_results.closure_kind_origins().get(hir_id);
ClosureTypeInfo { user_provided_sig, captures, kind_origin } ClosureTypeInfo { user_provided_sig, captures, kind_origin }
} }

View file

@ -1131,7 +1131,7 @@ impl<'tcx> TyCtxt<'tcx> {
self, self,
scope_def_id: LocalDefId, scope_def_id: LocalDefId,
) -> Vec<&'tcx hir::Ty<'tcx>> { ) -> 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), .. }) = let Some(hir::FnDecl { output: hir::FnRetTy::Return(hir_output), .. }) =
self.hir().fn_decl_by_hir_id(hir_id) self.hir().fn_decl_by_hir_id(hir_id)
else { else {
@ -1150,7 +1150,7 @@ impl<'tcx> TyCtxt<'tcx> {
self, self,
scope_def_id: LocalDefId, scope_def_id: LocalDefId,
) -> Option<(Vec<&'tcx hir::Ty<'tcx>>, Span, Option<Span>)> { ) -> 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()); let mut v = TraitObjectVisitor(vec![], self.hir());
// when the return type is a type alias // 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) if let Some(hir::FnDecl { output: hir::FnRetTy::Return(hir_output), .. }) = self.hir().fn_decl_by_hir_id(hir_id)

View file

@ -2273,7 +2273,7 @@ impl<'tcx> TyCtxt<'tcx> {
// FIXME(@lcnr): Remove this function. // FIXME(@lcnr): Remove this function.
pub fn get_attrs_unchecked(self, did: DefId) -> &'tcx [ast::Attribute] { pub fn get_attrs_unchecked(self, did: DefId) -> &'tcx [ast::Attribute] {
if let Some(did) = did.as_local() { 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 { } else {
self.item_attrs(did) self.item_attrs(did)
} }
@ -2288,7 +2288,7 @@ impl<'tcx> TyCtxt<'tcx> {
let did: DefId = did.into(); let did: DefId = did.into();
let filter_fn = move |a: &&ast::Attribute| a.has_name(attr); let filter_fn = move |a: &&ast::Attribute| a.has_name(attr);
if let Some(did) = did.as_local() { 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) { } 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); bug!("tried to access the `only_local` attribute `{}` from an extern crate", attr);
} else { } else {
@ -2306,7 +2306,7 @@ impl<'tcx> TyCtxt<'tcx> {
{ {
let filter_fn = move |a: &&ast::Attribute| a.path_matches(attr); let filter_fn = move |a: &&ast::Attribute| a.path_matches(attr);
if let Some(did) = did.as_local() { 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 { } else {
self.item_attrs(did).iter().filter(filter_fn) self.item_attrs(did).iter().filter(filter_fn)
} }

View file

@ -154,7 +154,7 @@ pub fn recursive_type_error(
let (_, field_id) = item_and_field_ids[i]; let (_, field_id) = item_and_field_ids[i];
let (next_item_id, _) = item_and_field_ids[(i + 1) % cycle_len]; let (next_item_id, _) = item_and_field_ids[(i + 1) % cycle_len];
// Find the span(s) that contain the next item in the cycle // 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 hir::Node::Field(field) = tcx.hir().get(hir_id) else { bug!("expected field") };
let mut found = Vec::new(); let mut found = Vec::new();
find_item_ty_spans(tcx, field.ty, next_item_id, &mut found, representable_ids); find_item_ty_spans(tcx, field.ty, next_item_id, &mut found, representable_ids);

View file

@ -451,7 +451,7 @@ fn construct_fn<'tcx>(
fn_sig: ty::FnSig<'tcx>, fn_sig: ty::FnSig<'tcx>,
) -> Body<'tcx> { ) -> Body<'tcx> {
let span = tcx.def_span(fn_def); 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); let coroutine_kind = tcx.coroutine_kind(fn_def);
// The representation of thir for `-Zunpretty=thir-tree` relies on // The representation of thir for `-Zunpretty=thir-tree` relies on
@ -569,7 +569,7 @@ fn construct_const<'a, 'tcx>(
expr: ExprId, expr: ExprId,
const_ty: Ty<'tcx>, const_ty: Ty<'tcx>,
) -> Body<'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. // Figure out what primary body this item has.
let (span, const_ty_span) = match tcx.hir().get(hir_id) { 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. /// with type errors, but normal MIR construction can't handle that in general.
fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -> Body<'_> { fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -> Body<'_> {
let span = tcx.def_span(def_id); 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 coroutine_kind = tcx.coroutine_kind(def_id);
let (inputs, output, yield_ty) = match tcx.def_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. // Runs all other queries that depend on THIR.
self.tcx.ensure_with_value().mir_built(def); self.tcx.ensure_with_value().mir_built(def);
let inner_thir = &inner_thir.steal(); 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 safety_context = mem::replace(&mut self.safety_context, SafetyContext::Safe);
let mut inner_visitor = UnsafetyVisitor { let mut inner_visitor = UnsafetyVisitor {
thir: inner_thir, thir: inner_thir,
@ -859,7 +859,7 @@ pub fn thir_check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
return; 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| { 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 { if fn_sig.header.unsafety == hir::Unsafety::Unsafe {
SafetyContext::UnsafeFn SafetyContext::UnsafeFn

View file

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

View file

@ -899,7 +899,7 @@ impl<'tcx> Cx<'tcx> {
} }
Res::Def(DefKind::ConstParam, def_id) => { 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 generics = self.tcx.generics_of(hir_id.owner);
let index = generics.param_def_id_to_index[&def_id]; let index = generics.param_def_id_to_index[&def_id];
let name = self.tcx.hir().name(hir_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 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) { 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 closure_env_param = cx.closure_env_param(owner_def, owner_id);
let explicit_params = cx.explicit_params(owner_id, fn_decl, body); 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> { fn new(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Cx<'tcx> {
let typeck_results = tcx.typeck(def); let typeck_results = tcx.typeck(def);
let hir = tcx.hir(); 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() { let body_type = if hir.body_owner_kind(def).is_fn_or_closure() {
// fetch the fully liberated fn signature (that is, all bound // 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, tcx,
thir: &*thir, thir: &*thir,
param_env: tcx.param_env(def_id), 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, let_source: LetSource::None,
pattern_arena: &pattern_arena, pattern_arena: &pattern_arena,
error: Ok(()), error: Ok(()),

View file

@ -452,7 +452,7 @@ fn check_unused_unsafe(
}; };
let body = tcx.hir().body(body_id); let body = tcx.hir().body(body_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 context = match tcx.hir().fn_sig_by_hir_id(hir_id) { let context = match tcx.hir().fn_sig_by_hir_id(hir_id) {
Some(sig) if sig.header.unsafety == hir::Unsafety::Unsafe => Context::UnsafeFn(hir_id), Some(sig) if sig.header.unsafety == hir::Unsafety::Unsafe => Context::UnsafeFn(hir_id),
_ => Context::Safe, _ => Context::Safe,
@ -568,7 +568,7 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) {
errors::UnsafeOpInUnsafeFn { errors::UnsafeOpInUnsafeFn {
details, details,
suggest_unsafe_block: suggest_unsafe_block.then(|| { suggest_unsafe_block: suggest_unsafe_block.then(|| {
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 fn_sig = tcx let fn_sig = tcx
.hir() .hir()
.fn_sig_by_hir_id(hir_id) .fn_sig_by_hir_id(hir_id)

View file

@ -110,7 +110,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
// However, we cannot allow stable `const fn`s to use unstable features without an explicit // However, we cannot allow stable `const fn`s to use unstable features without an explicit
// opt-in via `rustc_allow_const_fn_unstable`. // opt-in via `rustc_allow_const_fn_unstable`.
let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(def_id)); let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(def_id));
attr::rustc_allow_const_fn_unstable(tcx.sess, attrs).any(|name| name == feature_gate) attr::rustc_allow_const_fn_unstable(tcx.sess, attrs).any(|name| name == feature_gate)
}; };

View file

@ -559,7 +559,7 @@ fn has_allow_dead_code_or_lang_attr(
} }
fn has_allow_expect_dead_code(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { fn has_allow_expect_dead_code(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
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 lint_level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0; let lint_level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0;
matches!(lint_level, lint::Allow | lint::Expect(_)) matches!(lint_level, lint::Allow | lint::Expect(_))
} }
@ -805,10 +805,10 @@ impl<'tcx> DeadVisitor<'tcx> {
}; };
let tcx = self.tcx; let tcx = self.tcx;
let first_hir_id = tcx.hir().local_def_id_to_hir_id(first_id); let first_hir_id = tcx.local_def_id_to_hir_id(first_id);
let first_lint_level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, first_hir_id).0; let first_lint_level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, first_hir_id).0;
assert!(dead_codes.iter().skip(1).all(|id| { assert!(dead_codes.iter().skip(1).all(|id| {
let hir_id = tcx.hir().local_def_id_to_hir_id(*id); let hir_id = tcx.local_def_id_to_hir_id(*id);
let level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0; let level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0;
level == first_lint_level level == first_lint_level
})); }));
@ -969,7 +969,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
let def_id = item.id.owner_id.def_id; let def_id = item.id.owner_id.def_id;
if !visitor.is_live_code(def_id) { if !visitor.is_live_code(def_id) {
let name = tcx.item_name(def_id.to_def_id()); let name = tcx.item_name(def_id.to_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 level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0; let level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0;
dead_items.push(DeadItem { def_id, name, level }) dead_items.push(DeadItem { def_id, name, level })
@ -997,7 +997,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
let def_id = variant.def_id.expect_local(); let def_id = variant.def_id.expect_local();
if !live_symbols.contains(&def_id) { if !live_symbols.contains(&def_id) {
// Record to group diagnostics. // Record to group diagnostics.
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 level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0; let level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0;
dead_variants.push(DeadItem { def_id, name: variant.name, level }); dead_variants.push(DeadItem { def_id, name: variant.name, level });
continue; continue;
@ -1009,7 +1009,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
.iter() .iter()
.filter_map(|field| { .filter_map(|field| {
let def_id = field.did.expect_local(); let def_id = field.did.expect_local();
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);
if let ShouldWarnAboutField::Yes(is_pos) = if let ShouldWarnAboutField::Yes(is_pos) =
visitor.should_warn_about_field(field) visitor.should_warn_about_field(field)
{ {

View file

@ -42,7 +42,7 @@ impl<'tcx> LanguageItemCollector<'tcx> {
} }
fn check_for_lang(&mut self, actual_target: Target, def_id: LocalDefId) { fn check_for_lang(&mut self, actual_target: Target, def_id: LocalDefId) {
let attrs = self.tcx.hir().attrs(self.tcx.hir().local_def_id_to_hir_id(def_id)); let attrs = self.tcx.hir().attrs(self.tcx.local_def_id_to_hir_id(def_id));
if let Some((name, span)) = extract(attrs) { if let Some((name, span)) = extract(attrs) {
match LangItem::from_name(name) { match LangItem::from_name(name) {
// Known lang item with attribute on correct target. // Known lang item with attribute on correct target.

View file

@ -68,7 +68,7 @@ fn check_inline(tcx: TyCtxt<'_>, def_id: LocalDefId) {
/// Checks that function uses non-Rust ABI. /// Checks that function uses non-Rust ABI.
fn check_abi(tcx: TyCtxt<'_>, def_id: LocalDefId, abi: Abi) { fn check_abi(tcx: TyCtxt<'_>, def_id: LocalDefId, abi: Abi) {
if abi == Abi::Rust { if abi == Abi::Rust {
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 span = tcx.def_span(def_id); let span = tcx.def_span(def_id);
tcx.emit_spanned_lint( tcx.emit_spanned_lint(
UNDEFINED_NAKED_FUNCTION_ABI, UNDEFINED_NAKED_FUNCTION_ABI,

View file

@ -260,9 +260,7 @@ impl<'tcx> ReachableContext<'tcx> {
_ => { _ => {
bug!( bug!(
"found unexpected node kind in worklist: {} ({:?})", "found unexpected node kind in worklist: {} ({:?})",
self.tcx self.tcx.hir().node_to_string(self.tcx.local_def_id_to_hir_id(search_item)),
.hir()
.node_to_string(self.tcx.hir().local_def_id_to_hir_id(search_item)),
node, node,
); );
} }

View file

@ -111,7 +111,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
) where ) where
F: FnOnce(&mut Self), F: FnOnce(&mut Self),
{ {
let attrs = self.tcx.hir().attrs(self.tcx.hir().local_def_id_to_hir_id(def_id)); let attrs = self.tcx.hir().attrs(self.tcx.local_def_id_to_hir_id(def_id));
debug!("annotate(id = {:?}, attrs = {:?})", def_id, attrs); debug!("annotate(id = {:?}, attrs = {:?})", def_id, attrs);
let depr = attr::find_deprecation(self.tcx.sess, self.tcx.features(), attrs); let depr = attr::find_deprecation(self.tcx.sess, self.tcx.features(), attrs);
@ -120,7 +120,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
is_deprecated = true; is_deprecated = true;
if matches!(kind, AnnotationKind::Prohibited | AnnotationKind::DeprecationProhibited) { if matches!(kind, AnnotationKind::Prohibited | AnnotationKind::DeprecationProhibited) {
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);
self.tcx.emit_spanned_lint( self.tcx.emit_spanned_lint(
USELESS_DEPRECATED, USELESS_DEPRECATED,
hir_id, hir_id,

View file

@ -491,7 +491,7 @@ impl<'tcx> EmbargoVisitor<'tcx> {
macro_ev: EffectiveVisibility, macro_ev: EffectiveVisibility,
) { ) {
// Non-opaque macros cannot make other items more accessible than they already are. // Non-opaque macros cannot make other items more accessible than they already are.
let hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); let hir_id = self.tcx.local_def_id_to_hir_id(local_def_id);
let attrs = self.tcx.hir().attrs(hir_id); let attrs = self.tcx.hir().attrs(hir_id);
if attr::find_transparency(attrs, md.macro_rules).0 != Transparency::Opaque { if attr::find_transparency(attrs, md.macro_rules).0 != Transparency::Opaque {
return; return;
@ -1002,7 +1002,7 @@ impl<'tcx> NamePrivacyVisitor<'tcx> {
// definition of the field // definition of the field
let ident = Ident::new(kw::Empty, use_ctxt); let ident = Ident::new(kw::Empty, use_ctxt);
let hir_id = self.tcx.hir().local_def_id_to_hir_id(self.current_item); let hir_id = self.tcx.local_def_id_to_hir_id(self.current_item);
let def_id = self.tcx.adjust_ident_and_get_scope(ident, def.did(), hir_id).1; let def_id = self.tcx.adjust_ident_and_get_scope(ident, def.did(), hir_id).1;
if !field.vis.is_accessible_from(def_id, self.tcx) { if !field.vis.is_accessible_from(def_id, self.tcx) {
self.tcx.sess.emit_err(FieldIsPrivate { self.tcx.sess.emit_err(FieldIsPrivate {
@ -1440,7 +1440,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
if self.leaks_private_dep(def_id) { if self.leaks_private_dep(def_id) {
self.tcx.emit_spanned_lint( self.tcx.emit_spanned_lint(
lint::builtin::EXPORTED_PRIVATE_DEPENDENCIES, lint::builtin::EXPORTED_PRIVATE_DEPENDENCIES,
self.tcx.hir().local_def_id_to_hir_id(self.item_def_id), self.tcx.local_def_id_to_hir_id(self.item_def_id),
self.tcx.def_span(self.item_def_id.to_def_id()), self.tcx.def_span(self.item_def_id.to_def_id()),
FromPrivateDependencyInPublicInterface { FromPrivateDependencyInPublicInterface {
kind, kind,
@ -1497,7 +1497,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
}; };
self.tcx.emit_spanned_lint( self.tcx.emit_spanned_lint(
lint, lint,
self.tcx.hir().local_def_id_to_hir_id(self.item_def_id), self.tcx.local_def_id_to_hir_id(self.item_def_id),
span, span,
PrivateInterfacesOrBoundsLint { PrivateInterfacesOrBoundsLint {
item_span: span, item_span: span,
@ -1580,7 +1580,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
let reachable_at_vis = effective_vis.at_level(Level::Reachable); let reachable_at_vis = effective_vis.at_level(Level::Reachable);
if reachable_at_vis.is_public() && reexported_at_vis != reachable_at_vis { if reachable_at_vis.is_public() && reexported_at_vis != reachable_at_vis {
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);
let span = self.tcx.def_span(def_id.to_def_id()); let span = self.tcx.def_span(def_id.to_def_id());
self.tcx.emit_spanned_lint( self.tcx.emit_spanned_lint(
lint::builtin::UNNAMEABLE_TYPES, lint::builtin::UNNAMEABLE_TYPES,
@ -1820,7 +1820,7 @@ fn local_visibility(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Visibility {
match tcx.resolutions(()).visibilities.get(&def_id) { match tcx.resolutions(()).visibilities.get(&def_id) {
Some(vis) => *vis, Some(vis) => *vis,
None => { 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);
match tcx.hir().get(hir_id) { match tcx.hir().get(hir_id) {
// Unique types created for closures participate in type privacy checking. // Unique types created for closures participate in type privacy checking.
// They have visibilities inherited from the module they are defined in. // They have visibilities inherited from the module they are defined in.

View file

@ -393,7 +393,7 @@ impl IgnoredDiagnosticOption {
if let (Some(new_item), Some(old_item)) = (new, old) { if let (Some(new_item), Some(old_item)) = (new, old) {
tcx.emit_spanned_lint( tcx.emit_spanned_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.hir().local_def_id_to_hir_id(item_def_id.expect_local()), tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
new_item, new_item,
IgnoredDiagnosticOption { span: new_item, prev_span: old_item, option_name }, IgnoredDiagnosticOption { span: new_item, prev_span: old_item, option_name },
); );
@ -511,7 +511,7 @@ impl<'tcx> OnUnimplementedDirective {
if is_diagnostic_namespace_variant { if is_diagnostic_namespace_variant {
tcx.emit_spanned_lint( tcx.emit_spanned_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.hir().local_def_id_to_hir_id(item_def_id.expect_local()), tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
vec![item.span()], vec![item.span()],
MalformedOnUnimplementedAttrLint::new(item.span()), MalformedOnUnimplementedAttrLint::new(item.span()),
); );
@ -651,7 +651,7 @@ impl<'tcx> OnUnimplementedDirective {
tcx.emit_spanned_lint( tcx.emit_spanned_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.hir().local_def_id_to_hir_id(item_def_id.expect_local()), tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
report_span, report_span,
MalformedOnUnimplementedAttrLint::new(report_span), MalformedOnUnimplementedAttrLint::new(report_span),
); );
@ -662,14 +662,14 @@ impl<'tcx> OnUnimplementedDirective {
AttrKind::Normal(p) if !matches!(p.item.args, AttrArgs::Empty) => { AttrKind::Normal(p) if !matches!(p.item.args, AttrArgs::Empty) => {
tcx.emit_spanned_lint( tcx.emit_spanned_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.hir().local_def_id_to_hir_id(item_def_id.expect_local()), tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
attr.span, attr.span,
MalformedOnUnimplementedAttrLint::new(attr.span), MalformedOnUnimplementedAttrLint::new(attr.span),
); );
} }
_ => tcx.emit_spanned_lint( _ => tcx.emit_spanned_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.hir().local_def_id_to_hir_id(item_def_id.expect_local()), tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
attr.span, attr.span,
MissingOptionsForOnUnimplementedAttr, MissingOptionsForOnUnimplementedAttr,
), ),

View file

@ -871,7 +871,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}; };
let hir = self.tcx.hir(); let hir = self.tcx.hir();
let hir_id = hir.local_def_id_to_hir_id(def_id.as_local()?); let hir_id = self.tcx.local_def_id_to_hir_id(def_id.as_local()?);
match hir.find_parent(hir_id) { match hir.find_parent(hir_id) {
Some(hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(local), .. })) => { Some(hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(local), .. })) => {
get_name(err, &local.pat.kind) get_name(err, &local.pat.kind)
@ -2414,7 +2414,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
.tcx .tcx
.parent(coroutine_did) .parent(coroutine_did)
.as_local() .as_local()
.map(|parent_did| hir.local_def_id_to_hir_id(parent_did)) .map(|parent_did| self.tcx.local_def_id_to_hir_id(parent_did))
.and_then(|parent_hir_id| hir.opt_name(parent_hir_id)) .and_then(|parent_hir_id| hir.opt_name(parent_hir_id))
.map(|name| { .map(|name| {
format!("future returned by `{name}` is not {trait_name}") format!("future returned by `{name}` is not {trait_name}")
@ -2429,7 +2429,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
.tcx .tcx
.parent(coroutine_did) .parent(coroutine_did)
.as_local() .as_local()
.map(|parent_did| hir.local_def_id_to_hir_id(parent_did)) .map(|parent_did| self.tcx.local_def_id_to_hir_id(parent_did))
.and_then(|parent_hir_id| hir.opt_name(parent_hir_id)) .and_then(|parent_hir_id| hir.opt_name(parent_hir_id))
.map(|name| { .map(|name| {
format!("iterator returned by `{name}` is not {trait_name}") format!("iterator returned by `{name}` is not {trait_name}")

View file

@ -3075,7 +3075,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
// Additional context information explaining why the closure only implements // Additional context information explaining why the closure only implements
// a particular trait. // a particular trait.
if let Some(typeck_results) = &self.typeck_results { if let Some(typeck_results) = &self.typeck_results {
let hir_id = self.tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local()); let hir_id = self.tcx.local_def_id_to_hir_id(closure_def_id.expect_local());
match (found_kind, typeck_results.closure_kind_origins().get(hir_id)) { match (found_kind, typeck_results.closure_kind_origins().get(hir_id)) {
(ty::ClosureKind::FnOnce, Some((span, place))) => { (ty::ClosureKind::FnOnce, Some((span, place))) => {
err.fn_once_label = Some(ClosureFnOnceLabel { err.fn_once_label = Some(ClosureFnOnceLabel {

View file

@ -442,7 +442,7 @@ fn report_conflicting_impls<'tcx>(
}; };
tcx.struct_span_lint_hir( tcx.struct_span_lint_hir(
lint, lint,
tcx.hir().local_def_id_to_hir_id(impl_def_id), tcx.local_def_id_to_hir_id(impl_def_id),
impl_span, impl_span,
msg, msg,
|err| { |err| {

View file

@ -94,7 +94,7 @@ fn impl_item_implementor_ids(tcx: TyCtxt<'_>, impl_id: DefId) -> DefIdMap<DefId>
} }
fn associated_item(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AssocItem { fn associated_item(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AssocItem {
let id = tcx.hir().local_def_id_to_hir_id(def_id); let id = tcx.local_def_id_to_hir_id(def_id);
let parent_def_id = tcx.hir().get_parent_item(id); let parent_def_id = tcx.hir().get_parent_item(id);
let parent_item = tcx.hir().expect_item(parent_def_id.def_id); let parent_item = tcx.hir().expect_item(parent_def_id.def_id);
match parent_item.kind { match parent_item.kind {

View file

@ -81,8 +81,8 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
/// For the above example, this function returns `true` for `f1` and `false` for `f2`. /// For the above example, this function returns `true` for `f1` and `false` for `f2`.
#[instrument(level = "trace", skip(self), ret)] #[instrument(level = "trace", skip(self), ret)]
fn check_tait_defining_scope(&self, opaque_def_id: LocalDefId) -> bool { fn check_tait_defining_scope(&self, opaque_def_id: LocalDefId) -> bool {
let mut hir_id = self.tcx.hir().local_def_id_to_hir_id(self.item); let mut hir_id = self.tcx.local_def_id_to_hir_id(self.item);
let opaque_hir_id = self.tcx.hir().local_def_id_to_hir_id(opaque_def_id); let opaque_hir_id = self.tcx.local_def_id_to_hir_id(opaque_def_id);
// Named opaque types can be defined by any siblings or children of siblings. // Named opaque types can be defined by any siblings or children of siblings.
let scope = self.tcx.hir().get_defining_scope(opaque_hir_id); let scope = self.tcx.hir().get_defining_scope(opaque_hir_id);

View file

@ -640,7 +640,7 @@ fn build_module_items(
pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String { pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String {
if let Some(did) = did.as_local() { if let Some(did) = did.as_local() {
let hir_id = tcx.hir().local_def_id_to_hir_id(did); let hir_id = tcx.local_def_id_to_hir_id(did);
rustc_hir_pretty::id_to_string(&tcx.hir(), hir_id) rustc_hir_pretty::id_to_string(&tcx.hir(), hir_id)
} else { } else {
tcx.rendered_const(did).clone() tcx.rendered_const(did).clone()

View file

@ -345,7 +345,7 @@ pub(crate) fn rustc_span(def_id: DefId, tcx: TyCtxt<'_>) -> Span {
|| tcx.def_span(def_id), || tcx.def_span(def_id),
|local| { |local| {
let hir = tcx.hir(); let hir = tcx.hir();
hir.span_with_body(hir.local_def_id_to_hir_id(local)) hir.span_with_body(tcx.local_def_id_to_hir_id(local))
}, },
)) ))
} }

View file

@ -107,12 +107,12 @@ impl<'tcx> DocContext<'tcx> {
r r
} }
/// Like `hir().local_def_id_to_hir_id()`, but skips calling it on fake DefIds. /// Like `tcx.local_def_id_to_hir_id()`, but skips calling it on fake DefIds.
/// (This avoids a slice-index-out-of-bounds panic.) /// (This avoids a slice-index-out-of-bounds panic.)
pub(crate) fn as_local_hir_id(tcx: TyCtxt<'_>, item_id: ItemId) -> Option<HirId> { pub(crate) fn as_local_hir_id(tcx: TyCtxt<'_>, item_id: ItemId) -> Option<HirId> {
match item_id { match item_id {
ItemId::DefId(real_id) => { ItemId::DefId(real_id) => {
real_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id)) real_id.as_local().map(|def_id| tcx.local_def_id_to_hir_id(def_id))
} }
// FIXME: Can this be `Some` for `Auto` or `Blanket`? // FIXME: Can this be `Some` for `Auto` or `Blanket`?
_ => None, _ => None,

View file

@ -1207,7 +1207,7 @@ impl<'a, 'hir, 'tcx> HirCollector<'a, 'hir, 'tcx> {
sp: Span, sp: Span,
nested: F, nested: F,
) { ) {
let ast_attrs = self.tcx.hir().attrs(self.tcx.hir().local_def_id_to_hir_id(def_id)); let ast_attrs = self.tcx.hir().attrs(self.tcx.local_def_id_to_hir_id(def_id));
if let Some(ref cfg) = ast_attrs.cfg(self.tcx, &FxHashSet::default()) { if let Some(ref cfg) = ast_attrs.cfg(self.tcx, &FxHashSet::default()) {
if !cfg.matches(&self.sess.parse_sess, Some(self.tcx.features())) { if !cfg.matches(&self.sess.parse_sess, Some(self.tcx.features())) {
return; return;

View file

@ -841,7 +841,7 @@ impl<'tcx> ExtraInfo<'tcx> {
if let Some(def_id) = self.def_id.as_local() { if let Some(def_id) = self.def_id.as_local() {
self.tcx.struct_span_lint_hir( self.tcx.struct_span_lint_hir(
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES, crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
self.tcx.hir().local_def_id_to_hir_id(def_id), self.tcx.local_def_id_to_hir_id(def_id),
self.sp, self.sp,
msg, msg,
|l| l, |l| l,
@ -857,7 +857,7 @@ impl<'tcx> ExtraInfo<'tcx> {
if let Some(def_id) = self.def_id.as_local() { if let Some(def_id) = self.def_id.as_local() {
self.tcx.struct_span_lint_hir( self.tcx.struct_span_lint_hir(
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES, crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
self.tcx.hir().local_def_id_to_hir_id(def_id), self.tcx.local_def_id_to_hir_id(def_id),
self.sp, self.sp,
msg, msg,
|lint| lint.help(help), |lint| lint.help(help),

View file

@ -100,7 +100,7 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -
} }
let (level, source) = cx.tcx.lint_level_at_node( let (level, source) = cx.tcx.lint_level_at_node(
crate::lint::MISSING_DOC_CODE_EXAMPLES, crate::lint::MISSING_DOC_CODE_EXAMPLES,
cx.tcx.hir().local_def_id_to_hir_id(def_id), cx.tcx.local_def_id_to_hir_id(def_id),
); );
level != lint::Level::Allow || matches!(source, LintLevelSource::Default) level != lint::Level::Allow || matches!(source, LintLevelSource::Default)
} }

View file

@ -98,7 +98,7 @@ fn check_rust_syntax(
// Finally build and emit the completed diagnostic. // Finally build and emit the completed diagnostic.
// All points of divergence have been handled earlier so this can be // All points of divergence have been handled earlier so this can be
// done the same way whether the span is precise or not. // done the same way whether the span is precise or not.
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id); let hir_id = cx.tcx.local_def_id_to_hir_id(local_id);
cx.tcx.struct_span_lint_hir(crate::lint::INVALID_RUST_CODEBLOCKS, hir_id, sp, msg, |lint| { cx.tcx.struct_span_lint_hir(crate::lint::INVALID_RUST_CODEBLOCKS, hir_id, sp, msg, |lint| {
let explanation = if is_ignore { let explanation = if is_ignore {
"`ignore` code blocks require valid Rust code for syntax highlighting; \ "`ignore` code blocks require valid Rust code for syntax highlighting; \

View file

@ -242,7 +242,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
}; };
let document_hidden = self.cx.render_options.document_hidden; let document_hidden = self.cx.render_options.document_hidden;
let use_attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(def_id)); let use_attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(def_id));
// Don't inline `doc(hidden)` imports so they can be stripped at a later stage. // Don't inline `doc(hidden)` imports so they can be stripped at a later stage.
let is_no_inline = use_attrs.lists(sym::doc).has_word(sym::no_inline) let is_no_inline = use_attrs.lists(sym::doc).has_word(sym::no_inline)
|| (document_hidden && use_attrs.lists(sym::doc).has_word(sym::hidden)); || (document_hidden && use_attrs.lists(sym::doc).has_word(sym::hidden));
@ -446,8 +446,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
continue; continue;
} }
let attrs = let attrs = tcx.hir().attrs(tcx.local_def_id_to_hir_id(item.owner_id.def_id));
tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(item.owner_id.def_id));
// If there was a private module in the current path then don't bother inlining // If there was a private module in the current path then don't bother inlining
// anything as it will probably be stripped anyway. // anything as it will probably be stripped anyway.

View file

@ -255,7 +255,7 @@ fn check_hash_peq<'tcx>(
"you are deriving `Hash` but have implemented `PartialEq` explicitly", "you are deriving `Hash` but have implemented `PartialEq` explicitly",
|diag| { |diag| {
if let Some(local_def_id) = impl_id.as_local() { if let Some(local_def_id) = impl_id.as_local() {
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id); let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialEq` implemented here"); diag.span_note(cx.tcx.hir().span(hir_id), "`PartialEq` implemented here");
} }
}, },
@ -299,7 +299,7 @@ fn check_ord_partial_ord<'tcx>(
span_lint_and_then(cx, DERIVE_ORD_XOR_PARTIAL_ORD, span, mess, |diag| { span_lint_and_then(cx, DERIVE_ORD_XOR_PARTIAL_ORD, span, mess, |diag| {
if let Some(local_def_id) = impl_id.as_local() { if let Some(local_def_id) = impl_id.as_local() {
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id); let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialOrd` implemented here"); diag.span_note(cx.tcx.hir().span(hir_id), "`PartialOrd` implemented here");
} }
}); });
@ -381,7 +381,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
&& match_def_path(cx, trait_def_id, &paths::SERDE_DESERIALIZE) && match_def_path(cx, trait_def_id, &paths::SERDE_DESERIALIZE)
&& let ty::Adt(def, _) = ty.kind() && let ty::Adt(def, _) = ty.kind()
&& let Some(local_def_id) = def.did().as_local() && let Some(local_def_id) = def.did().as_local()
&& let adt_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id) && let adt_hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id)
&& !is_lint_allowed(cx, UNSAFE_DERIVE_DESERIALIZE, adt_hir_id) && !is_lint_allowed(cx, UNSAFE_DERIVE_DESERIALIZE, adt_hir_id)
&& cx && cx
.tcx .tcx

View file

@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for ErrorImplError {
if let Some(trait_def_id) = imp.of_trait.and_then(|t| t.trait_def_id()) if let Some(trait_def_id) = imp.of_trait.and_then(|t| t.trait_def_id())
&& error_def_id == trait_def_id && error_def_id == trait_def_id
&& let Some(def_id) = path_res(cx, imp.self_ty).opt_def_id().and_then(DefId::as_local) && let Some(def_id) = path_res(cx, imp.self_ty).opt_def_id().and_then(DefId::as_local)
&& let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id) && let hir_id = cx.tcx.local_def_id_to_hir_id(def_id)
&& let Some(ident) = cx.tcx.opt_item_ident(def_id.to_def_id()) && let Some(ident) = cx.tcx.opt_item_ident(def_id.to_def_id())
&& ident.name == sym::Error && ident.name == sym::Error
&& is_visible_outside_module(cx, def_id) => && is_visible_outside_module(cx, def_id) =>

View file

@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
let parent_id = cx let parent_id = cx
.tcx .tcx
.hir() .hir()
.get_parent_item(cx.tcx.hir().local_def_id_to_hir_id(fn_def_id)) .get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
.def_id; .def_id;
let parent_node = cx.tcx.hir().find_by_def_id(parent_id); let parent_node = cx.tcx.hir().find_by_def_id(parent_id);

View file

@ -171,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
span: Span, span: Span,
def_id: LocalDefId, def_id: LocalDefId,
) { ) {
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
if let Some(fn_header) = fn_kind.header() if let Some(fn_header) = fn_kind.header()
&& fn_header.abi == Abi::Rust && fn_header.abi == Abi::Rust
&& get_parent_as_impl(cx.tcx, hir_id).map_or(true, |impl_item| impl_item.of_trait.is_none()) && get_parent_as_impl(cx.tcx, hir_id).map_or(true, |impl_item| impl_item.of_trait.is_none())

View file

@ -407,7 +407,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
span: Span, span: Span,
def_id: LocalDefId, def_id: LocalDefId,
) { ) {
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
too_many_arguments::check_fn(cx, kind, decl, span, hir_id, self.too_many_arguments_threshold); too_many_arguments::check_fn(cx, kind, decl, span, hir_id, self.too_many_arguments_threshold);
too_many_lines::check_fn(cx, kind, span, body, self.too_many_lines_threshold); too_many_lines::check_fn(cx, kind, span, body, self.too_many_lines_threshold);
not_unsafe_ptr_arg_deref::check_fn(cx, kind, decl, body, def_id); not_unsafe_ptr_arg_deref::check_fn(cx, kind, decl, body, def_id);

View file

@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
if let FnKind::Closure = kind { if let FnKind::Closure = kind {
return; return;
} }
let ret_ty = return_ty(cx, cx.tcx.hir().local_def_id_to_hir_id(fn_def_id).expect_owner()); let ret_ty = return_ty(cx, cx.tcx.local_def_id_to_hir_id(fn_def_id).expect_owner());
if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() { if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() {
let preds = cx.tcx.explicit_item_bounds(def_id); let preds = cx.tcx.explicit_item_bounds(def_id);
let mut is_future = false; let mut is_future = false;

View file

@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
&& !is_lint_allowed( && !is_lint_allowed(
cx, cx,
MULTIPLE_INHERENT_IMPL, MULTIPLE_INHERENT_IMPL,
cx.tcx.hir().local_def_id_to_hir_id(id), cx.tcx.local_def_id_to_hir_id(id),
) )
}) { }) {
for impl_id in impl_ids.iter().map(|id| id.expect_local()) { for impl_id in impl_ids.iter().map(|id| id.expect_local()) {
@ -117,7 +117,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
/// Gets the span for the given impl block unless it's not being considered by the lint. /// Gets the span for the given impl block unless it's not being considered by the lint.
fn get_impl_span(cx: &LateContext<'_>, id: LocalDefId) -> Option<Span> { fn get_impl_span(cx: &LateContext<'_>, id: LocalDefId) -> Option<Span> {
let id = cx.tcx.hir().local_def_id_to_hir_id(id); let id = cx.tcx.local_def_id_to_hir_id(id);
if let Node::Item(&Item { if let Node::Item(&Item {
kind: ItemKind::Impl(impl_item), kind: ItemKind::Impl(impl_item),
span, span,

View file

@ -142,7 +142,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
&& let TyKind::Path(ty_path) = &imp.self_ty.kind && let TyKind::Path(ty_path) = &imp.self_ty.kind
&& let Some(ty_id) = cx.qpath_res(ty_path, imp.self_ty.hir_id).opt_def_id() && let Some(ty_id) = cx.qpath_res(ty_path, imp.self_ty.hir_id).opt_def_id()
&& let Some(local_id) = ty_id.as_local() && let Some(local_id) = ty_id.as_local()
&& let ty_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id) && let ty_hir_id = cx.tcx.local_def_id_to_hir_id(local_id)
&& !is_lint_allowed(cx, LEN_WITHOUT_IS_EMPTY, ty_hir_id) && !is_lint_allowed(cx, LEN_WITHOUT_IS_EMPTY, ty_hir_id)
&& let Some(output) = && let Some(output) =
parse_len_output(cx, cx.tcx.fn_sig(item.owner_id).instantiate_identity().skip_binder()) parse_len_output(cx, cx.tcx.fn_sig(item.owner_id).instantiate_identity().skip_binder())

View file

@ -192,7 +192,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustiveEnum {
.contains(&(enum_id.to_def_id(), variant_id.to_def_id())) .contains(&(enum_id.to_def_id(), variant_id.to_def_id()))
}) })
{ {
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(enum_id); let hir_id = cx.tcx.local_def_id_to_hir_id(enum_id);
span_lint_hir_and_then( span_lint_hir_and_then(
cx, cx,
MANUAL_NON_EXHAUSTIVE, MANUAL_NON_EXHAUSTIVE,

View file

@ -27,7 +27,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, arg: &
closure.def_id.to_def_id(), closure.def_id.to_def_id(),
Binder::bind_with_vars( Binder::bind_with_vars(
cx.typeck_results().node_type(param_ty.hir_id), cx.typeck_results().node_type(param_ty.hir_id),
cx.tcx.late_bound_vars(cx.tcx.hir().local_def_id_to_hir_id(closure.def_id)), cx.tcx.late_bound_vars(cx.tcx.local_def_id_to_hir_id(closure.def_id)),
), ),
) )
&& is_copy(cx, param_ty) && is_copy(cx, param_ty)

View file

@ -131,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
FnKind::Closure => return, FnKind::Closure => return,
} }
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
// Const fns are not allowed as methods in a trait. // Const fns are not allowed as methods in a trait.
{ {

View file

@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
return; return;
} }
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(fn_def_id); let hir_id = cx.tcx.local_def_id_to_hir_id(fn_def_id);
let is_async = match kind { let is_async = match kind {
FnKind::ItemFn(.., header) => { FnKind::ItemFn(.., header) => {
if header.is_unsafe() { if header.is_unsafe() {
@ -256,7 +256,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
span_lint_hir_and_then( span_lint_hir_and_then(
cx, cx,
NEEDLESS_PASS_BY_REF_MUT, NEEDLESS_PASS_BY_REF_MUT,
cx.tcx.hir().local_def_id_to_hir_id(*fn_def_id), cx.tcx.local_def_id_to_hir_id(*fn_def_id),
sp, sp,
"this argument is a mutable reference, but not used mutably", "this argument is a mutable reference, but not used mutably",
|diag| { |diag| {

View file

@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
return; return;
} }
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(fn_def_id); let hir_id = cx.tcx.local_def_id_to_hir_id(fn_def_id);
match kind { match kind {
FnKind::ItemFn(.., header) => { FnKind::ItemFn(.., header) => {

View file

@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
let ty = cx.tcx.type_of(d).instantiate_identity(); let ty = cx.tcx.type_of(d).instantiate_identity();
if let Some(ty_def) = ty.ty_adt_def() { if let Some(ty_def) = ty.ty_adt_def() {
if let Some(local_def_id) = ty_def.did().as_local() { if let Some(local_def_id) = ty_def.did().as_local() {
impls.insert(cx.tcx.hir().local_def_id_to_hir_id(local_def_id)); impls.insert(cx.tcx.local_def_id_to_hir_id(local_def_id));
} }
} }
}); });
@ -119,7 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
&& let self_def = cx.tcx.type_of(self_def_id).instantiate_identity() && let self_def = cx.tcx.type_of(self_def_id).instantiate_identity()
&& let Some(self_def) = self_def.ty_adt_def() && let Some(self_def) = self_def.ty_adt_def()
&& let Some(self_local_did) = self_def.did().as_local() && let Some(self_local_did) = self_def.did().as_local()
&& let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_local_did) && let self_id = cx.tcx.local_def_id_to_hir_id(self_local_did)
&& impling_types.contains(&self_id) && impling_types.contains(&self_id)
{ {
return; return;

View file

@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
if let Some(field_hir_id) = field if let Some(field_hir_id) = field
.did .did
.as_local() .as_local()
.map(|local_def_id| hir_map.local_def_id_to_hir_id(local_def_id)) .map(|local_def_id| cx.tcx.local_def_id_to_hir_id(local_def_id))
&& !is_lint_allowed(cx, NON_SEND_FIELDS_IN_SEND_TY, field_hir_id) && !is_lint_allowed(cx, NON_SEND_FIELDS_IN_SEND_TY, field_hir_id)
&& let field_ty = field.ty(cx.tcx, impl_trait_args) && let field_ty = field.ty(cx.tcx, impl_trait_args)
&& !ty_allowed_in_send(cx, field_ty, send_trait) && !ty_allowed_in_send(cx, field_ty, send_trait)

Some files were not shown because too many files have changed in this diff Show more