Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 55a92cf

Browse files
committedMar 21, 2024
Avoid lots of hir::HirId{,Map,Set} qualifiers.
Because they're a bit redundant.
1 parent eba9934 commit 55a92cf

File tree

39 files changed

+301
-337
lines changed

39 files changed

+301
-337
lines changed
 

‎compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_ast::*;
1414
use rustc_data_structures::stack::ensure_sufficient_stack;
1515
use rustc_hir as hir;
1616
use rustc_hir::def::{DefKind, Res};
17+
use rustc_hir::HirId;
1718
use rustc_middle::span_bug;
1819
use rustc_session::errors::report_lit_error;
1920
use rustc_span::source_map::{respan, Spanned};
@@ -698,8 +699,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
698699
pub(super) fn maybe_forward_track_caller(
699700
&mut self,
700701
span: Span,
701-
outer_hir_id: hir::HirId,
702-
inner_hir_id: hir::HirId,
702+
outer_hir_id: HirId,
703+
inner_hir_id: HirId,
703704
) {
704705
if self.tcx.features().async_fn_track_caller
705706
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
@@ -1045,7 +1046,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10451046
binder: &ClosureBinder,
10461047
capture_clause: CaptureBy,
10471048
closure_id: NodeId,
1048-
closure_hir_id: hir::HirId,
1049+
closure_hir_id: HirId,
10491050
coroutine_kind: CoroutineKind,
10501051
decl: &FnDecl,
10511052
body: &Expr,
@@ -2033,7 +2034,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
20332034
&mut self,
20342035
sp: Span,
20352036
ident: Ident,
2036-
binding: hir::HirId,
2037+
binding: HirId,
20372038
) -> &'hir hir::Expr<'hir> {
20382039
self.arena.alloc(self.expr_ident_mut(sp, ident, binding))
20392040
}
@@ -2042,7 +2043,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
20422043
&mut self,
20432044
span: Span,
20442045
ident: Ident,
2045-
binding: hir::HirId,
2046+
binding: HirId,
20462047
) -> hir::Expr<'hir> {
20472048
let hir_id = self.next_id();
20482049
let res = Res::Local(binding);

‎compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use rustc_hir as hir;
5656
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5757
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
5858
use rustc_hir::{
59-
ConstArg, GenericArg, ItemLocalMap, MissingLifetimeKind, ParamName, TraitCandidate,
59+
ConstArg, GenericArg, HirId, ItemLocalMap, MissingLifetimeKind, ParamName, TraitCandidate,
6060
};
6161
use rustc_index::{Idx, IndexSlice, IndexVec};
6262
use rustc_macros::extension;
@@ -107,7 +107,7 @@ struct LoweringContext<'a, 'hir> {
107107

108108
/// When inside an `async` context, this is the `HirId` of the
109109
/// `task_context` local bound to the resume argument of the coroutine.
110-
task_context: Option<hir::HirId>,
110+
task_context: Option<HirId>,
111111

112112
/// Used to get the current `fn`'s def span to point to when using `await`
113113
/// outside of an `async fn`.
@@ -661,18 +661,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
661661
/// `HirIdValidator` later on, which makes sure that all `NodeId`s got mapped
662662
/// properly. Calling the method twice with the same `NodeId` is fine though.
663663
#[instrument(level = "debug", skip(self), ret)]
664-
fn lower_node_id(&mut self, ast_node_id: NodeId) -> hir::HirId {
664+
fn lower_node_id(&mut self, ast_node_id: NodeId) -> HirId {
665665
assert_ne!(ast_node_id, DUMMY_NODE_ID);
666666

667667
match self.node_id_to_local_id.entry(ast_node_id) {
668-
Entry::Occupied(o) => {
669-
hir::HirId { owner: self.current_hir_id_owner, local_id: *o.get() }
670-
}
668+
Entry::Occupied(o) => HirId { owner: self.current_hir_id_owner, local_id: *o.get() },
671669
Entry::Vacant(v) => {
672670
// Generate a new `HirId`.
673671
let owner = self.current_hir_id_owner;
674672
let local_id = self.item_local_id_counter;
675-
let hir_id = hir::HirId { owner, local_id };
673+
let hir_id = HirId { owner, local_id };
676674

677675
v.insert(local_id);
678676
self.item_local_id_counter.increment_by(1);
@@ -693,20 +691,20 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
693691

694692
/// Generate a new `HirId` without a backing `NodeId`.
695693
#[instrument(level = "debug", skip(self), ret)]
696-
fn next_id(&mut self) -> hir::HirId {
694+
fn next_id(&mut self) -> HirId {
697695
let owner = self.current_hir_id_owner;
698696
let local_id = self.item_local_id_counter;
699697
assert_ne!(local_id, hir::ItemLocalId::new(0));
700698
self.item_local_id_counter.increment_by(1);
701-
hir::HirId { owner, local_id }
699+
HirId { owner, local_id }
702700
}
703701

704702
#[instrument(level = "trace", skip(self))]
705703
fn lower_res(&mut self, res: Res<NodeId>) -> Res {
706704
let res: Result<Res, ()> = res.apply_id(|id| {
707705
let owner = self.current_hir_id_owner;
708706
let local_id = self.node_id_to_local_id.get(&id).copied().ok_or(())?;
709-
Ok(hir::HirId { owner, local_id })
707+
Ok(HirId { owner, local_id })
710708
});
711709
trace!(?res);
712710

@@ -889,7 +887,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
889887
ret
890888
}
891889

892-
fn lower_attrs(&mut self, id: hir::HirId, attrs: &[Attribute]) -> Option<&'hir [Attribute]> {
890+
fn lower_attrs(&mut self, id: HirId, attrs: &[Attribute]) -> Option<&'hir [Attribute]> {
893891
if attrs.is_empty() {
894892
None
895893
} else {
@@ -921,7 +919,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
921919
Attribute { kind, id: attr.id, style: attr.style, span: self.lower_span(attr.span) }
922920
}
923921

924-
fn alias_attrs(&mut self, id: hir::HirId, target_id: hir::HirId) {
922+
fn alias_attrs(&mut self, id: HirId, target_id: HirId) {
925923
debug_assert_eq!(id.owner, self.current_hir_id_owner);
926924
debug_assert_eq!(target_id.owner, self.current_hir_id_owner);
927925
if let Some(&a) = self.attrs.get(&target_id.local_id) {
@@ -2418,11 +2416,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24182416
self.pat(span, hir::PatKind::Struct(qpath, fields, false))
24192417
}
24202418

2421-
fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, hir::HirId) {
2419+
fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, HirId) {
24222420
self.pat_ident_binding_mode(span, ident, hir::BindingAnnotation::NONE)
24232421
}
24242422

2425-
fn pat_ident_mut(&mut self, span: Span, ident: Ident) -> (hir::Pat<'hir>, hir::HirId) {
2423+
fn pat_ident_mut(&mut self, span: Span, ident: Ident) -> (hir::Pat<'hir>, HirId) {
24262424
self.pat_ident_binding_mode_mut(span, ident, hir::BindingAnnotation::NONE)
24272425
}
24282426

@@ -2431,7 +2429,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24312429
span: Span,
24322430
ident: Ident,
24332431
bm: hir::BindingAnnotation,
2434-
) -> (&'hir hir::Pat<'hir>, hir::HirId) {
2432+
) -> (&'hir hir::Pat<'hir>, HirId) {
24352433
let (pat, hir_id) = self.pat_ident_binding_mode_mut(span, ident, bm);
24362434
(self.arena.alloc(pat), hir_id)
24372435
}
@@ -2441,7 +2439,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24412439
span: Span,
24422440
ident: Ident,
24432441
bm: hir::BindingAnnotation,
2444-
) -> (hir::Pat<'hir>, hir::HirId) {
2442+
) -> (hir::Pat<'hir>, HirId) {
24452443
let hir_id = self.next_id();
24462444

24472445
(
@@ -2473,12 +2471,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24732471
}
24742472
}
24752473

2476-
fn ty_path(
2477-
&mut self,
2478-
mut hir_id: hir::HirId,
2479-
span: Span,
2480-
qpath: hir::QPath<'hir>,
2481-
) -> hir::Ty<'hir> {
2474+
fn ty_path(&mut self, mut hir_id: HirId, span: Span, qpath: hir::QPath<'hir>) -> hir::Ty<'hir> {
24822475
let kind = match qpath {
24832476
hir::QPath::Resolved(None, path) => {
24842477
// Turn trait object paths into `TyKind::TraitObject` instead.

‎compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_hir as hir;
2424
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
2525
use rustc_hir::def_id::{DefId, LocalDefId};
2626
use rustc_hir::intravisit::{walk_generics, Visitor as _};
27-
use rustc_hir::{GenericArg, GenericArgs};
27+
use rustc_hir::{GenericArg, GenericArgs, HirId};
2828
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
2929
use rustc_infer::traits::ObligationCause;
3030
use rustc_middle::middle::stability::AllowUnstable;
@@ -137,7 +137,7 @@ pub trait AstConv<'tcx> {
137137
/// report.
138138
fn set_tainted_by_errors(&self, e: ErrorGuaranteed);
139139

140-
fn record_ty(&self, hir_id: hir::HirId, ty: Ty<'tcx>, span: Span);
140+
fn record_ty(&self, hir_id: HirId, ty: Ty<'tcx>, span: Span);
141141

142142
fn astconv(&self) -> &dyn AstConv<'tcx>
143143
where
@@ -943,7 +943,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
943943
#[instrument(level = "debug", skip(self, hir_ref_id, span, qself, assoc_segment), fields(assoc_ident=?assoc_segment.ident), ret)]
944944
pub fn associated_path_to_ty(
945945
&self,
946-
hir_ref_id: hir::HirId,
946+
hir_ref_id: HirId,
947947
span: Span,
948948
qself_ty: Ty<'tcx>,
949949
qself: &hir::Ty<'_>,
@@ -1226,7 +1226,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
12261226
segment: &hir::PathSegment<'tcx>,
12271227
adt_did: DefId,
12281228
self_ty: Ty<'tcx>,
1229-
block: hir::HirId,
1229+
block: HirId,
12301230
span: Span,
12311231
) -> Result<Option<(Ty<'tcx>, DefId)>, ErrorGuaranteed> {
12321232
let tcx = self.tcx();
@@ -1377,7 +1377,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
13771377
fn lookup_assoc_ty(
13781378
&self,
13791379
name: Ident,
1380-
block: hir::HirId,
1380+
block: HirId,
13811381
span: Span,
13821382
scope: DefId,
13831383
) -> Option<DefId> {
@@ -1389,7 +1389,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
13891389
fn lookup_assoc_ty_unchecked(
13901390
&self,
13911391
name: Ident,
1392-
block: hir::HirId,
1392+
block: HirId,
13931393
scope: DefId,
13941394
) -> Option<(DefId, DefId)> {
13951395
let tcx = self.tcx();
@@ -1406,14 +1406,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
14061406
Some((item.def_id, def_scope))
14071407
}
14081408

1409-
fn check_assoc_ty(
1410-
&self,
1411-
item: DefId,
1412-
name: Ident,
1413-
def_scope: DefId,
1414-
block: hir::HirId,
1415-
span: Span,
1416-
) {
1409+
fn check_assoc_ty(&self, item: DefId, name: Ident, def_scope: DefId, block: HirId, span: Span) {
14171410
let tcx = self.tcx();
14181411
let kind = DefKind::AssocTy;
14191412

@@ -1816,7 +1809,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
18161809
&self,
18171810
opt_self_ty: Option<Ty<'tcx>>,
18181811
path: &hir::Path<'tcx>,
1819-
hir_id: hir::HirId,
1812+
hir_id: HirId,
18201813
permit_variants: bool,
18211814
) -> Ty<'tcx> {
18221815
let tcx = self.tcx();
@@ -2054,7 +2047,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
20542047

20552048
// Converts a hir id corresponding to a type parameter to
20562049
// a early-bound `ty::Param` or late-bound `ty::Bound`.
2057-
pub(crate) fn hir_id_to_bound_ty(&self, hir_id: hir::HirId) -> Ty<'tcx> {
2050+
pub(crate) fn hir_id_to_bound_ty(&self, hir_id: HirId) -> Ty<'tcx> {
20582051
let tcx = self.tcx();
20592052
match tcx.named_bound_var(hir_id) {
20602053
Some(rbv::ResolvedArg::LateBound(debruijn, index, def_id)) => {
@@ -2079,11 +2072,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
20792072

20802073
// Converts a hir id corresponding to a const parameter to
20812074
// a early-bound `ConstKind::Param` or late-bound `ConstKind::Bound`.
2082-
pub(crate) fn hir_id_to_bound_const(
2083-
&self,
2084-
hir_id: hir::HirId,
2085-
param_ty: Ty<'tcx>,
2086-
) -> Const<'tcx> {
2075+
pub(crate) fn hir_id_to_bound_const(&self, hir_id: HirId, param_ty: Ty<'tcx>) -> Const<'tcx> {
20872076
let tcx = self.tcx();
20882077
match tcx.named_bound_var(hir_id) {
20892078
Some(rbv::ResolvedArg::EarlyBound(def_id)) => {
@@ -2417,7 +2406,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
24172406
#[instrument(level = "debug", skip(self, hir_id, unsafety, abi, decl, generics, hir_ty), ret)]
24182407
pub fn ty_of_fn(
24192408
&self,
2420-
hir_id: hir::HirId,
2409+
hir_id: HirId,
24212410
unsafety: hir::Unsafety,
24222411
abi: abi::Abi,
24232412
decl: &hir::FnDecl<'tcx>,
@@ -2551,7 +2540,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
25512540
/// corresponds to the return type.
25522541
fn suggest_trait_fn_ty_for_impl_fn_infer(
25532542
&self,
2554-
fn_hir_id: hir::HirId,
2543+
fn_hir_id: HirId,
25552544
arg_idx: Option<usize>,
25562545
) -> Option<Ty<'tcx>> {
25572546
let tcx = self.tcx();

‎compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir as hir;
1313
use rustc_hir::def::{DefKind, Res};
1414
use rustc_hir::def_id::LocalDefId;
1515
use rustc_hir::intravisit::{self, Visitor};
16-
use rustc_hir::{GenericArg, GenericParam, GenericParamKind, HirIdMap, LifetimeName, Node};
16+
use rustc_hir::{GenericArg, GenericParam, GenericParamKind, HirId, HirIdMap, LifetimeName, Node};
1717
use rustc_macros::extension;
1818
use rustc_middle::bug;
1919
use rustc_middle::hir::nested_filter;
@@ -108,7 +108,7 @@ enum Scope<'a> {
108108
/// queried later. However, if we enter an elision scope, we have to
109109
/// later append the elided bound vars to the list and need to know what
110110
/// to append to.
111-
hir_id: hir::HirId,
111+
hir_id: HirId,
112112

113113
s: ScopeRef<'a>,
114114

@@ -775,7 +775,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
775775
}
776776
}
777777

778-
fn visit_path(&mut self, path: &hir::Path<'tcx>, hir_id: hir::HirId) {
778+
fn visit_path(&mut self, path: &hir::Path<'tcx>, hir_id: HirId) {
779779
for (i, segment) in path.segments.iter().enumerate() {
780780
let depth = path.segments.len() - i - 1;
781781
if let Some(args) = segment.args {
@@ -994,7 +994,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
994994
}
995995
}
996996

997-
fn record_late_bound_vars(&mut self, hir_id: hir::HirId, binder: Vec<ty::BoundVariableKind>) {
997+
fn record_late_bound_vars(&mut self, hir_id: HirId, binder: Vec<ty::BoundVariableKind>) {
998998
if let Some(old) = self.map.late_bound_vars.insert(hir_id, binder) {
999999
bug!(
10001000
"overwrote bound vars for {hir_id:?}:\nold={old:?}\nnew={:?}",
@@ -1021,12 +1021,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
10211021
/// already in scope (for a fn item, that will be 0, but for a method it might not be). Late
10221022
/// bound lifetimes are resolved by name and associated with a binder ID (`binder_id`), so the
10231023
/// ordering is not important there.
1024-
fn visit_early_late<F>(
1025-
&mut self,
1026-
hir_id: hir::HirId,
1027-
generics: &'tcx hir::Generics<'tcx>,
1028-
walk: F,
1029-
) where
1024+
fn visit_early_late<F>(&mut self, hir_id: HirId, generics: &'tcx hir::Generics<'tcx>, walk: F)
1025+
where
10301026
F: for<'b, 'c> FnOnce(&'b mut BoundVarContext<'c, 'tcx>),
10311027
{
10321028
let mut named_late_bound_vars = 0;
@@ -1073,7 +1069,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
10731069
self.with(scope, walk);
10741070
}
10751071

1076-
fn visit_early<F>(&mut self, hir_id: hir::HirId, generics: &'tcx hir::Generics<'tcx>, walk: F)
1072+
fn visit_early<F>(&mut self, hir_id: HirId, generics: &'tcx hir::Generics<'tcx>, walk: F)
10771073
where
10781074
F: for<'b, 'c> FnOnce(&'b mut BoundVarContext<'c, 'tcx>),
10791075
{
@@ -1299,7 +1295,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
12991295
);
13001296
}
13011297

1302-
fn resolve_type_ref(&mut self, param_def_id: LocalDefId, hir_id: hir::HirId) {
1298+
fn resolve_type_ref(&mut self, param_def_id: LocalDefId, hir_id: HirId) {
13031299
// Walk up the scope chain, tracking the number of fn scopes
13041300
// that we pass through, until we find a lifetime with the
13051301
// given name or we run out of scopes.

‎compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent};
99
use rustc_ast_pretty::pp::{self, Breaks};
1010
use rustc_ast_pretty::pprust::{Comments, PrintState};
1111
use rustc_hir as hir;
12-
use rustc_hir::LifetimeParamKind;
13-
use rustc_hir::{BindingAnnotation, ByRef, GenericArg, GenericParam, GenericParamKind, Node, Term};
14-
use rustc_hir::{GenericBound, PatKind, RangeEnd, TraitBoundModifier};
12+
use rustc_hir::{
13+
BindingAnnotation, ByRef, GenericArg, GenericBound, GenericParam, GenericParamKind, HirId,
14+
LifetimeParamKind, Node, PatKind, RangeEnd, Term, TraitBoundModifier,
15+
};
1516
use rustc_span::source_map::SourceMap;
1617
use rustc_span::symbol::{kw, Ident, Symbol};
1718
use rustc_span::FileName;
@@ -20,15 +21,15 @@ use rustc_target::spec::abi::Abi;
2021
use std::cell::Cell;
2122
use std::vec;
2223

23-
pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: hir::HirId) -> String {
24+
pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: HirId) -> String {
2425
to_string(&map, |s| s.print_node(map.hir_node(hir_id)))
2526
}
2627

2728
pub enum AnnNode<'a> {
2829
Name(&'a Symbol),
2930
Block(&'a hir::Block<'a>),
3031
Item(&'a hir::Item<'a>),
31-
SubItem(hir::HirId),
32+
SubItem(HirId),
3233
Expr(&'a hir::Expr<'a>),
3334
Pat(&'a hir::Pat<'a>),
3435
Arm(&'a hir::Arm<'a>),
@@ -69,12 +70,12 @@ impl PpAnn for &dyn rustc_hir::intravisit::Map<'_> {
6970
pub struct State<'a> {
7071
pub s: pp::Printer,
7172
comments: Option<Comments<'a>>,
72-
attrs: &'a dyn Fn(hir::HirId) -> &'a [ast::Attribute],
73+
attrs: &'a dyn Fn(HirId) -> &'a [ast::Attribute],
7374
ann: &'a (dyn PpAnn + 'a),
7475
}
7576

7677
impl<'a> State<'a> {
77-
fn attrs(&self, id: hir::HirId) -> &'a [ast::Attribute] {
78+
fn attrs(&self, id: HirId) -> &'a [ast::Attribute] {
7879
(self.attrs)(id)
7980
}
8081

@@ -163,7 +164,7 @@ pub fn print_crate<'a>(
163164
krate: &hir::Mod<'_>,
164165
filename: FileName,
165166
input: String,
166-
attrs: &'a dyn Fn(hir::HirId) -> &'a [ast::Attribute],
167+
attrs: &'a dyn Fn(HirId) -> &'a [ast::Attribute],
167168
ann: &'a dyn PpAnn,
168169
) -> String {
169170
let mut s = State {

‎compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2870,7 +2870,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28702870
span: Span,
28712871
base_ty: Ty<'tcx>,
28722872
mod_id: DefId,
2873-
hir_id: hir::HirId,
2873+
hir_id: HirId,
28742874
) -> Vec<(Vec<&'tcx ty::FieldDef>, GenericArgsRef<'tcx>)> {
28752875
debug!("get_field_candidates(span: {:?}, base_t: {:?}", span, base_ty);
28762876

‎compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_data_structures::fx::FxIndexMap;
1313
use rustc_hir as hir;
1414
use rustc_hir::def::Res;
1515
use rustc_hir::def_id::LocalDefId;
16-
use rustc_hir::PatKind;
16+
use rustc_hir::{HirId, PatKind};
1717
use rustc_infer::infer::InferCtxt;
1818
use rustc_middle::hir::place::ProjectionKind;
1919
use rustc_middle::mir::FakeReadCause;
@@ -39,33 +39,33 @@ pub trait Delegate<'tcx> {
3939
/// diagnostics. Around pattern matching such as `let pat = expr`, the diagnostic
4040
/// id will be the id of the expression `expr` but the place itself will have
4141
/// the id of the binding in the pattern `pat`.
42-
fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId);
42+
fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId);
4343

4444
/// The value found at `place` is being borrowed with kind `bk`.
4545
/// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
4646
fn borrow(
4747
&mut self,
4848
place_with_id: &PlaceWithHirId<'tcx>,
49-
diag_expr_id: hir::HirId,
49+
diag_expr_id: HirId,
5050
bk: ty::BorrowKind,
5151
);
5252

5353
/// The value found at `place` is being copied.
5454
/// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
55-
fn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
55+
fn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
5656
// In most cases, copying data from `x` is equivalent to doing `*&x`, so by default
5757
// we treat a copy of `x` as a borrow of `x`.
5858
self.borrow(place_with_id, diag_expr_id, ty::BorrowKind::ImmBorrow)
5959
}
6060

6161
/// The path at `assignee_place` is being assigned to.
6262
/// `diag_expr_id` is the id used for diagnostics (see `consume` for more details).
63-
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId);
63+
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId);
6464

6565
/// The path at `binding_place` is a binding that is being initialized.
6666
///
6767
/// This covers cases such as `let x = 42;`
68-
fn bind(&mut self, binding_place: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
68+
fn bind(&mut self, binding_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
6969
// Bindings can normally be treated as a regular assignment, so by default we
7070
// forward this to the mutate callback.
7171
self.mutate(binding_place, diag_expr_id)
@@ -76,7 +76,7 @@ pub trait Delegate<'tcx> {
7676
&mut self,
7777
place_with_id: &PlaceWithHirId<'tcx>,
7878
cause: FakeReadCause,
79-
diag_expr_id: hir::HirId,
79+
diag_expr_id: HirId,
8080
);
8181
}
8282

@@ -154,7 +154,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
154154
self.mc.tcx()
155155
}
156156

157-
fn delegate_consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
157+
fn delegate_consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
158158
delegate_consume(&self.mc, self.delegate, place_with_id, diag_expr_id)
159159
}
160160

@@ -774,8 +774,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
774774
/// closure as the DefId.
775775
fn walk_captures(&mut self, closure_expr: &hir::Closure<'_>) {
776776
fn upvar_is_local_variable(
777-
upvars: Option<&FxIndexMap<hir::HirId, hir::Upvar>>,
778-
upvar_id: hir::HirId,
777+
upvars: Option<&FxIndexMap<HirId, hir::Upvar>>,
778+
upvar_id: HirId,
779779
body_owner_is_closure: bool,
780780
) -> bool {
781781
upvars.map(|upvars| !upvars.contains_key(&upvar_id)).unwrap_or(body_owner_is_closure)
@@ -901,7 +901,7 @@ fn delegate_consume<'a, 'tcx>(
901901
mc: &mc::MemCategorizationContext<'a, 'tcx>,
902902
delegate: &mut (dyn Delegate<'tcx> + 'a),
903903
place_with_id: &PlaceWithHirId<'tcx>,
904-
diag_expr_id: hir::HirId,
904+
diag_expr_id: HirId,
905905
) {
906906
debug!("delegate_consume(place_with_id={:?})", place_with_id);
907907

‎compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hir as hir;
1010
use rustc_hir::def::{CtorOf, DefKind, Res};
1111
use rustc_hir::def_id::DefId;
1212
use rustc_hir::lang_items::LangItem;
13-
use rustc_hir::{ExprKind, GenericArg, Node, QPath};
13+
use rustc_hir::{ExprKind, GenericArg, HirId, Node, QPath};
1414
use rustc_hir_analysis::astconv::generics::{
1515
check_generic_arg_count_for_call, create_args_for_parent_generic_args,
1616
};
@@ -46,7 +46,7 @@ use std::slice;
4646
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4747
/// Produces warning on the given node, if the current point in the
4848
/// function is unreachable, and there hasn't been another warning.
49-
pub(in super::super) fn warn_if_unreachable(&self, id: hir::HirId, span: Span, kind: &str) {
49+
pub(in super::super) fn warn_if_unreachable(&self, id: HirId, span: Span, kind: &str) {
5050
// FIXME: Combine these two 'if' expressions into one once
5151
// let chains are implemented
5252
if let Diverges::Always { span: orig_span, custom_note } = self.diverges.get() {
@@ -129,14 +129,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
129129
format!("{self:p}")
130130
}
131131

132-
pub fn local_ty(&self, span: Span, nid: hir::HirId) -> Ty<'tcx> {
132+
pub fn local_ty(&self, span: Span, nid: HirId) -> Ty<'tcx> {
133133
self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| {
134134
span_bug!(span, "no type for local variable {}", self.tcx.hir().node_to_string(nid))
135135
})
136136
}
137137

138138
#[inline]
139-
pub fn write_ty(&self, id: hir::HirId, ty: Ty<'tcx>) {
139+
pub fn write_ty(&self, id: HirId, ty: Ty<'tcx>) {
140140
debug!("write_ty({:?}, {:?}) in fcx {}", id, self.resolve_vars_if_possible(ty), self.tag());
141141
let mut typeck = self.typeck_results.borrow_mut();
142142
let mut node_ty = typeck.node_types_mut();
@@ -160,7 +160,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
160160

161161
pub fn write_field_index(
162162
&self,
163-
hir_id: hir::HirId,
163+
hir_id: HirId,
164164
index: FieldIdx,
165165
nested_fields: Vec<(Ty<'tcx>, FieldIdx)>,
166166
) {
@@ -173,7 +173,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
173173
#[instrument(level = "debug", skip(self))]
174174
pub(in super::super) fn write_resolution(
175175
&self,
176-
hir_id: hir::HirId,
176+
hir_id: HirId,
177177
r: Result<(DefKind, DefId), ErrorGuaranteed>,
178178
) {
179179
self.typeck_results.borrow_mut().type_dependent_defs_mut().insert(hir_id, r);
@@ -182,7 +182,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
182182
#[instrument(level = "debug", skip(self))]
183183
pub fn write_method_call_and_enforce_effects(
184184
&self,
185-
hir_id: hir::HirId,
185+
hir_id: HirId,
186186
span: Span,
187187
method: MethodCallee<'tcx>,
188188
) {
@@ -191,7 +191,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
191191
self.write_args(hir_id, method.args);
192192
}
193193

194-
pub fn write_args(&self, node_id: hir::HirId, args: GenericArgsRef<'tcx>) {
194+
pub fn write_args(&self, node_id: HirId, args: GenericArgsRef<'tcx>) {
195195
if !args.is_empty() {
196196
debug!("write_args({:?}, {:?}) in fcx {}", node_id, args, self.tag());
197197

@@ -209,7 +209,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
209209
#[instrument(skip(self), level = "debug")]
210210
pub fn write_user_type_annotation_from_args(
211211
&self,
212-
hir_id: hir::HirId,
212+
hir_id: HirId,
213213
def_id: DefId,
214214
args: GenericArgsRef<'tcx>,
215215
user_self_ty: Option<UserSelfTy<'tcx>>,
@@ -229,7 +229,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
229229
#[instrument(skip(self), level = "debug")]
230230
pub fn write_user_type_annotation(
231231
&self,
232-
hir_id: hir::HirId,
232+
hir_id: HirId,
233233
canonical_user_type_annotation: CanonicalUserType<'tcx>,
234234
) {
235235
debug!("fcx {}", self.tag());
@@ -466,7 +466,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
466466
t.has_free_regions() || t.has_projections() || t.has_infer_types()
467467
}
468468

469-
pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> {
469+
pub fn node_ty(&self, id: HirId) -> Ty<'tcx> {
470470
match self.typeck_results.borrow().node_types().get(id) {
471471
Some(&t) => t,
472472
None if let Some(e) = self.tainted_by_errors() => Ty::new_error(self.tcx, e),
@@ -480,7 +480,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
480480
}
481481
}
482482

483-
pub fn node_ty_opt(&self, id: hir::HirId) -> Option<Ty<'tcx>> {
483+
pub fn node_ty_opt(&self, id: HirId) -> Option<Ty<'tcx>> {
484484
match self.typeck_results.borrow().node_types().get(id) {
485485
Some(&t) => Some(t),
486486
None if let Some(e) = self.tainted_by_errors() => Some(Ty::new_error(self.tcx, e)),
@@ -767,7 +767,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
767767
&self,
768768
lang_item: hir::LangItem,
769769
span: Span,
770-
hir_id: hir::HirId,
770+
hir_id: HirId,
771771
) -> (Res, Ty<'tcx>) {
772772
let def_id = self.tcx.require_lang_item(lang_item, Some(span));
773773
let def_kind = self.tcx.def_kind(def_id);
@@ -815,7 +815,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
815815
pub fn resolve_ty_and_res_fully_qualified_call(
816816
&self,
817817
qpath: &'tcx QPath<'tcx>,
818-
hir_id: hir::HirId,
818+
hir_id: HirId,
819819
span: Span,
820820
args: Option<&'tcx [hir::Expr<'tcx>]>,
821821
) -> (Res, Option<LoweredTy<'tcx>>, &'tcx [hir::PathSegment<'tcx>]) {
@@ -945,7 +945,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
945945
pub(in super::super) fn get_node_fn_decl(
946946
&self,
947947
node: Node<'tcx>,
948-
) -> Option<(hir::HirId, &'tcx hir::FnDecl<'tcx>, Ident, bool)> {
948+
) -> Option<(HirId, &'tcx hir::FnDecl<'tcx>, Ident, bool)> {
949949
match node {
950950
Node::Item(&hir::Item {
951951
ident,
@@ -957,7 +957,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
957957
// method called `main`, regardless of whether it is actually the entry point,
958958
// but it will still present it as the reason for the expected type.
959959
Some((
960-
hir::HirId::make_owner(owner_id.def_id),
960+
HirId::make_owner(owner_id.def_id),
961961
&sig.decl,
962962
ident,
963963
ident.name != sym::main,
@@ -968,13 +968,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
968968
kind: hir::TraitItemKind::Fn(ref sig, ..),
969969
owner_id,
970970
..
971-
}) => Some((hir::HirId::make_owner(owner_id.def_id), &sig.decl, ident, true)),
971+
}) => Some((HirId::make_owner(owner_id.def_id), &sig.decl, ident, true)),
972972
Node::ImplItem(&hir::ImplItem {
973973
ident,
974974
kind: hir::ImplItemKind::Fn(ref sig, ..),
975975
owner_id,
976976
..
977-
}) => Some((hir::HirId::make_owner(owner_id.def_id), &sig.decl, ident, false)),
977+
}) => Some((HirId::make_owner(owner_id.def_id), &sig.decl, ident, false)),
978978
Node::Expr(&hir::Expr {
979979
hir_id,
980980
kind:
@@ -1005,7 +1005,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10051005
_ => return None,
10061006
};
10071007
Some((
1008-
hir::HirId::make_owner(owner_id.def_id),
1008+
HirId::make_owner(owner_id.def_id),
10091009
&sig.decl,
10101010
ident,
10111011
ident.name != sym::main,
@@ -1017,10 +1017,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10171017

10181018
/// Given a `HirId`, return the `HirId` of the enclosing function, its `FnDecl`, and whether a
10191019
/// suggestion can be made, `None` otherwise.
1020-
pub fn get_fn_decl(
1021-
&self,
1022-
blk_id: hir::HirId,
1023-
) -> Option<(hir::HirId, &'tcx hir::FnDecl<'tcx>, bool)> {
1020+
pub fn get_fn_decl(&self, blk_id: HirId) -> Option<(HirId, &'tcx hir::FnDecl<'tcx>, bool)> {
10241021
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
10251022
// `while` before reaching it, as block tail returns are not available in them.
10261023
self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {
@@ -1115,7 +1112,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11151112
res: Res,
11161113
span: Span,
11171114
path_span: Span,
1118-
hir_id: hir::HirId,
1115+
hir_id: HirId,
11191116
) -> (Ty<'tcx>, Res) {
11201117
let tcx = self.tcx;
11211118

@@ -1489,7 +1486,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14891486
span: Span,
14901487
def_id: DefId,
14911488
args: GenericArgsRef<'tcx>,
1492-
hir_id: hir::HirId,
1489+
hir_id: HirId,
14931490
) {
14941491
self.add_required_obligations_with_code(span, def_id, args, |idx, span| {
14951492
if span.is_dummy() {
@@ -1580,7 +1577,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15801577

15811578
pub(in super::super) fn with_breakable_ctxt<F: FnOnce() -> R, R>(
15821579
&self,
1583-
id: hir::HirId,
1580+
id: HirId,
15841581
ctxt: BreakableCtxt<'tcx>,
15851582
f: F,
15861583
) -> (BreakableCtxt<'tcx>, R) {
@@ -1619,7 +1616,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16191616
}
16201617

16211618
/// Returns `true` if an expression is contained inside the LHS of an assignment expression.
1622-
pub(in super::super) fn expr_in_place(&self, mut expr_id: hir::HirId) -> bool {
1619+
pub(in super::super) fn expr_in_place(&self, mut expr_id: HirId) -> bool {
16231620
let mut contained_in_place = false;
16241621

16251622
while let hir::Node::Expr(parent_expr) = self.tcx.parent_hir_node(expr_id) {

‎compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_hir as hir;
2323
use rustc_hir::def::{CtorOf, DefKind, Res};
2424
use rustc_hir::def_id::DefId;
2525
use rustc_hir::intravisit::Visitor;
26-
use rustc_hir::{ExprKind, Node, QPath};
26+
use rustc_hir::{ExprKind, HirId, Node, QPath};
2727
use rustc_hir_analysis::astconv::AstConv;
2828
use rustc_hir_analysis::check::intrinsicck::InlineAsmCtxt;
2929
use rustc_hir_analysis::check::potentially_plural_count;
@@ -1438,7 +1438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14381438
pub fn check_struct_path(
14391439
&self,
14401440
qpath: &QPath<'tcx>,
1441-
hir_id: hir::HirId,
1441+
hir_id: HirId,
14421442
) -> Result<(&'tcx ty::VariantDef, Ty<'tcx>), ErrorGuaranteed> {
14431443
let path_span = qpath.span();
14441444
let (def, ty) = self.finish_resolving_struct_path(qpath, path_span, hir_id);
@@ -1503,7 +1503,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15031503

15041504
pub fn check_decl_initializer(
15051505
&self,
1506-
hir_id: hir::HirId,
1506+
hir_id: HirId,
15071507
pat: &'tcx hir::Pat<'tcx>,
15081508
init: &'tcx hir::Expr<'tcx>,
15091509
) -> Ty<'tcx> {
@@ -1826,7 +1826,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18261826
ty
18271827
}
18281828

1829-
fn parent_item_span(&self, id: hir::HirId) -> Option<Span> {
1829+
fn parent_item_span(&self, id: HirId) -> Option<Span> {
18301830
let node = self.tcx.hir_node_by_def_id(self.tcx.hir().get_parent_item(id).def_id);
18311831
match node {
18321832
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(_, _, body_id), .. })
@@ -1844,7 +1844,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18441844
/// Given a function block's `HirId`, returns its `FnDecl` if it exists, or `None` otherwise.
18451845
pub(crate) fn get_parent_fn_decl(
18461846
&self,
1847-
blk_id: hir::HirId,
1847+
blk_id: HirId,
18481848
) -> Option<(&'tcx hir::FnDecl<'tcx>, Ident)> {
18491849
let parent = self.tcx.hir_node_by_def_id(self.tcx.hir().get_parent_item(blk_id).def_id);
18501850
self.get_node_fn_decl(parent).map(|(_, fn_decl, ident, _)| (fn_decl, ident))
@@ -1886,15 +1886,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18861886
expr.span
18871887
}
18881888

1889-
fn overwrite_local_ty_if_err(
1890-
&self,
1891-
hir_id: hir::HirId,
1892-
pat: &'tcx hir::Pat<'tcx>,
1893-
ty: Ty<'tcx>,
1894-
) {
1889+
fn overwrite_local_ty_if_err(&self, hir_id: HirId, pat: &'tcx hir::Pat<'tcx>, ty: Ty<'tcx>) {
18951890
struct V<'tcx> {
18961891
tcx: TyCtxt<'tcx>,
1897-
pat_hir_ids: Vec<hir::HirId>,
1892+
pat_hir_ids: Vec<HirId>,
18981893
}
18991894

19001895
impl<'tcx> Visitor<'tcx> for V<'tcx> {
@@ -1932,7 +1927,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19321927
&self,
19331928
qpath: &QPath<'tcx>,
19341929
path_span: Span,
1935-
hir_id: hir::HirId,
1930+
hir_id: HirId,
19361931
) -> (Res, LoweredTy<'tcx>) {
19371932
match *qpath {
19381933
QPath::Resolved(ref maybe_qself, path) => {

‎compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7070
expr: &'tcx hir::Expr<'tcx>,
7171
expected: Ty<'tcx>,
7272
found: Ty<'tcx>,
73-
blk_id: hir::HirId,
73+
blk_id: HirId,
7474
) -> bool {
7575
let expr = expr.peel_drop_temps();
7676
let mut pointing_at_return_type = false;
@@ -796,7 +796,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
796796
expected: Ty<'tcx>,
797797
found: Ty<'tcx>,
798798
can_suggest: bool,
799-
fn_id: hir::HirId,
799+
fn_id: HirId,
800800
) -> bool {
801801
let found =
802802
self.resolve_numeric_literals_with_default(self.resolve_vars_if_possible(found));
@@ -912,7 +912,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
912912
err: &mut Diag<'_>,
913913
expected: Ty<'tcx>,
914914
found: Ty<'tcx>,
915-
fn_id: hir::HirId,
915+
fn_id: HirId,
916916
) {
917917
// Only apply the suggestion if:
918918
// - the return type is a generic parameter
@@ -1019,8 +1019,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10191019
fn_decl: &hir::FnDecl<'tcx>,
10201020
expected: Ty<'tcx>,
10211021
found: Ty<'tcx>,
1022-
id: hir::HirId,
1023-
fn_id: hir::HirId,
1022+
id: HirId,
1023+
fn_id: HirId,
10241024
) {
10251025
if !expected.is_unit() {
10261026
return;
@@ -1592,12 +1592,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15921592
}
15931593
}
15941594

1595-
fn is_loop(&self, id: hir::HirId) -> bool {
1595+
fn is_loop(&self, id: HirId) -> bool {
15961596
let node = self.tcx.hir_node(id);
15971597
matches!(node, Node::Expr(Expr { kind: ExprKind::Loop(..), .. }))
15981598
}
15991599

1600-
fn is_local_statement(&self, id: hir::HirId) -> bool {
1600+
fn is_local_statement(&self, id: HirId) -> bool {
16011601
let node = self.tcx.hir_node(id);
16021602
matches!(node, Node::Stmt(Stmt { kind: StmtKind::Let(..), .. }))
16031603
}

‎compiler/rustc_hir_typeck/src/gather_locals.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::FnCtxt;
22
use rustc_hir as hir;
33
use rustc_hir::intravisit::{self, Visitor};
4-
use rustc_hir::PatKind;
4+
use rustc_hir::{HirId, PatKind};
55
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
66
use rustc_middle::ty::Ty;
77
use rustc_middle::ty::UserType;
@@ -33,7 +33,7 @@ impl<'a> DeclOrigin<'a> {
3333
///
3434
/// It must have a hir_id, as this is how we connect gather_locals to the check functions.
3535
pub(super) struct Declaration<'a> {
36-
pub hir_id: hir::HirId,
36+
pub hir_id: HirId,
3737
pub pat: &'a hir::Pat<'a>,
3838
pub ty: Option<&'a hir::Ty<'a>>,
3939
pub span: Span,
@@ -48,8 +48,8 @@ impl<'a> From<&'a hir::Local<'a>> for Declaration<'a> {
4848
}
4949
}
5050

51-
impl<'a> From<(&'a hir::LetExpr<'a>, hir::HirId)> for Declaration<'a> {
52-
fn from((let_expr, hir_id): (&'a hir::LetExpr<'a>, hir::HirId)) -> Self {
51+
impl<'a> From<(&'a hir::LetExpr<'a>, HirId)> for Declaration<'a> {
52+
fn from((let_expr, hir_id): (&'a hir::LetExpr<'a>, HirId)) -> Self {
5353
let hir::LetExpr { pat, ty, span, init, is_recovered: _ } = *let_expr;
5454
Declaration { hir_id, pat, ty, span, init: Some(init), origin: DeclOrigin::LetExpr }
5555
}
@@ -60,15 +60,15 @@ pub(super) struct GatherLocalsVisitor<'a, 'tcx> {
6060
// parameters are special cases of patterns, but we want to handle them as
6161
// *distinct* cases. so track when we are hitting a pattern *within* an fn
6262
// parameter.
63-
outermost_fn_param_pat: Option<(Span, hir::HirId)>,
63+
outermost_fn_param_pat: Option<(Span, HirId)>,
6464
}
6565

6666
impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
6767
pub(super) fn new(fcx: &'a FnCtxt<'a, 'tcx>) -> Self {
6868
Self { fcx, outermost_fn_param_pat: None }
6969
}
7070

71-
fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<Ty<'tcx>>) -> Ty<'tcx> {
71+
fn assign(&mut self, span: Span, nid: HirId, ty_opt: Option<Ty<'tcx>>) -> Ty<'tcx> {
7272
match ty_opt {
7373
None => {
7474
// Infer the variable's type.

‎compiler/rustc_hir_typeck/src/inherited.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::callee::DeferredCallResolution;
33
use rustc_data_structures::unord::{UnordMap, UnordSet};
44
use rustc_hir as hir;
55
use rustc_hir::def_id::LocalDefId;
6-
use rustc_hir::HirIdMap;
6+
use rustc_hir::{HirId, HirIdMap};
77
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
88
use rustc_middle::traits::DefiningAnchor;
99
use rustc_middle::ty::visit::TypeVisitableExt;
@@ -51,9 +51,9 @@ pub struct Inherited<'tcx> {
5151

5252
pub(super) deferred_cast_checks: RefCell<Vec<super::cast::CastCheck<'tcx>>>,
5353

54-
pub(super) deferred_transmute_checks: RefCell<Vec<(Ty<'tcx>, Ty<'tcx>, hir::HirId)>>,
54+
pub(super) deferred_transmute_checks: RefCell<Vec<(Ty<'tcx>, Ty<'tcx>, HirId)>>,
5555

56-
pub(super) deferred_asm_checks: RefCell<Vec<(&'tcx hir::InlineAsm<'tcx>, hir::HirId)>>,
56+
pub(super) deferred_asm_checks: RefCell<Vec<(&'tcx hir::InlineAsm<'tcx>, HirId)>>,
5757

5858
pub(super) deferred_coroutine_interiors: RefCell<Vec<(LocalDefId, hir::BodyId, Ty<'tcx>)>>,
5959

‎compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed};
5656
use rustc_hir as hir;
5757
use rustc_hir::def::{DefKind, Res};
5858
use rustc_hir::intravisit::Visitor;
59-
use rustc_hir::{HirIdMap, Node};
59+
use rustc_hir::{HirId, HirIdMap, Node};
6060
use rustc_hir_analysis::astconv::AstConv;
6161
use rustc_hir_analysis::check::check_abi;
6262
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
@@ -343,13 +343,13 @@ pub struct EnclosingBreakables<'tcx> {
343343
}
344344

345345
impl<'tcx> EnclosingBreakables<'tcx> {
346-
fn find_breakable(&mut self, target_id: hir::HirId) -> &mut BreakableCtxt<'tcx> {
346+
fn find_breakable(&mut self, target_id: HirId) -> &mut BreakableCtxt<'tcx> {
347347
self.opt_find_breakable(target_id).unwrap_or_else(|| {
348348
bug!("could not find enclosing breakable with id {}", target_id);
349349
})
350350
}
351351

352-
fn opt_find_breakable(&mut self, target_id: hir::HirId) -> Option<&mut BreakableCtxt<'tcx>> {
352+
fn opt_find_breakable(&mut self, target_id: HirId) -> Option<&mut BreakableCtxt<'tcx>> {
353353
match self.by_id.get(&target_id) {
354354
Some(ix) => Some(&mut self.stack[*ix]),
355355
None => None,

‎compiler/rustc_hir_typeck/src/mem_categorization.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,24 @@ use rustc_hir as hir;
5858
use rustc_hir::def::{CtorOf, DefKind, Res};
5959
use rustc_hir::def_id::LocalDefId;
6060
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
61-
use rustc_hir::PatKind;
61+
use rustc_hir::{HirId, PatKind};
6262
use rustc_infer::infer::InferCtxt;
6363
use rustc_span::Span;
6464
use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
6565
use rustc_trait_selection::infer::InferCtxtExt;
6666

6767
pub(crate) trait HirNode {
68-
fn hir_id(&self) -> hir::HirId;
68+
fn hir_id(&self) -> HirId;
6969
}
7070

7171
impl HirNode for hir::Expr<'_> {
72-
fn hir_id(&self) -> hir::HirId {
72+
fn hir_id(&self) -> HirId {
7373
self.hir_id
7474
}
7575
}
7676

7777
impl HirNode for hir::Pat<'_> {
78-
fn hir_id(&self) -> hir::HirId {
78+
fn hir_id(&self) -> HirId {
7979
self.hir_id
8080
}
8181
}
@@ -86,7 +86,7 @@ pub(crate) struct MemCategorizationContext<'a, 'tcx> {
8686
infcx: &'a InferCtxt<'tcx>,
8787
param_env: ty::ParamEnv<'tcx>,
8888
body_owner: LocalDefId,
89-
upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
89+
upvars: Option<&'tcx FxIndexMap<HirId, hir::Upvar>>,
9090
}
9191

9292
pub(crate) type McResult<T> = Result<T, ()>;
@@ -127,11 +127,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
127127
self.infcx.tainted_by_errors().is_some()
128128
}
129129

130-
fn resolve_type_vars_or_error(
131-
&self,
132-
id: hir::HirId,
133-
ty: Option<Ty<'tcx>>,
134-
) -> McResult<Ty<'tcx>> {
130+
fn resolve_type_vars_or_error(&self, id: HirId, ty: Option<Ty<'tcx>>) -> McResult<Ty<'tcx>> {
135131
match ty {
136132
Some(ty) => {
137133
let ty = self.resolve_vars_if_possible(ty);
@@ -153,7 +149,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
153149
}
154150
}
155151

156-
pub(crate) fn node_ty(&self, hir_id: hir::HirId) -> McResult<Ty<'tcx>> {
152+
pub(crate) fn node_ty(&self, hir_id: HirId) -> McResult<Ty<'tcx>> {
157153
self.resolve_type_vars_or_error(hir_id, self.typeck_results.node_type_opt(hir_id))
158154
}
159155

@@ -381,7 +377,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
381377
#[instrument(level = "debug", skip(self, span), ret)]
382378
pub(crate) fn cat_res(
383379
&self,
384-
hir_id: hir::HirId,
380+
hir_id: HirId,
385381
span: Span,
386382
expr_ty: Ty<'tcx>,
387383
res: Res,
@@ -420,7 +416,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
420416
/// environment and upvar reference as appropriate. Only regionck cares
421417
/// about these dereferences, so we let it compute them as needed.
422418
#[instrument(level = "debug", skip(self), ret)]
423-
fn cat_upvar(&self, hir_id: hir::HirId, var_id: hir::HirId) -> McResult<PlaceWithHirId<'tcx>> {
419+
fn cat_upvar(&self, hir_id: HirId, var_id: HirId) -> McResult<PlaceWithHirId<'tcx>> {
424420
let closure_expr_def_id = self.body_owner;
425421

426422
let upvar_id = ty::UpvarId {
@@ -433,7 +429,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
433429
}
434430

435431
#[instrument(level = "debug", skip(self), ret)]
436-
pub(crate) fn cat_rvalue(&self, hir_id: hir::HirId, expr_ty: Ty<'tcx>) -> PlaceWithHirId<'tcx> {
432+
pub(crate) fn cat_rvalue(&self, hir_id: HirId, expr_ty: Ty<'tcx>) -> PlaceWithHirId<'tcx> {
437433
PlaceWithHirId::new(hir_id, expr_ty, PlaceBase::Rvalue, Vec::new())
438434
}
439435

@@ -527,7 +523,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
527523
fn variant_index_for_adt(
528524
&self,
529525
qpath: &hir::QPath<'_>,
530-
pat_hir_id: hir::HirId,
526+
pat_hir_id: HirId,
531527
span: Span,
532528
) -> McResult<VariantIdx> {
533529
let res = self.typeck_results.qpath_res(qpath, pat_hir_id);
@@ -560,7 +556,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
560556
/// Here `pat_hir_id` is the HirId of the pattern itself.
561557
fn total_fields_in_adt_variant(
562558
&self,
563-
pat_hir_id: hir::HirId,
559+
pat_hir_id: HirId,
564560
variant_index: VariantIdx,
565561
span: Span,
566562
) -> McResult<usize> {
@@ -577,7 +573,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
577573

578574
/// Returns the total number of fields in a tuple used within a Tuple pattern.
579575
/// Here `pat_hir_id` is the HirId of the pattern itself.
580-
fn total_fields_in_tuple(&self, pat_hir_id: hir::HirId, span: Span) -> McResult<usize> {
576+
fn total_fields_in_tuple(&self, pat_hir_id: HirId, span: Span) -> McResult<usize> {
581577
let ty = self.typeck_results.node_type(pat_hir_id);
582578
match ty.kind() {
583579
ty::Tuple(args) => Ok(args.len()),

‎compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_data_structures::fx::FxHashSet;
99
use rustc_errors::Applicability;
1010
use rustc_hir as hir;
1111
use rustc_hir::def::DefKind;
12+
use rustc_hir::HirId;
1213
use rustc_hir_analysis::autoderef::{self, Autoderef};
1314
use rustc_infer::infer::canonical::OriginalQueryValues;
1415
use rustc_infer::infer::canonical::{Canonical, QueryResponse};
@@ -87,7 +88,7 @@ pub(crate) struct ProbeContext<'a, 'tcx> {
8788
Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>, Option<ObligationCause<'tcx>>)>,
8889
>,
8990

90-
scope_expr_id: hir::HirId,
91+
scope_expr_id: HirId,
9192
}
9293

9394
impl<'a, 'tcx> Deref for ProbeContext<'a, 'tcx> {
@@ -264,7 +265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
264265
mode: Mode,
265266
return_type: Ty<'tcx>,
266267
self_ty: Ty<'tcx>,
267-
scope_expr_id: hir::HirId,
268+
scope_expr_id: HirId,
268269
candidate_filter: impl Fn(&ty::AssocItem) -> bool,
269270
) -> Vec<ty::AssocItem> {
270271
let method_names = self
@@ -308,7 +309,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
308309
return_type: Option<Ty<'tcx>>,
309310
is_suggestion: IsSuggestion,
310311
self_ty: Ty<'tcx>,
311-
scope_expr_id: hir::HirId,
312+
scope_expr_id: HirId,
312313
scope: ProbeScope,
313314
) -> PickResult<'tcx> {
314315
self.probe_op(
@@ -332,7 +333,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
332333
return_type: Option<Ty<'tcx>>,
333334
is_suggestion: IsSuggestion,
334335
self_ty: Ty<'tcx>,
335-
scope_expr_id: hir::HirId,
336+
scope_expr_id: HirId,
336337
scope: ProbeScope,
337338
) -> Vec<Candidate<'tcx>> {
338339
self.probe_op(
@@ -363,7 +364,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
363364
return_type: Option<Ty<'tcx>>,
364365
is_suggestion: IsSuggestion,
365366
self_ty: Ty<'tcx>,
366-
scope_expr_id: hir::HirId,
367+
scope_expr_id: HirId,
367368
scope: ProbeScope,
368369
op: OP,
369370
) -> Result<R, MethodError<'tcx>>
@@ -580,7 +581,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
580581
return_type: Option<Ty<'tcx>>,
581582
orig_steps_var_values: &'a OriginalQueryValues<'tcx>,
582583
steps: &'tcx [CandidateStep<'tcx>],
583-
scope_expr_id: hir::HirId,
584+
scope_expr_id: HirId,
584585
) -> ProbeContext<'a, 'tcx> {
585586
ProbeContext {
586587
fcx,
@@ -1373,7 +1374,7 @@ impl<'tcx> Pick<'tcx> {
13731374
&self,
13741375
tcx: TyCtxt<'tcx>,
13751376
span: Span,
1376-
scope_expr_id: hir::HirId,
1377+
scope_expr_id: HirId,
13771378
) {
13781379
if self.unstable_candidates.is_empty() {
13791380
return;

‎compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use rustc_errors::{Applicability, MultiSpan};
3838
use rustc_hir as hir;
3939
use rustc_hir::def_id::LocalDefId;
4040
use rustc_hir::intravisit::{self, Visitor};
41+
use rustc_hir::HirId;
4142
use rustc_infer::infer::UpvarRegion;
4243
use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection, ProjectionKind};
4344
use rustc_middle::mir::FakeReadCause;
@@ -87,7 +88,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8788
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
8889
enum UpvarMigrationInfo {
8990
/// We previously captured all of `x`, but now we capture some sub-path.
90-
CapturingPrecise { source_expr: Option<hir::HirId>, var_name: String },
91+
CapturingPrecise { source_expr: Option<HirId>, var_name: String },
9192
CapturingNothing {
9293
// where the variable appears in the closure (but is not captured)
9394
use_span: Span,
@@ -130,7 +131,7 @@ struct MigrationLintNote {
130131
/// Intermediate format to store the hir id of the root variable and a HashSet containing
131132
/// information on why the root variable should be fully captured
132133
struct NeededMigration {
133-
var_hir_id: hir::HirId,
134+
var_hir_id: HirId,
134135
diagnostics_info: Vec<MigrationLintNote>,
135136
}
136137

@@ -162,7 +163,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
162163
#[instrument(skip(self, body), level = "debug")]
163164
fn analyze_closure(
164165
&self,
165-
closure_hir_id: hir::HirId,
166+
closure_hir_id: HirId,
166167
span: Span,
167168
body_id: hir::BodyId,
168169
body: &'tcx hir::Body<'tcx>,
@@ -1058,7 +1059,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10581059
fn compute_2229_migrations_for_trait(
10591060
&self,
10601061
min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
1061-
var_hir_id: hir::HirId,
1062+
var_hir_id: HirId,
10621063
closure_clause: hir::CaptureBy,
10631064
) -> Option<FxIndexMap<UpvarMigrationInfo, UnordSet<&'static str>>> {
10641065
let auto_traits_def_id = [
@@ -1170,7 +1171,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11701171
closure_span: Span,
11711172
min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
11721173
closure_clause: hir::CaptureBy,
1173-
var_hir_id: hir::HirId,
1174+
var_hir_id: HirId,
11741175
) -> Option<FxIndexSet<UpvarMigrationInfo>> {
11751176
let ty = self.resolve_vars_if_possible(self.node_ty(var_hir_id));
11761177

@@ -1610,7 +1611,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16101611
fn place_for_root_variable(
16111612
&self,
16121613
closure_def_id: LocalDefId,
1613-
var_hir_id: hir::HirId,
1614+
var_hir_id: HirId,
16141615
) -> Place<'tcx> {
16151616
let upvar_id = ty::UpvarId::new(var_hir_id, closure_def_id);
16161617

@@ -1789,7 +1790,7 @@ fn apply_capture_kind_on_capture_ty<'tcx>(
17891790
}
17901791

17911792
/// Returns the Span of where the value with the provided HirId would be dropped
1792-
fn drop_location_span(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> Span {
1793+
fn drop_location_span(tcx: TyCtxt<'_>, hir_id: HirId) -> Span {
17931794
let owner_id = tcx.hir().get_enclosing_scope(hir_id).unwrap();
17941795

17951796
let owner_node = tcx.hir_node(owner_id);
@@ -1841,15 +1842,15 @@ struct InferBorrowKind<'tcx> {
18411842
/// Place { V1, [ProjectionKind::Field(Index=1, Variant=0)] } : CaptureKind { E2, MutableBorrow }
18421843
/// ```
18431844
capture_information: InferredCaptureInformation<'tcx>,
1844-
fake_reads: Vec<(Place<'tcx>, FakeReadCause, hir::HirId)>,
1845+
fake_reads: Vec<(Place<'tcx>, FakeReadCause, HirId)>,
18451846
}
18461847

18471848
impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
18481849
fn fake_read(
18491850
&mut self,
18501851
place: &PlaceWithHirId<'tcx>,
18511852
cause: FakeReadCause,
1852-
diag_expr_id: hir::HirId,
1853+
diag_expr_id: HirId,
18531854
) {
18541855
let PlaceBase::Upvar(_) = place.place.base else { return };
18551856

@@ -1864,7 +1865,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
18641865
}
18651866

18661867
#[instrument(skip(self), level = "debug")]
1867-
fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
1868+
fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
18681869
let PlaceBase::Upvar(upvar_id) = place_with_id.place.base else { return };
18691870
assert_eq!(self.closure_def_id, upvar_id.closure_expr_id);
18701871

@@ -1882,7 +1883,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
18821883
fn borrow(
18831884
&mut self,
18841885
place_with_id: &PlaceWithHirId<'tcx>,
1885-
diag_expr_id: hir::HirId,
1886+
diag_expr_id: HirId,
18861887
bk: ty::BorrowKind,
18871888
) {
18881889
let PlaceBase::Upvar(upvar_id) = place_with_id.place.base else { return };
@@ -1913,7 +1914,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
19131914
}
19141915

19151916
#[instrument(skip(self), level = "debug")]
1916-
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) {
1917+
fn mutate(&mut self, assignee_place: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
19171918
self.borrow(assignee_place, diag_expr_id, ty::BorrowKind::MutBorrow);
19181919
}
19191920
}
@@ -2100,14 +2101,14 @@ fn construct_capture_info_string<'tcx>(
21002101
format!("{place_str} -> {capture_kind_str}")
21012102
}
21022103

2103-
fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol {
2104+
fn var_name(tcx: TyCtxt<'_>, var_hir_id: HirId) -> Symbol {
21042105
tcx.hir().name(var_hir_id)
21052106
}
21062107

21072108
#[instrument(level = "debug", skip(tcx))]
21082109
fn should_do_rust_2021_incompatible_closure_captures_analysis(
21092110
tcx: TyCtxt<'_>,
2110-
closure_id: hir::HirId,
2111+
closure_id: HirId,
21112112
) -> bool {
21122113
if tcx.sess.at_least_rust_2021() {
21132114
return false;

‎compiler/rustc_hir_typeck/src/writeback.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_data_structures::unord::ExtendUnord;
77
use rustc_errors::{ErrorGuaranteed, StashKey};
88
use rustc_hir as hir;
99
use rustc_hir::intravisit::{self, Visitor};
10+
use rustc_hir::HirId;
1011
use rustc_infer::infer::error_reporting::TypeAnnotationNeeded::E0282;
1112
use rustc_middle::traits::ObligationCause;
1213
use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
@@ -134,7 +135,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
134135
self.fcx.tcx
135136
}
136137

137-
fn write_ty_to_typeck_results(&mut self, hir_id: hir::HirId, ty: Ty<'tcx>) {
138+
fn write_ty_to_typeck_results(&mut self, hir_id: HirId, ty: Ty<'tcx>) {
138139
debug!("write_ty_to_typeck_results({:?}, {:?})", hir_id, ty);
139140
assert!(
140141
!ty.has_infer() && !ty.has_placeholders() && !ty.has_free_regions(),
@@ -460,7 +461,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
460461
fcx_typeck_results.closure_kind_origins().items_in_stable_order();
461462

462463
for (local_id, origin) in fcx_closure_kind_origins {
463-
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
464+
let hir_id = HirId { owner: common_hir_owner, local_id };
464465
let place_span = origin.0;
465466
let place = self.resolve(origin.1.clone(), &place_span);
466467
self.typeck_results.closure_kind_origins_mut().insert(hir_id, (place_span, place));
@@ -489,7 +490,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
489490

490491
let mut errors_buffer = Vec::new();
491492
for (local_id, c_ty) in sorted_user_provided_types {
492-
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
493+
let hir_id = HirId { owner: common_hir_owner, local_id };
493494

494495
if let ty::UserType::TypeOf(_, user_args) = c_ty.value {
495496
// This is a unit-testing mechanism.
@@ -512,7 +513,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
512513

513514
self.typeck_results.user_provided_types_mut().extend(
514515
fcx_typeck_results.user_provided_types().items().map(|(local_id, c_ty)| {
515-
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
516+
let hir_id = HirId { owner: common_hir_owner, local_id };
516517

517518
if cfg!(debug_assertions) && c_ty.has_infer() {
518519
span_bug!(
@@ -603,7 +604,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
603604
}
604605
}
605606

606-
fn visit_field_id(&mut self, hir_id: hir::HirId) {
607+
fn visit_field_id(&mut self, hir_id: HirId) {
607608
if let Some(index) = self.fcx.typeck_results.borrow_mut().field_indices_mut().remove(hir_id)
608609
{
609610
self.typeck_results.field_indices_mut().insert(hir_id, index);
@@ -616,7 +617,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
616617
}
617618

618619
#[instrument(skip(self, span), level = "debug")]
619-
fn visit_node_id(&mut self, span: Span, hir_id: hir::HirId) {
620+
fn visit_node_id(&mut self, span: Span, hir_id: HirId) {
620621
// Export associated path extensions and method resolutions.
621622
if let Some(def) =
622623
self.fcx.typeck_results.borrow_mut().type_dependent_defs_mut().remove(hir_id)
@@ -643,7 +644,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
643644
}
644645

645646
#[instrument(skip(self, span), level = "debug")]
646-
fn visit_adjustments(&mut self, span: Span, hir_id: hir::HirId) {
647+
fn visit_adjustments(&mut self, span: Span, hir_id: HirId) {
647648
let adjustment = self.fcx.typeck_results.borrow_mut().adjustments_mut().remove(hir_id);
648649
match adjustment {
649650
None => {
@@ -659,7 +660,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
659660
}
660661

661662
#[instrument(skip(self, span), level = "debug")]
662-
fn visit_pat_adjustments(&mut self, span: Span, hir_id: hir::HirId) {
663+
fn visit_pat_adjustments(&mut self, span: Span, hir_id: HirId) {
663664
let adjustment = self.fcx.typeck_results.borrow_mut().pat_adjustments_mut().remove(hir_id);
664665
match adjustment {
665666
None => {
@@ -682,7 +683,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
682683
let fcx_liberated_fn_sigs = fcx_typeck_results.liberated_fn_sigs().items_in_stable_order();
683684

684685
for (local_id, &fn_sig) in fcx_liberated_fn_sigs {
685-
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
686+
let hir_id = HirId { owner: common_hir_owner, local_id };
686687
let fn_sig = self.resolve(fn_sig, &hir_id);
687688
self.typeck_results.liberated_fn_sigs_mut().insert(hir_id, fn_sig);
688689
}
@@ -696,7 +697,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
696697
let fcx_fru_field_types = fcx_typeck_results.fru_field_types().items_in_stable_order();
697698

698699
for (local_id, ftys) in fcx_fru_field_types {
699-
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
700+
let hir_id = HirId { owner: common_hir_owner, local_id };
700701
let ftys = self.resolve(ftys.clone(), &hir_id);
701702
self.typeck_results.fru_field_types_mut().insert(hir_id, ftys);
702703
}
@@ -710,7 +711,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
710711
for (local_id, &(container, ref indices)) in
711712
fcx_typeck_results.offset_of_data().items_in_stable_order()
712713
{
713-
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
714+
let hir_id = HirId { owner: common_hir_owner, local_id };
714715
let container = self.resolve(container, &hir_id);
715716
self.typeck_results.offset_of_data_mut().insert(hir_id, (container, indices.clone()));
716717
}
@@ -745,7 +746,7 @@ impl Locatable for Span {
745746
}
746747
}
747748

748-
impl Locatable for hir::HirId {
749+
impl Locatable for HirId {
749750
fn to_span(&self, tcx: TyCtxt<'_>) -> Span {
750751
tcx.hir().span(*self)
751752
}

‎compiler/rustc_lint/src/late.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use rustc_data_structures::sync::{join, Lrc};
2121
use rustc_hir as hir;
2222
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
2323
use rustc_hir::intravisit as hir_visit;
24+
use rustc_hir::HirId;
2425
use rustc_middle::hir::nested_filter;
2526
use rustc_middle::ty::{self, TyCtxt};
2627
use rustc_session::lint::LintPass;
@@ -54,7 +55,7 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
5455
/// Merge the lints specified by any lint attributes into the
5556
/// current lint context, call the provided function, then reset the
5657
/// lints in effect to their previous state.
57-
fn with_lint_attrs<F>(&mut self, id: hir::HirId, f: F)
58+
fn with_lint_attrs<F>(&mut self, id: HirId, f: F)
5859
where
5960
F: FnOnce(&mut Self),
6061
{
@@ -82,7 +83,7 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
8283
self.context.param_env = old_param_env;
8384
}
8485

85-
fn process_mod(&mut self, m: &'tcx hir::Mod<'tcx>, n: hir::HirId) {
86+
fn process_mod(&mut self, m: &'tcx hir::Mod<'tcx>, n: HirId) {
8687
lint_callback!(self, check_mod, m, n);
8788
hir_visit::walk_mod(self, m, n);
8889
}
@@ -232,7 +233,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
232233
hir_visit::walk_inf(self, inf);
233234
}
234235

235-
fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, _: Span, n: hir::HirId) {
236+
fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, _: Span, n: HirId) {
236237
if !self.context.only_module {
237238
self.process_mod(m, n);
238239
}
@@ -306,7 +307,7 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
306307
hir_visit::walk_lifetime(self, lt);
307308
}
308309

309-
fn visit_path(&mut self, p: &hir::Path<'tcx>, id: hir::HirId) {
310+
fn visit_path(&mut self, p: &hir::Path<'tcx>, id: HirId) {
310311
lint_callback!(self, check_path, p, id);
311312
hir_visit::walk_path(self, p);
312313
}

‎compiler/rustc_middle/src/middle/region.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::ty::TyCtxt;
1010
use rustc_data_structures::fx::FxIndexMap;
1111
use rustc_data_structures::unord::UnordMap;
1212
use rustc_hir as hir;
13-
use rustc_hir::{HirIdMap, Node};
13+
use rustc_hir::{HirId, HirIdMap, Node};
1414
use rustc_macros::HashStable;
1515
use rustc_span::{Span, DUMMY_SP};
1616

@@ -164,10 +164,10 @@ impl Scope {
164164
self.id
165165
}
166166

167-
pub fn hir_id(&self, scope_tree: &ScopeTree) -> Option<hir::HirId> {
167+
pub fn hir_id(&self, scope_tree: &ScopeTree) -> Option<HirId> {
168168
scope_tree
169169
.root_body
170-
.map(|hir_id| hir::HirId { owner: hir_id.owner, local_id: self.item_local_id() })
170+
.map(|hir_id| HirId { owner: hir_id.owner, local_id: self.item_local_id() })
171171
}
172172

173173
/// Returns the span of this `Scope`. Note that in general the
@@ -207,7 +207,7 @@ pub type ScopeDepth = u32;
207207
#[derive(Default, Debug, HashStable)]
208208
pub struct ScopeTree {
209209
/// If not empty, this body is the root of this region hierarchy.
210-
pub root_body: Option<hir::HirId>,
210+
pub root_body: Option<HirId>,
211211

212212
/// Maps from a scope ID to the enclosing scope id;
213213
/// this is usually corresponding to the lexical nesting, though
@@ -341,11 +341,7 @@ impl ScopeTree {
341341
self.var_map.insert(var, lifetime);
342342
}
343343

344-
pub fn record_rvalue_candidate(
345-
&mut self,
346-
var: hir::HirId,
347-
candidate_type: RvalueCandidateType,
348-
) {
344+
pub fn record_rvalue_candidate(&mut self, var: HirId, candidate_type: RvalueCandidateType) {
349345
debug!("record_rvalue_candidate(var={var:?}, type={candidate_type:?})");
350346
match &candidate_type {
351347
RvalueCandidateType::Borrow { lifetime: Some(lifetime), .. }

‎compiler/rustc_middle/src/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ pub enum Safety {
804804
/// Unsafe because of an unsafe fn
805805
FnUnsafe,
806806
/// Unsafe because of an `unsafe` block
807-
ExplicitUnsafe(hir::HirId),
807+
ExplicitUnsafe(HirId),
808808
}
809809

810810
impl<'tcx> Index<BasicBlock> for Body<'tcx> {
@@ -1561,7 +1561,7 @@ pub struct SourceScopeData<'tcx> {
15611561
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
15621562
pub struct SourceScopeLocalData {
15631563
/// An `HirId` with lint levels equivalent to this scope's lint levels.
1564-
pub lint_root: hir::HirId,
1564+
pub lint_root: HirId,
15651565
/// The unsafe block that contains this node.
15661566
pub safety: Safety,
15671567
}

‎compiler/rustc_middle/src/mir/query.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::ty::{self, OpaqueHiddenType, Ty, TyCtxt};
55
use rustc_data_structures::fx::FxIndexMap;
66
use rustc_data_structures::unord::UnordSet;
77
use rustc_errors::ErrorGuaranteed;
8-
use rustc_hir as hir;
98
use rustc_hir::def_id::LocalDefId;
9+
use rustc_hir::HirId;
1010
use rustc_index::bit_set::BitMatrix;
1111
use rustc_index::{Idx, IndexVec};
1212
use rustc_span::symbol::Symbol;
@@ -52,7 +52,7 @@ pub enum UnsafetyViolationDetails {
5252
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, HashStable, Debug)]
5353
pub struct UnsafetyViolation {
5454
pub source_info: SourceInfo,
55-
pub lint_root: hir::HirId,
55+
pub lint_root: HirId,
5656
pub kind: UnsafetyViolationKind,
5757
pub details: UnsafetyViolationDetails,
5858
}
@@ -64,7 +64,7 @@ pub enum UnusedUnsafe {
6464
Unused,
6565
/// `unsafe` block nested under another (used) `unsafe` block
6666
/// > ``… because it's nested under this `unsafe` block``
67-
InUnsafeBlock(hir::HirId),
67+
InUnsafeBlock(HirId),
6868
}
6969

7070
#[derive(TyEncodable, TyDecodable, HashStable, Debug)]
@@ -73,10 +73,10 @@ pub struct UnsafetyCheckResult {
7373
pub violations: Vec<UnsafetyViolation>,
7474

7575
/// Used `unsafe` blocks in this function. This is used for the "unused_unsafe" lint.
76-
pub used_unsafe_blocks: UnordSet<hir::HirId>,
76+
pub used_unsafe_blocks: UnordSet<HirId>,
7777

7878
/// This is `Some` iff the item is not a closure.
79-
pub unused_unsafes: Option<Vec<(hir::HirId, UnusedUnsafe)>>,
79+
pub unused_unsafes: Option<Vec<(HirId, UnusedUnsafe)>>,
8080
}
8181

8282
rustc_index::newtype_index! {

‎compiler/rustc_middle/src/thir.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
1212
use rustc_errors::{DiagArgValue, IntoDiagArg};
1313
use rustc_hir as hir;
1414
use rustc_hir::def_id::DefId;
15-
use rustc_hir::RangeEnd;
15+
use rustc_hir::{HirId, RangeEnd};
1616
use rustc_index::newtype_index;
1717
use rustc_index::IndexVec;
1818
use rustc_middle::middle::region;
@@ -115,13 +115,13 @@ pub struct Param<'tcx> {
115115
/// Whether this param is `self`, and how it is bound.
116116
pub self_kind: Option<hir::ImplicitSelfKind>,
117117
/// HirId for lints.
118-
pub hir_id: Option<hir::HirId>,
118+
pub hir_id: Option<HirId>,
119119
}
120120

121121
#[derive(Copy, Clone, Debug, HashStable)]
122122
pub enum LintLevel {
123123
Inherited,
124-
Explicit(hir::HirId),
124+
Explicit(HirId),
125125
}
126126

127127
#[derive(Clone, Debug, HashStable)]
@@ -167,7 +167,7 @@ pub struct ClosureExpr<'tcx> {
167167
pub args: UpvarArgs<'tcx>,
168168
pub upvars: Box<[ExprId]>,
169169
pub movability: Option<hir::Movability>,
170-
pub fake_reads: Vec<(ExprId, FakeReadCause, hir::HirId)>,
170+
pub fake_reads: Vec<(ExprId, FakeReadCause, HirId)>,
171171
}
172172

173173
#[derive(Clone, Debug, HashStable)]
@@ -184,7 +184,7 @@ pub enum BlockSafety {
184184
/// A compiler-generated unsafe block
185185
BuiltinUnsafe,
186186
/// An `unsafe` block. The `HirId` is the ID of the block.
187-
ExplicitUnsafe(hir::HirId),
187+
ExplicitUnsafe(HirId),
188188
}
189189

190190
#[derive(Clone, Debug, HashStable)]
@@ -233,7 +233,7 @@ pub enum StmtKind<'tcx> {
233233
}
234234

235235
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)]
236-
pub struct LocalVarId(pub hir::HirId);
236+
pub struct LocalVarId(pub HirId);
237237

238238
/// A THIR expression.
239239
#[derive(Clone, Debug, HashStable)]
@@ -356,7 +356,7 @@ pub enum ExprKind<'tcx> {
356356
/// A `match` expression.
357357
Match {
358358
scrutinee: ExprId,
359-
scrutinee_hir_id: hir::HirId,
359+
scrutinee_hir_id: HirId,
360360
arms: Box<[ArmId]>,
361361
},
362362
/// A block.

‎compiler/rustc_middle/src/traits/mod.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use rustc_data_structures::sync::Lrc;
1919
use rustc_errors::{Applicability, Diag, EmissionGuarantee};
2020
use rustc_hir as hir;
2121
use rustc_hir::def_id::DefId;
22+
use rustc_hir::HirId;
2223
use rustc_span::def_id::{LocalDefId, CRATE_DEF_ID};
2324
use rustc_span::symbol::Symbol;
2425
use rustc_span::{Span, DUMMY_SP};
@@ -262,10 +263,10 @@ pub enum ObligationCauseCode<'tcx> {
262263
/// expression that caused the obligation, and the `usize`
263264
/// indicates exactly which predicate it is in the list of
264265
/// instantiated predicates.
265-
ExprItemObligation(DefId, rustc_hir::HirId, usize),
266+
ExprItemObligation(DefId, HirId, usize),
266267

267268
/// Combines `ExprItemObligation` and `BindingObligation`.
268-
ExprBindingObligation(DefId, Span, rustc_hir::HirId, usize),
269+
ExprBindingObligation(DefId, Span, HirId, usize),
269270

270271
/// A type like `&'a T` is WF only if `T: 'a`.
271272
ReferenceOutlivesReferent(Ty<'tcx>),
@@ -287,9 +288,9 @@ pub enum ObligationCauseCode<'tcx> {
287288
/// `S { ... }` must be `Sized`.
288289
StructInitializerSized,
289290
/// Type of each variable must be `Sized`.
290-
VariableType(hir::HirId),
291+
VariableType(HirId),
291292
/// Argument type must be `Sized`.
292-
SizedArgumentType(Option<hir::HirId>),
293+
SizedArgumentType(Option<HirId>),
293294
/// Return type must be `Sized`.
294295
SizedReturnType,
295296
/// Return type of a call expression must be `Sized`.
@@ -335,9 +336,9 @@ pub enum ObligationCauseCode<'tcx> {
335336

336337
FunctionArgumentObligation {
337338
/// The node of the relevant argument in the function call.
338-
arg_hir_id: hir::HirId,
339+
arg_hir_id: HirId,
339340
/// The node of the function call.
340-
call_hir_id: hir::HirId,
341+
call_hir_id: HirId,
341342
/// The obligation introduced by this argument.
342343
parent_code: InternedObligationCauseCode<'tcx>,
343344
},
@@ -402,18 +403,18 @@ pub enum ObligationCauseCode<'tcx> {
402403
ReturnNoExpression,
403404

404405
/// `return` with an expression
405-
ReturnValue(hir::HirId),
406+
ReturnValue(HirId),
406407

407408
/// Opaque return type of this function
408409
OpaqueReturnType(Option<(Ty<'tcx>, Span)>),
409410

410411
/// Block implicit return
411-
BlockTailExpression(hir::HirId, hir::MatchSource),
412+
BlockTailExpression(HirId, hir::MatchSource),
412413

413414
/// #[feature(trivial_bounds)] is not enabled
414415
TrivialBound,
415416

416-
AwaitableExpr(hir::HirId),
417+
AwaitableExpr(HirId),
417418

418419
ForLoopIterator,
419420

@@ -431,8 +432,8 @@ pub enum ObligationCauseCode<'tcx> {
431432
MatchImpl(ObligationCause<'tcx>, DefId),
432433

433434
BinOp {
434-
lhs_hir_id: hir::HirId,
435-
rhs_hir_id: Option<hir::HirId>,
435+
lhs_hir_id: HirId,
436+
rhs_hir_id: Option<HirId>,
436437
rhs_span: Option<Span>,
437438
rhs_is_lit: bool,
438439
output_ty: Option<Ty<'tcx>>,
@@ -562,10 +563,10 @@ pub enum StatementAsExpression {
562563
#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
563564
#[derive(TypeVisitable, TypeFoldable)]
564565
pub struct MatchExpressionArmCause<'tcx> {
565-
pub arm_block_id: Option<hir::HirId>,
566+
pub arm_block_id: Option<HirId>,
566567
pub arm_ty: Ty<'tcx>,
567568
pub arm_span: Span,
568-
pub prior_arm_block_id: Option<hir::HirId>,
569+
pub prior_arm_block_id: Option<HirId>,
569570
pub prior_arm_ty: Ty<'tcx>,
570571
pub prior_arm_span: Span,
571572
pub scrut_span: Span,
@@ -577,8 +578,8 @@ pub struct MatchExpressionArmCause<'tcx> {
577578
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
578579
#[derive(TypeFoldable, TypeVisitable, HashStable, TyEncodable, TyDecodable)]
579580
pub struct IfExpressionCause<'tcx> {
580-
pub then_id: hir::HirId,
581-
pub else_id: hir::HirId,
581+
pub then_id: HirId,
582+
pub else_id: HirId,
582583
pub then_ty: Ty<'tcx>,
583584
pub else_ty: Ty<'tcx>,
584585
pub outer_span: Option<Span>,

‎compiler/rustc_middle/src/ty/closure.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::query::Providers;
99
use rustc_data_structures::fx::FxIndexMap;
1010
use rustc_hir as hir;
1111
use rustc_hir::def_id::LocalDefId;
12+
use rustc_hir::HirId;
1213
use rustc_span::def_id::LocalDefIdMap;
1314
use rustc_span::symbol::Ident;
1415
use rustc_span::{Span, Symbol};
@@ -24,7 +25,7 @@ pub const CAPTURE_STRUCT_LOCAL: mir::Local = mir::Local::from_u32(1);
2425
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
2526
#[derive(TypeFoldable, TypeVisitable)]
2627
pub struct UpvarPath {
27-
pub hir_id: hir::HirId,
28+
pub hir_id: HirId,
2829
}
2930

3031
/// Upvars do not get their own `NodeId`. Instead, we use the pair of
@@ -38,7 +39,7 @@ pub struct UpvarId {
3839
}
3940

4041
impl UpvarId {
41-
pub fn new(var_hir_id: hir::HirId, closure_def_id: LocalDefId) -> UpvarId {
42+
pub fn new(var_hir_id: HirId, closure_def_id: LocalDefId) -> UpvarId {
4243
UpvarId { var_path: UpvarPath { hir_id: var_hir_id }, closure_expr_id: closure_def_id }
4344
}
4445
}
@@ -67,7 +68,7 @@ pub type MinCaptureInformationMap<'tcx> = LocalDefIdMap<RootVariableMinCaptureLi
6768
///
6869
/// This provides a convenient and quick way of checking if a variable being used within
6970
/// a closure is a capture of a local variable.
70-
pub type RootVariableMinCaptureList<'tcx> = FxIndexMap<hir::HirId, MinCaptureList<'tcx>>;
71+
pub type RootVariableMinCaptureList<'tcx> = FxIndexMap<HirId, MinCaptureList<'tcx>>;
7172

7273
/// Part of `MinCaptureInformationMap`; List of `CapturePlace`s.
7374
pub type MinCaptureList<'tcx> = Vec<CapturedPlace<'tcx>>;
@@ -134,7 +135,7 @@ impl<'tcx> CapturedPlace<'tcx> {
134135

135136
/// Returns the hir-id of the root variable for the captured place.
136137
/// e.g., if `a.b.c` was captured, would return the hir-id for `a`.
137-
pub fn get_root_variable(&self) -> hir::HirId {
138+
pub fn get_root_variable(&self) -> HirId {
138139
match self.place.base {
139140
HirPlaceBase::Upvar(upvar_id) => upvar_id.var_path.hir_id,
140141
base => bug!("Expected upvar, found={:?}", base),
@@ -285,12 +286,12 @@ pub struct CaptureInfo {
285286
///
286287
/// In this example, if `capture_disjoint_fields` is **not** set, then x will be captured,
287288
/// but we won't see it being used during capture analysis, since it's essentially a discard.
288-
pub capture_kind_expr_id: Option<hir::HirId>,
289+
pub capture_kind_expr_id: Option<HirId>,
289290
/// Expr Id pointing to use that resulted the corresponding place being captured
290291
///
291292
/// See `capture_kind_expr_id` for example.
292293
///
293-
pub path_expr_id: Option<hir::HirId>,
294+
pub path_expr_id: Option<HirId>,
294295

295296
/// Capture mode that was selected
296297
pub capture_kind: UpvarCapture,

‎compiler/rustc_middle/src/ty/typeck_results.rs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ pub struct TypeckResults<'tcx> {
188188
/// we never capture `t`. This becomes an issue when we build MIR as we require
189189
/// information on `t` in order to create place `t.0` and `t.1`. We can solve this
190190
/// issue by fake reading `t`.
191-
pub closure_fake_reads: LocalDefIdMap<Vec<(HirPlace<'tcx>, FakeReadCause, hir::HirId)>>,
191+
pub closure_fake_reads: LocalDefIdMap<Vec<(HirPlace<'tcx>, FakeReadCause, HirId)>>,
192192

193193
/// Tracks the rvalue scoping rules which defines finer scoping for rvalue expressions
194194
/// by applying extended parameter rules.
@@ -246,7 +246,7 @@ impl<'tcx> TypeckResults<'tcx> {
246246
}
247247

248248
/// Returns the final resolution of a `QPath` in an `Expr` or `Pat` node.
249-
pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: hir::HirId) -> Res {
249+
pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: HirId) -> Res {
250250
match *qpath {
251251
hir::QPath::Resolved(_, path) => path.res,
252252
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
@@ -284,11 +284,11 @@ impl<'tcx> TypeckResults<'tcx> {
284284
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.field_indices }
285285
}
286286

287-
pub fn field_index(&self, id: hir::HirId) -> FieldIdx {
287+
pub fn field_index(&self, id: HirId) -> FieldIdx {
288288
self.field_indices().get(id).cloned().expect("no index for a field")
289289
}
290290

291-
pub fn opt_field_index(&self, id: hir::HirId) -> Option<FieldIdx> {
291+
pub fn opt_field_index(&self, id: HirId) -> Option<FieldIdx> {
292292
self.field_indices().get(id).cloned()
293293
}
294294

@@ -300,7 +300,7 @@ impl<'tcx> TypeckResults<'tcx> {
300300
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.nested_fields }
301301
}
302302

303-
pub fn nested_field_tys_and_indices(&self, id: hir::HirId) -> &[(Ty<'tcx>, FieldIdx)] {
303+
pub fn nested_field_tys_and_indices(&self, id: HirId) -> &[(Ty<'tcx>, FieldIdx)] {
304304
self.nested_fields().get(id).map_or(&[], Vec::as_slice)
305305
}
306306

@@ -322,13 +322,13 @@ impl<'tcx> TypeckResults<'tcx> {
322322
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.node_types }
323323
}
324324

325-
pub fn node_type(&self, id: hir::HirId) -> Ty<'tcx> {
325+
pub fn node_type(&self, id: HirId) -> Ty<'tcx> {
326326
self.node_type_opt(id).unwrap_or_else(|| {
327327
bug!("node_type: no type for node {}", tls::with(|tcx| tcx.hir().node_to_string(id)))
328328
})
329329
}
330330

331-
pub fn node_type_opt(&self, id: hir::HirId) -> Option<Ty<'tcx>> {
331+
pub fn node_type_opt(&self, id: HirId) -> Option<Ty<'tcx>> {
332332
validate_hir_id_for_typeck_results(self.hir_owner, id);
333333
self.node_types.get(&id.local_id).cloned()
334334
}
@@ -337,12 +337,12 @@ impl<'tcx> TypeckResults<'tcx> {
337337
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.node_args }
338338
}
339339

340-
pub fn node_args(&self, id: hir::HirId) -> GenericArgsRef<'tcx> {
340+
pub fn node_args(&self, id: HirId) -> GenericArgsRef<'tcx> {
341341
validate_hir_id_for_typeck_results(self.hir_owner, id);
342342
self.node_args.get(&id.local_id).cloned().unwrap_or_else(|| GenericArgs::empty())
343343
}
344344

345-
pub fn node_args_opt(&self, id: hir::HirId) -> Option<GenericArgsRef<'tcx>> {
345+
pub fn node_args_opt(&self, id: HirId) -> Option<GenericArgsRef<'tcx>> {
346346
validate_hir_id_for_typeck_results(self.hir_owner, id);
347347
self.node_args.get(&id.local_id).cloned()
348348
}
@@ -469,7 +469,7 @@ impl<'tcx> TypeckResults<'tcx> {
469469
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.fru_field_types }
470470
}
471471

472-
pub fn is_coercion_cast(&self, hir_id: hir::HirId) -> bool {
472+
pub fn is_coercion_cast(&self, hir_id: HirId) -> bool {
473473
validate_hir_id_for_typeck_results(self.hir_owner, hir_id);
474474
self.coercion_casts.contains(&hir_id.local_id)
475475
}
@@ -503,15 +503,15 @@ impl<'tcx> TypeckResults<'tcx> {
503503
/// would result in lookup errors, or worse, in silently wrong data being
504504
/// stored/returned.
505505
#[inline]
506-
fn validate_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: hir::HirId) {
506+
fn validate_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: HirId) {
507507
if hir_id.owner != hir_owner {
508508
invalid_hir_id_for_typeck_results(hir_owner, hir_id);
509509
}
510510
}
511511

512512
#[cold]
513513
#[inline(never)]
514-
fn invalid_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: hir::HirId) {
514+
fn invalid_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: HirId) {
515515
ty::tls::with(|tcx| {
516516
bug!(
517517
"node {} cannot be placed in TypeckResults with hir_owner {:?}",
@@ -527,12 +527,12 @@ pub struct LocalTableInContext<'a, V> {
527527
}
528528

529529
impl<'a, V> LocalTableInContext<'a, V> {
530-
pub fn contains_key(&self, id: hir::HirId) -> bool {
530+
pub fn contains_key(&self, id: HirId) -> bool {
531531
validate_hir_id_for_typeck_results(self.hir_owner, id);
532532
self.data.contains_key(&id.local_id)
533533
}
534534

535-
pub fn get(&self, id: hir::HirId) -> Option<&'a V> {
535+
pub fn get(&self, id: HirId) -> Option<&'a V> {
536536
validate_hir_id_for_typeck_results(self.hir_owner, id);
537537
self.data.get(&id.local_id)
538538
}
@@ -549,10 +549,10 @@ impl<'a, V> LocalTableInContext<'a, V> {
549549
}
550550
}
551551

552-
impl<'a, V> ::std::ops::Index<hir::HirId> for LocalTableInContext<'a, V> {
552+
impl<'a, V> ::std::ops::Index<HirId> for LocalTableInContext<'a, V> {
553553
type Output = V;
554554

555-
fn index(&self, key: hir::HirId) -> &V {
555+
fn index(&self, key: HirId) -> &V {
556556
self.get(key).expect("LocalTableInContext: key not found")
557557
}
558558
}
@@ -563,35 +563,32 @@ pub struct LocalTableInContextMut<'a, V> {
563563
}
564564

565565
impl<'a, V> LocalTableInContextMut<'a, V> {
566-
pub fn get_mut(&mut self, id: hir::HirId) -> Option<&mut V> {
566+
pub fn get_mut(&mut self, id: HirId) -> Option<&mut V> {
567567
validate_hir_id_for_typeck_results(self.hir_owner, id);
568568
self.data.get_mut(&id.local_id)
569569
}
570570

571-
pub fn get(&mut self, id: hir::HirId) -> Option<&V> {
571+
pub fn get(&mut self, id: HirId) -> Option<&V> {
572572
validate_hir_id_for_typeck_results(self.hir_owner, id);
573573
self.data.get(&id.local_id)
574574
}
575575

576-
pub fn entry(&mut self, id: hir::HirId) -> Entry<'_, hir::ItemLocalId, V> {
576+
pub fn entry(&mut self, id: HirId) -> Entry<'_, hir::ItemLocalId, V> {
577577
validate_hir_id_for_typeck_results(self.hir_owner, id);
578578
self.data.entry(id.local_id)
579579
}
580580

581-
pub fn insert(&mut self, id: hir::HirId, val: V) -> Option<V> {
581+
pub fn insert(&mut self, id: HirId, val: V) -> Option<V> {
582582
validate_hir_id_for_typeck_results(self.hir_owner, id);
583583
self.data.insert(id.local_id, val)
584584
}
585585

586-
pub fn remove(&mut self, id: hir::HirId) -> Option<V> {
586+
pub fn remove(&mut self, id: HirId) -> Option<V> {
587587
validate_hir_id_for_typeck_results(self.hir_owner, id);
588588
self.data.remove(&id.local_id)
589589
}
590590

591-
pub fn extend(
592-
&mut self,
593-
items: UnordItems<(hir::HirId, V), impl Iterator<Item = (hir::HirId, V)>>,
594-
) {
591+
pub fn extend(&mut self, items: UnordItems<(HirId, V), impl Iterator<Item = (HirId, V)>>) {
595592
self.data.extend_unord(items.map(|(id, value)| {
596593
validate_hir_id_for_typeck_results(self.hir_owner, id);
597594
(id.local_id, value)

‎compiler/rustc_mir_build/src/build/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_errors::ErrorGuaranteed;
1010
use rustc_hir as hir;
1111
use rustc_hir::def::DefKind;
1212
use rustc_hir::def_id::{DefId, LocalDefId};
13-
use rustc_hir::Node;
13+
use rustc_hir::{HirId, Node};
1414
use rustc_index::bit_set::GrowableBitSet;
1515
use rustc_index::{Idx, IndexSlice, IndexVec};
1616
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
@@ -173,7 +173,7 @@ struct Builder<'a, 'tcx> {
173173
cfg: CFG<'tcx>,
174174

175175
def_id: LocalDefId,
176-
hir_id: hir::HirId,
176+
hir_id: HirId,
177177
parent_module: DefId,
178178
check_overflow: bool,
179179
fn_span: Span,
@@ -240,7 +240,7 @@ struct Builder<'a, 'tcx> {
240240
coverage_branch_info: Option<coverageinfo::BranchInfoBuilder>,
241241
}
242242

243-
type CaptureMap<'tcx> = SortedIndexMultiMap<usize, hir::HirId, Capture<'tcx>>;
243+
type CaptureMap<'tcx> = SortedIndexMultiMap<usize, HirId, Capture<'tcx>>;
244244

245245
#[derive(Debug)]
246246
struct Capture<'tcx> {
@@ -758,7 +758,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
758758
thir: &'a Thir<'tcx>,
759759
infcx: InferCtxt<'tcx>,
760760
def: LocalDefId,
761-
hir_id: hir::HirId,
761+
hir_id: HirId,
762762
span: Span,
763763
arg_count: usize,
764764
safety: Safety,
@@ -1024,7 +1024,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10241024

10251025
fn set_correct_source_scope_for_arg(
10261026
&mut self,
1027-
arg_hir_id: hir::HirId,
1027+
arg_hir_id: HirId,
10281028
original_source_scope: SourceScope,
10291029
pattern_span: Span,
10301030
) {

‎compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
use std::borrow::Cow;
2-
31
use crate::build::ExprCategory;
42
use crate::errors::*;
5-
use rustc_middle::thir::visit::Visitor;
63

74
use rustc_errors::DiagArgValue;
85
use rustc_hir as hir;
6+
use rustc_hir::HirId;
97
use rustc_middle::mir::BorrowKind;
8+
use rustc_middle::thir::visit::Visitor;
109
use rustc_middle::thir::*;
1110
use rustc_middle::ty::print::with_no_trimmed_paths;
1211
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt};
@@ -16,6 +15,7 @@ use rustc_span::def_id::{DefId, LocalDefId};
1615
use rustc_span::symbol::Symbol;
1716
use rustc_span::{sym, Span};
1817

18+
use std::borrow::Cow;
1919
use std::mem;
2020
use std::ops::Bound;
2121

@@ -24,7 +24,7 @@ struct UnsafetyVisitor<'a, 'tcx> {
2424
thir: &'a Thir<'tcx>,
2525
/// The `HirId` of the current scope, which would be the `HirId`
2626
/// of the current HIR node, modulo adjustments. Used for lint levels.
27-
hir_context: hir::HirId,
27+
hir_context: HirId,
2828
/// The current "safety context". This notably tracks whether we are in an
2929
/// `unsafe` block, and whether it has been used.
3030
safety_context: SafetyContext,
@@ -123,7 +123,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
123123

124124
fn warn_unused_unsafe(
125125
&mut self,
126-
hir_id: hir::HirId,
126+
hir_id: HirId,
127127
block_span: Span,
128128
enclosing_unsafe: Option<UnusedUnsafeEnclosing>,
129129
) {
@@ -536,22 +536,17 @@ enum SafetyContext {
536536
Safe,
537537
BuiltinUnsafeBlock,
538538
UnsafeFn,
539-
UnsafeBlock {
540-
span: Span,
541-
hir_id: hir::HirId,
542-
used: bool,
543-
nested_used_blocks: Vec<NestedUsedBlock>,
544-
},
539+
UnsafeBlock { span: Span, hir_id: HirId, used: bool, nested_used_blocks: Vec<NestedUsedBlock> },
545540
}
546541

547542
#[derive(Clone, Copy)]
548543
struct NestedUsedBlock {
549-
hir_id: hir::HirId,
544+
hir_id: HirId,
550545
span: Span,
551546
}
552547

553548
struct UnusedUnsafeWarning {
554-
hir_id: hir::HirId,
549+
hir_id: HirId,
555550
block_span: Span,
556551
enclosing_unsafe: Option<UnusedUnsafeEnclosing>,
557552
}
@@ -584,7 +579,7 @@ impl UnsafeOpKind {
584579
pub fn emit_unsafe_op_in_unsafe_fn_lint(
585580
&self,
586581
tcx: TyCtxt<'_>,
587-
hir_id: hir::HirId,
582+
hir_id: HirId,
588583
span: Span,
589584
suggest_unsafe_block: bool,
590585
) {
@@ -725,7 +720,7 @@ impl UnsafeOpKind {
725720
&self,
726721
tcx: TyCtxt<'_>,
727722
span: Span,
728-
hir_context: hir::HirId,
723+
hir_context: HirId,
729724
unsafe_op_in_unsafe_fn_allowed: bool,
730725
) {
731726
let note_non_inherited = tcx.hir().parent_iter(hir_context).find(|(id, node)| {

‎compiler/rustc_passes/src/hir_stats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
387387
hir_visit::walk_fn(self, fk, fd, b, id)
388388
}
389389

390-
fn visit_use(&mut self, p: &'v hir::UsePath<'v>, hir_id: hir::HirId) {
390+
fn visit_use(&mut self, p: &'v hir::UsePath<'v>, hir_id: HirId) {
391391
// This is `visit_use`, but the type is `Path` so record it that way.
392392
self.record("Path", Id::None, p);
393393
hir_visit::walk_use(self, p, hir_id)
@@ -460,7 +460,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
460460
hir_visit::walk_lifetime(self, lifetime)
461461
}
462462

463-
fn visit_path(&mut self, path: &hir::Path<'v>, _id: hir::HirId) {
463+
fn visit_path(&mut self, path: &hir::Path<'v>, _id: HirId) {
464464
self.record("Path", Id::None, path);
465465
hir_visit::walk_path(self, path)
466466
}

‎compiler/rustc_passes/src/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
602602
String::from_utf8(wr).unwrap()
603603
}
604604

605-
fn log_liveness(&self, entry_ln: LiveNode, hir_id: hir::HirId) {
605+
fn log_liveness(&self, entry_ln: LiveNode, hir_id: HirId) {
606606
// hack to skip the loop unless debug! is enabled:
607607
debug!(
608608
"^^ liveness computation results for body {} (entry={:?})",

‎compiler/rustc_passes/src/naked_functions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir as hir;
55
use rustc_hir::def::DefKind;
66
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
77
use rustc_hir::intravisit::Visitor;
8-
use rustc_hir::{ExprKind, InlineAsmOperand, StmtKind};
8+
use rustc_hir::{ExprKind, HirIdSet, InlineAsmOperand, StmtKind};
99
use rustc_middle::query::Providers;
1010
use rustc_middle::ty::TyCtxt;
1111
use rustc_session::lint::builtin::UNDEFINED_NAKED_FUNCTION_ABI;
@@ -94,7 +94,7 @@ fn check_no_patterns(tcx: TyCtxt<'_>, params: &[hir::Param<'_>]) {
9494

9595
/// Checks that function parameters aren't used in the function body.
9696
fn check_no_parameters_use<'tcx>(tcx: TyCtxt<'tcx>, body: &'tcx hir::Body<'tcx>) {
97-
let mut params = hir::HirIdSet::default();
97+
let mut params = HirIdSet::default();
9898
for param in body.params {
9999
param.pat.each_binding(|_binding_mode, hir_id, _span, _ident| {
100100
params.insert(hir_id);
@@ -105,7 +105,7 @@ fn check_no_parameters_use<'tcx>(tcx: TyCtxt<'tcx>, body: &'tcx hir::Body<'tcx>)
105105

106106
struct CheckParameters<'tcx> {
107107
tcx: TyCtxt<'tcx>,
108-
params: hir::HirIdSet,
108+
params: HirIdSet,
109109
}
110110

111111
impl<'tcx> Visitor<'tcx> for CheckParameters<'tcx> {

‎compiler/rustc_passes/src/upvars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl CaptureCollector<'_, '_> {
6666
}
6767

6868
impl<'tcx> Visitor<'tcx> for CaptureCollector<'_, 'tcx> {
69-
fn visit_path(&mut self, path: &hir::Path<'tcx>, _: hir::HirId) {
69+
fn visit_path(&mut self, path: &hir::Path<'tcx>, _: HirId) {
7070
if let Res::Local(var_id) = path.res {
7171
self.visit_local_use(var_id, path.span);
7272
}

‎compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4253,7 +4253,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
42534253
type_diffs: &[TypeError<'tcx>],
42544254
span: Span,
42554255
prev_ty: Ty<'tcx>,
4256-
body_id: hir::HirId,
4256+
body_id: HirId,
42574257
param_env: ty::ParamEnv<'tcx>,
42584258
) -> Vec<Option<(Span, (DefId, Ty<'tcx>))>> {
42594259
let ocx = ObligationCtxt::new(self.infcx);
@@ -4704,7 +4704,7 @@ impl<'v> Visitor<'v> for ReturnsVisitor<'v> {
47044704
/// Collect all the awaited expressions within the input expression.
47054705
#[derive(Default)]
47064706
struct AwaitsVisitor {
4707-
awaits: Vec<hir::HirId>,
4707+
awaits: Vec<HirId>,
47084708
}
47094709

47104710
impl<'v> Visitor<'v> for AwaitsVisitor {

‎src/tools/clippy/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_hir::{self as hir, intravisit, HirIdSet};
1+
use rustc_hir::{self as hir, intravisit, HirId, HirIdSet};
22
use rustc_lint::LateContext;
33
use rustc_middle::ty;
44
use rustc_span::def_id::LocalDefId;
@@ -74,7 +74,7 @@ fn check_raw_ptr<'tcx>(
7474
}
7575
}
7676

77-
fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option<hir::HirId> {
77+
fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option<HirId> {
7878
if let (&hir::PatKind::Binding(_, id, _, _), Some(&ty::RawPtr(_))) = (
7979
&arg.pat.kind,
8080
cx.maybe_typeck_results()

‎src/tools/clippy/clippy_lints/src/index_refutable_slice.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use clippy_utils::{is_expn_of, is_lint_allowed, path_to_local};
77
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
88
use rustc_errors::Applicability;
99
use rustc_hir as hir;
10+
use rustc_hir::HirId;
1011
use rustc_hir::intravisit::{self, Visitor};
1112
use rustc_lint::{LateContext, LateLintPass};
1213
use rustc_middle::hir::nested_filter;
@@ -87,9 +88,9 @@ impl<'tcx> LateLintPass<'tcx> for IndexRefutableSlice {
8788
extract_msrv_attr!(LateContext);
8889
}
8990

90-
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<hir::HirId, SliceLintInformation> {
91-
let mut removed_pat: FxHashSet<hir::HirId> = FxHashSet::default();
92-
let mut slices: FxIndexMap<hir::HirId, SliceLintInformation> = FxIndexMap::default();
91+
fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<HirId, SliceLintInformation> {
92+
let mut removed_pat: FxHashSet<HirId> = FxHashSet::default();
93+
let mut slices: FxIndexMap<HirId, SliceLintInformation> = FxIndexMap::default();
9394
pat.walk_always(|pat| {
9495
// We'll just ignore mut and ref mut for simplicity sake right now
9596
if let hir::PatKind::Binding(
@@ -206,10 +207,10 @@ impl SliceLintInformation {
206207

207208
fn filter_lintable_slices<'tcx>(
208209
cx: &LateContext<'tcx>,
209-
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
210+
slice_lint_info: FxIndexMap<HirId, SliceLintInformation>,
210211
max_suggested_slice: u64,
211212
scope: &'tcx hir::Expr<'tcx>,
212-
) -> FxIndexMap<hir::HirId, SliceLintInformation> {
213+
) -> FxIndexMap<HirId, SliceLintInformation> {
213214
let mut visitor = SliceIndexLintingVisitor {
214215
cx,
215216
slice_lint_info,
@@ -223,7 +224,7 @@ fn filter_lintable_slices<'tcx>(
223224

224225
struct SliceIndexLintingVisitor<'a, 'tcx> {
225226
cx: &'a LateContext<'tcx>,
226-
slice_lint_info: FxIndexMap<hir::HirId, SliceLintInformation>,
227+
slice_lint_info: FxIndexMap<HirId, SliceLintInformation>,
227228
max_suggested_slice: u64,
228229
}
229230

‎src/tools/clippy/clippy_lints/src/operators/assign_op_pattern.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use clippy_utils::{binop_traits, eq_expr_value, trait_ref_of_method};
66
use core::ops::ControlFlow;
77
use rustc_errors::Applicability;
88
use rustc_hir as hir;
9+
use rustc_hir::{HirId, HirIdSet};
910
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1011
use rustc_lint::LateContext;
1112
use rustc_middle::mir::FakeReadCause;
@@ -98,10 +99,10 @@ pub(super) fn check<'tcx>(
9899
}
99100
}
100101

101-
fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet {
102-
struct S(hir::HirIdSet);
102+
fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
103+
struct S(HirIdSet);
103104
impl Delegate<'_> for S {
104-
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: hir::HirId, kind: BorrowKind) {
105+
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
105106
if matches!(kind, BorrowKind::ImmBorrow | BorrowKind::UniqueImmBorrow) {
106107
self.0.insert(match place.place.base {
107108
PlaceBase::Local(id) => id,
@@ -111,13 +112,13 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
111112
}
112113
}
113114

114-
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
115-
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
116-
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: hir::HirId) {}
117-
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
115+
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
116+
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
117+
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: HirId) {}
118+
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
118119
}
119120

120-
let mut s = S(hir::HirIdSet::default());
121+
let mut s = S(HirIdSet::default());
121122
let infcx = cx.tcx.infer_ctxt().build();
122123
let mut v = ExprUseVisitor::new(
123124
&mut s,
@@ -130,10 +131,10 @@ fn imm_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
130131
s.0
131132
}
132133

133-
fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet {
134-
struct S(hir::HirIdSet);
134+
fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> HirIdSet {
135+
struct S(HirIdSet);
135136
impl Delegate<'_> for S {
136-
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: hir::HirId, kind: BorrowKind) {
137+
fn borrow(&mut self, place: &PlaceWithHirId<'_>, _: HirId, kind: BorrowKind) {
137138
if matches!(kind, BorrowKind::MutBorrow) {
138139
self.0.insert(match place.place.base {
139140
PlaceBase::Local(id) => id,
@@ -143,13 +144,13 @@ fn mut_borrows_in_expr(cx: &LateContext<'_>, e: &hir::Expr<'_>) -> hir::HirIdSet
143144
}
144145
}
145146

146-
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
147-
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
148-
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: hir::HirId) {}
149-
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: hir::HirId) {}
147+
fn consume(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
148+
fn mutate(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
149+
fn fake_read(&mut self, _: &PlaceWithHirId<'_>, _: FakeReadCause, _: HirId) {}
150+
fn copy(&mut self, _: &PlaceWithHirId<'_>, _: HirId) {}
150151
}
151152

152-
let mut s = S(hir::HirIdSet::default());
153+
let mut s = S(HirIdSet::default());
153154
let infcx = cx.tcx.infer_ctxt().build();
154155
let mut v = ExprUseVisitor::new(
155156
&mut s,

‎src/tools/clippy/clippy_lints/src/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use clippy_utils::{get_expr_use_or_unification_node, is_lint_allowed, path_def_i
88
use hir::LifetimeName;
99
use rustc_errors::{Applicability, MultiSpan};
1010
use rustc_hir::def_id::DefId;
11-
use rustc_hir::hir_id::HirIdMap;
11+
use rustc_hir::hir_id::{HirId, HirIdMap};
1212
use rustc_hir::intravisit::{walk_expr, Visitor};
1313
use rustc_hir::{
1414
self as hir, AnonConst, BinOpKind, BindingAnnotation, Body, Expr, ExprKind, FnRetTy, FnSig, GenericArg,
@@ -324,7 +324,7 @@ struct PtrArgReplacement {
324324

325325
struct PtrArg<'tcx> {
326326
idx: usize,
327-
emission_id: hir::HirId,
327+
emission_id: HirId,
328328
span: Span,
329329
ty_did: DefId,
330330
ty_name: Symbol,

‎src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
55
use rustc_errors::Applicability;
66
use rustc_hir::def::{DefKind, Res};
77
use rustc_hir::intravisit::{walk_expr, Visitor};
8-
use rustc_hir::{self as hir};
8+
use rustc_hir::{self as hir, HirId};
99
use rustc_lint::{LateContext, LateLintPass, LintContext};
1010
use rustc_middle::ty::{GenericArgKind, Ty, TypeAndMut};
1111
use rustc_session::impl_lint_pass;
@@ -55,7 +55,7 @@ impl_lint_pass!(SignificantDropTightening<'_> => [SIGNIFICANT_DROP_TIGHTENING]);
5555

5656
#[derive(Default)]
5757
pub struct SignificantDropTightening<'tcx> {
58-
apas: FxIndexMap<hir::HirId, AuxParamsAttr>,
58+
apas: FxIndexMap<HirId, AuxParamsAttr>,
5959
/// Auxiliary structure used to avoid having to verify the same type multiple times.
6060
seen_types: FxHashSet<Ty<'tcx>>,
6161
type_cache: FxHashMap<Ty<'tcx>, bool>,
@@ -359,20 +359,20 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> Visitor<'tcx> for StmtsChecker<'ap, 'lc, 'o
359359
/// Auxiliary parameters used on each block check of an item
360360
struct AuxParams<'others, 'stmt, 'tcx> {
361361
//// See [AuxParamsAttr].
362-
apas: &'others mut FxIndexMap<hir::HirId, AuxParamsAttr>,
362+
apas: &'others mut FxIndexMap<HirId, AuxParamsAttr>,
363363
/// The current block identifier that is being visited.
364-
curr_block_hir_id: hir::HirId,
364+
curr_block_hir_id: HirId,
365365
/// The current block span that is being visited.
366366
curr_block_span: Span,
367367
/// The current statement that is being visited.
368368
curr_stmt: Cow<'stmt, hir::Stmt<'tcx>>,
369369
}
370370

371371
impl<'others, 'stmt, 'tcx> AuxParams<'others, 'stmt, 'tcx> {
372-
fn new(apas: &'others mut FxIndexMap<hir::HirId, AuxParamsAttr>, curr_stmt: &'stmt hir::Stmt<'tcx>) -> Self {
372+
fn new(apas: &'others mut FxIndexMap<HirId, AuxParamsAttr>, curr_stmt: &'stmt hir::Stmt<'tcx>) -> Self {
373373
Self {
374374
apas,
375-
curr_block_hir_id: hir::HirId::INVALID,
375+
curr_block_hir_id: HirId::INVALID,
376376
curr_block_span: DUMMY_SP,
377377
curr_stmt: Cow::Borrowed(curr_stmt),
378378
}
@@ -389,7 +389,7 @@ struct AuxParamsAttr {
389389
has_expensive_expr_after_last_attr: bool,
390390

391391
/// The identifier of the block that involves the first `#[has_significant_drop]`.
392-
first_block_hir_id: hir::HirId,
392+
first_block_hir_id: HirId,
393393
/// The span of the block that involves the first `#[has_significant_drop]`.
394394
first_block_span: Span,
395395
/// The binding or variable that references the initial construction of the type marked with
@@ -414,7 +414,7 @@ impl Default for AuxParamsAttr {
414414
Self {
415415
counter: 0,
416416
has_expensive_expr_after_last_attr: false,
417-
first_block_hir_id: hir::HirId::INVALID,
417+
first_block_hir_id: HirId::INVALID,
418418
first_bind_ident: Ident::empty(),
419419
first_block_span: DUMMY_SP,
420420
first_method_span: DUMMY_SP,
@@ -428,7 +428,7 @@ impl Default for AuxParamsAttr {
428428

429429
fn dummy_stmt_expr<'any>(expr: &'any hir::Expr<'any>) -> hir::Stmt<'any> {
430430
hir::Stmt {
431-
hir_id: hir::HirId::INVALID,
431+
hir_id: HirId::INVALID,
432432
kind: hir::StmtKind::Expr(expr),
433433
span: DUMMY_SP,
434434
}

‎src/tools/clippy/clippy_utils/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ pub fn get_parent_expr<'tcx>(cx: &LateContext<'tcx>, e: &Expr<'_>) -> Option<&'t
13111311

13121312
/// This retrieves the parent for the given `HirId` if it's an expression. This is useful for
13131313
/// constraint lints
1314-
pub fn get_parent_expr_for_hir<'tcx>(cx: &LateContext<'tcx>, hir_id: hir::HirId) -> Option<&'tcx Expr<'tcx>> {
1314+
pub fn get_parent_expr_for_hir<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> {
13151315
match cx.tcx.parent_hir_node(hir_id) {
13161316
Node::Expr(parent) => Some(parent),
13171317
_ => None,
@@ -2487,7 +2487,7 @@ fn with_test_item_names(tcx: TyCtxt<'_>, module: LocalModDefId, f: impl Fn(&[Sym
24872487
/// Checks if the function containing the given `HirId` is a `#[test]` function
24882488
///
24892489
/// Note: Add `//@compile-flags: --test` to UI tests with a `#[test]` function
2490-
pub fn is_in_test_function(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
2490+
pub fn is_in_test_function(tcx: TyCtxt<'_>, id: HirId) -> bool {
24912491
with_test_item_names(tcx, tcx.parent_module(id), |names| {
24922492
tcx.hir()
24932493
.parent_iter(id)
@@ -2510,7 +2510,7 @@ pub fn is_in_test_function(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
25102510
///
25112511
/// This only checks directly applied attributes, to see if a node is inside a `#[cfg(test)]` parent
25122512
/// use [`is_in_cfg_test`]
2513-
pub fn is_cfg_test(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
2513+
pub fn is_cfg_test(tcx: TyCtxt<'_>, id: HirId) -> bool {
25142514
tcx.hir().attrs(id).iter().any(|attr| {
25152515
if attr.has_name(sym::cfg)
25162516
&& let Some(items) = attr.meta_item_list()
@@ -2525,7 +2525,7 @@ pub fn is_cfg_test(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
25252525
}
25262526

25272527
/// Checks if any parent node of `HirId` has `#[cfg(test)]` attribute applied
2528-
pub fn is_in_cfg_test(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
2528+
pub fn is_in_cfg_test(tcx: TyCtxt<'_>, id: HirId) -> bool {
25292529
tcx.hir()
25302530
.parent_id_iter(id)
25312531
.any(|parent_id| is_cfg_test(tcx, parent_id))

‎src/tools/clippy/clippy_utils/src/usage.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ impl<'tcx> Delegate<'tcx> for MutVarsDelegate {
8787
}
8888

8989
pub struct ParamBindingIdCollector {
90-
pub binding_hir_ids: Vec<hir::HirId>,
90+
pub binding_hir_ids: Vec<HirId>,
9191
}
9292
impl<'tcx> ParamBindingIdCollector {
93-
fn collect_binding_hir_ids(body: &'tcx hir::Body<'tcx>) -> Vec<hir::HirId> {
94-
let mut hir_ids: Vec<hir::HirId> = Vec::new();
93+
fn collect_binding_hir_ids(body: &'tcx hir::Body<'tcx>) -> Vec<HirId> {
94+
let mut hir_ids: Vec<HirId> = Vec::new();
9595
for param in body.params {
9696
let mut finder = ParamBindingIdCollector {
9797
binding_hir_ids: Vec::new(),
@@ -115,7 +115,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for ParamBindingIdCollector {
115115

116116
pub struct BindingUsageFinder<'a, 'tcx> {
117117
cx: &'a LateContext<'tcx>,
118-
binding_ids: Vec<hir::HirId>,
118+
binding_ids: Vec<HirId>,
119119
usage_found: bool,
120120
}
121121
impl<'a, 'tcx> BindingUsageFinder<'a, 'tcx> {
@@ -138,7 +138,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for BindingUsageFinder<'a, 'tcx> {
138138
}
139139
}
140140

141-
fn visit_path(&mut self, path: &hir::Path<'tcx>, _: hir::HirId) {
141+
fn visit_path(&mut self, path: &hir::Path<'tcx>, _: HirId) {
142142
if let Res::Local(id) = path.res {
143143
if self.binding_ids.contains(&id) {
144144
self.usage_found = true;

0 commit comments

Comments
 (0)
Please sign in to comment.