Skip to content

Commit 7eff2fe

Browse files
committed
Remove further usage of &hir::Map
1 parent 89ac81a commit 7eff2fe

File tree

6 files changed

+24
-27
lines changed

6 files changed

+24
-27
lines changed

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
763763
HirId, ImplItem, ImplItemKind, Item, ItemKind,
764764
};
765765

766-
fn maybe_body_id_of_fn(hir_map: &Map<'_>, id: HirId) -> Option<BodyId> {
766+
fn maybe_body_id_of_fn(hir_map: Map<'_>, id: HirId) -> Option<BodyId> {
767767
match hir_map.find(id) {
768768
Some(Node::Item(Item { kind: ItemKind::Fn(_, _, body_id), .. }))
769769
| Some(Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(_, body_id), .. })) => {
@@ -774,7 +774,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
774774
}
775775
let hir_map = self.infcx.tcx.hir();
776776
let mir_body_hir_id = self.mir_hir_id();
777-
if let Some(fn_body_id) = maybe_body_id_of_fn(&hir_map, mir_body_hir_id) {
777+
if let Some(fn_body_id) = maybe_body_id_of_fn(hir_map, mir_body_hir_id) {
778778
if let Block(
779779
hir::Block {
780780
expr:

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
22262226
bound_kind: GenericKind<'tcx>,
22272227
sub: Region<'tcx>,
22282228
) -> DiagnosticBuilder<'a> {
2229-
let hir = &self.tcx.hir();
2229+
let hir = self.tcx.hir();
22302230
// Attempt to obtain the span of the parameter so we can
22312231
// suggest adding an explicit lifetime bound to it.
22322232
let generics = self

compiler/rustc_resolve/src/late/lifetimes.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ pub enum LifetimeUseSet<'tcx> {
4141
}
4242

4343
trait RegionExt {
44-
fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region);
44+
fn early(hir_map: Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region);
4545

46-
fn late(index: u32, hir_map: &Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region);
46+
fn late(index: u32, hir_map: Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region);
4747

4848
fn late_anon(named_late_bound_vars: u32, index: &Cell<u32>) -> Region;
4949

@@ -59,7 +59,7 @@ trait RegionExt {
5959
}
6060

6161
impl RegionExt for Region {
62-
fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region) {
62+
fn early(hir_map: Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region) {
6363
let i = *index;
6464
*index += 1;
6565
let def_id = hir_map.local_def_id(param.hir_id);
@@ -68,7 +68,7 @@ impl RegionExt for Region {
6868
(param.name.normalize_to_macros_2_0(), Region::EarlyBound(i, def_id.to_def_id(), origin))
6969
}
7070

71-
fn late(idx: u32, hir_map: &Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region) {
71+
fn late(idx: u32, hir_map: Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region) {
7272
let depth = ty::INNERMOST;
7373
let def_id = hir_map.local_def_id(param.hir_id);
7474
let origin = LifetimeDefOrigin::from_param(param);
@@ -817,7 +817,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
817817
.iter()
818818
.filter_map(|param| match param.kind {
819819
GenericParamKind::Lifetime { .. } => {
820-
Some(Region::early(&self.tcx.hir(), &mut index, param))
820+
Some(Region::early(self.tcx.hir(), &mut index, param))
821821
}
822822
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
823823
non_lifetime_count += 1;
@@ -888,7 +888,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
888888
.filter(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))
889889
.enumerate()
890890
.map(|(late_bound_idx, param)| {
891-
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
891+
let pair = Region::late(late_bound_idx as u32, self.tcx.hir(), param);
892892
let r = late_region_as_bound_region(self.tcx, &pair.1);
893893
(pair, r)
894894
})
@@ -1045,7 +1045,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
10451045
for param in generics.params {
10461046
match param.kind {
10471047
GenericParamKind::Lifetime { .. } => {
1048-
let (name, reg) = Region::early(&self.tcx.hir(), &mut index, &param);
1048+
let (name, reg) = Region::early(self.tcx.hir(), &mut index, &param);
10491049
let Region::EarlyBound(_, def_id, _) = reg else {
10501050
bug!();
10511051
};
@@ -1145,7 +1145,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
11451145
.iter()
11461146
.filter_map(|param| match param.kind {
11471147
GenericParamKind::Lifetime { .. } => {
1148-
Some(Region::early(&self.tcx.hir(), &mut index, param))
1148+
Some(Region::early(self.tcx.hir(), &mut index, param))
11491149
}
11501150
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
11511151
non_lifetime_count += 1;
@@ -1214,7 +1214,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
12141214
.iter()
12151215
.filter_map(|param| match param.kind {
12161216
GenericParamKind::Lifetime { .. } => {
1217-
Some(Region::early(&self.tcx.hir(), &mut index, param))
1217+
Some(Region::early(self.tcx.hir(), &mut index, param))
12181218
}
12191219
GenericParamKind::Const { .. } | GenericParamKind::Type { .. } => {
12201220
non_lifetime_count += 1;
@@ -1368,7 +1368,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
13681368
.enumerate()
13691369
.map(|(late_bound_idx, param)| {
13701370
let pair =
1371-
Region::late(late_bound_idx as u32, &this.tcx.hir(), param);
1371+
Region::late(late_bound_idx as u32, this.tcx.hir(), param);
13721372
let r = late_region_as_bound_region(this.tcx, &pair.1);
13731373
(pair, r)
13741374
})
@@ -1463,11 +1463,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
14631463
.filter(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))
14641464
.enumerate()
14651465
.map(|(late_bound_idx, param)| {
1466-
let pair = Region::late(
1467-
initial_bound_vars + late_bound_idx as u32,
1468-
&self.tcx.hir(),
1469-
param,
1470-
);
1466+
let pair =
1467+
Region::late(initial_bound_vars + late_bound_idx as u32, self.tcx.hir(), param);
14711468
let r = late_region_as_bound_region(self.tcx, &pair.1);
14721469
lifetimes.insert(pair.0, pair.1);
14731470
r
@@ -2200,9 +2197,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
22002197
if self.map.late_bound.contains(&param.hir_id) {
22012198
let late_bound_idx = named_late_bound_vars;
22022199
named_late_bound_vars += 1;
2203-
Some(Region::late(late_bound_idx, &self.tcx.hir(), param))
2200+
Some(Region::late(late_bound_idx, self.tcx.hir(), param))
22042201
} else {
2205-
Some(Region::early(&self.tcx.hir(), &mut next_early_index, param))
2202+
Some(Region::early(self.tcx.hir(), &mut next_early_index, param))
22062203
}
22072204
}
22082205
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
@@ -2222,7 +2219,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
22222219
})
22232220
.enumerate()
22242221
.map(|(late_bound_idx, param)| {
2225-
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
2222+
let pair = Region::late(late_bound_idx as u32, self.tcx.hir(), param);
22262223
late_region_as_bound_region(self.tcx, &pair.1)
22272224
})
22282225
.collect();

compiler/rustc_save_analysis/src/dump_visitor.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<'tcx> DumpVisitor<'tcx> {
262262
) {
263263
debug!("process_method: {:?}:{}", def_id, ident);
264264

265-
let map = &self.tcx.hir();
265+
let map = self.tcx.hir();
266266
let hir_id = map.local_def_id_to_hir_id(def_id);
267267
self.nest_typeck_results(def_id, |v| {
268268
if let Some(mut method_data) = v.save_ctxt.get_method_data(hir_id, ident, span) {
@@ -361,7 +361,7 @@ impl<'tcx> DumpVisitor<'tcx> {
361361
ty_params: &'tcx hir::Generics<'tcx>,
362362
body: hir::BodyId,
363363
) {
364-
let map = &self.tcx.hir();
364+
let map = self.tcx.hir();
365365
self.nest_typeck_results(item.def_id, |v| {
366366
let body = map.body(body);
367367
if let Some(fn_data) = v.save_ctxt.get_item_data(item) {
@@ -626,7 +626,7 @@ impl<'tcx> DumpVisitor<'tcx> {
626626
}
627627
}
628628

629-
let map = &self.tcx.hir();
629+
let map = self.tcx.hir();
630630
self.nest_typeck_results(item.def_id, |v| {
631631
v.visit_ty(&impl_.self_ty);
632632
if let Some(trait_ref) = &impl_.of_trait {
@@ -716,7 +716,7 @@ impl<'tcx> DumpVisitor<'tcx> {
716716
// walk generics and methods
717717
self.process_generic_params(generics, &qualname, item.hir_id());
718718
for method in methods {
719-
let map = &self.tcx.hir();
719+
let map = self.tcx.hir();
720720
self.process_trait_item(map.trait_item(method.id), item.def_id.to_def_id())
721721
}
722722
}

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
7777
/// Used to set on_unimplemented's `ItemContext`
7878
/// to be the enclosing (async) block/function/closure
7979
fn describe_enclosure(&self, hir_id: hir::HirId) -> Option<&'static str> {
80-
let hir = &self.tcx.hir();
80+
let hir = self.tcx.hir();
8181
let node = hir.find(hir_id)?;
8282
match &node {
8383
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. }) => {

compiler/rustc_typeck/src/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16631663
let table_owner = table.borrow().hir_owner;
16641664
let generics = self.tcx.generics_of(table_owner.to_def_id());
16651665
let type_param = generics.type_param(param, self.tcx);
1666-
let hir = &self.tcx.hir();
1666+
let hir = self.tcx.hir();
16671667
if let Some(def_id) = type_param.def_id.as_local() {
16681668
let id = hir.local_def_id_to_hir_id(def_id);
16691669
// Get the `hir::Param` to verify whether it already has any bounds.

0 commit comments

Comments
 (0)