Remove further usage of &hir::Map
This commit is contained in:
parent
89ac81a6e6
commit
7eff2feb62
@ -763,7 +763,7 @@ fn suggest_similar_mut_method_for_for_loop(&self, err: &mut DiagnosticBuilder<'_
|
||||
HirId, ImplItem, ImplItemKind, Item, ItemKind,
|
||||
};
|
||||
|
||||
fn maybe_body_id_of_fn(hir_map: &Map<'_>, id: HirId) -> Option<BodyId> {
|
||||
fn maybe_body_id_of_fn(hir_map: Map<'_>, id: HirId) -> Option<BodyId> {
|
||||
match hir_map.find(id) {
|
||||
Some(Node::Item(Item { kind: ItemKind::Fn(_, _, body_id), .. }))
|
||||
| Some(Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(_, body_id), .. })) => {
|
||||
@ -774,7 +774,7 @@ fn maybe_body_id_of_fn(hir_map: &Map<'_>, id: HirId) -> Option<BodyId> {
|
||||
}
|
||||
let hir_map = self.infcx.tcx.hir();
|
||||
let mir_body_hir_id = self.mir_hir_id();
|
||||
if let Some(fn_body_id) = maybe_body_id_of_fn(&hir_map, mir_body_hir_id) {
|
||||
if let Some(fn_body_id) = maybe_body_id_of_fn(hir_map, mir_body_hir_id) {
|
||||
if let Block(
|
||||
hir::Block {
|
||||
expr:
|
||||
|
@ -2226,7 +2226,7 @@ pub fn construct_generic_bound_failure(
|
||||
bound_kind: GenericKind<'tcx>,
|
||||
sub: Region<'tcx>,
|
||||
) -> DiagnosticBuilder<'a> {
|
||||
let hir = &self.tcx.hir();
|
||||
let hir = self.tcx.hir();
|
||||
// Attempt to obtain the span of the parameter so we can
|
||||
// suggest adding an explicit lifetime bound to it.
|
||||
let generics = self
|
||||
|
@ -41,9 +41,9 @@ pub enum LifetimeUseSet<'tcx> {
|
||||
}
|
||||
|
||||
trait RegionExt {
|
||||
fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region);
|
||||
fn early(hir_map: Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region);
|
||||
|
||||
fn late(index: u32, hir_map: &Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region);
|
||||
fn late(index: u32, hir_map: Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region);
|
||||
|
||||
fn late_anon(named_late_bound_vars: u32, index: &Cell<u32>) -> Region;
|
||||
|
||||
@ -59,7 +59,7 @@ fn subst<'a, L>(self, params: L, map: &NamedRegionMap) -> Option<Region>
|
||||
}
|
||||
|
||||
impl RegionExt for Region {
|
||||
fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region) {
|
||||
fn early(hir_map: Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region) {
|
||||
let i = *index;
|
||||
*index += 1;
|
||||
let def_id = hir_map.local_def_id(param.hir_id);
|
||||
@ -68,7 +68,7 @@ fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (Param
|
||||
(param.name.normalize_to_macros_2_0(), Region::EarlyBound(i, def_id.to_def_id(), origin))
|
||||
}
|
||||
|
||||
fn late(idx: u32, hir_map: &Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region) {
|
||||
fn late(idx: u32, hir_map: Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region) {
|
||||
let depth = ty::INNERMOST;
|
||||
let def_id = hir_map.local_def_id(param.hir_id);
|
||||
let origin = LifetimeDefOrigin::from_param(param);
|
||||
@ -817,7 +817,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||
.iter()
|
||||
.filter_map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
Some(Region::early(&self.tcx.hir(), &mut index, param))
|
||||
Some(Region::early(self.tcx.hir(), &mut index, param))
|
||||
}
|
||||
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
|
||||
non_lifetime_count += 1;
|
||||
@ -888,7 +888,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
|
||||
.filter(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))
|
||||
.enumerate()
|
||||
.map(|(late_bound_idx, param)| {
|
||||
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
|
||||
let pair = Region::late(late_bound_idx as u32, self.tcx.hir(), param);
|
||||
let r = late_region_as_bound_region(self.tcx, &pair.1);
|
||||
(pair, r)
|
||||
})
|
||||
@ -1045,7 +1045,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
|
||||
for param in generics.params {
|
||||
match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
let (name, reg) = Region::early(&self.tcx.hir(), &mut index, ¶m);
|
||||
let (name, reg) = Region::early(self.tcx.hir(), &mut index, ¶m);
|
||||
let Region::EarlyBound(_, def_id, _) = reg else {
|
||||
bug!();
|
||||
};
|
||||
@ -1145,7 +1145,7 @@ fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
|
||||
.iter()
|
||||
.filter_map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
Some(Region::early(&self.tcx.hir(), &mut index, param))
|
||||
Some(Region::early(self.tcx.hir(), &mut index, param))
|
||||
}
|
||||
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
|
||||
non_lifetime_count += 1;
|
||||
@ -1214,7 +1214,7 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
|
||||
.iter()
|
||||
.filter_map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
Some(Region::early(&self.tcx.hir(), &mut index, param))
|
||||
Some(Region::early(self.tcx.hir(), &mut index, param))
|
||||
}
|
||||
GenericParamKind::Const { .. } | GenericParamKind::Type { .. } => {
|
||||
non_lifetime_count += 1;
|
||||
@ -1368,7 +1368,7 @@ fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) {
|
||||
.enumerate()
|
||||
.map(|(late_bound_idx, param)| {
|
||||
let pair =
|
||||
Region::late(late_bound_idx as u32, &this.tcx.hir(), param);
|
||||
Region::late(late_bound_idx as u32, this.tcx.hir(), param);
|
||||
let r = late_region_as_bound_region(this.tcx, &pair.1);
|
||||
(pair, r)
|
||||
})
|
||||
@ -1463,11 +1463,8 @@ fn visit_poly_trait_ref(
|
||||
.filter(|param| matches!(param.kind, GenericParamKind::Lifetime { .. }))
|
||||
.enumerate()
|
||||
.map(|(late_bound_idx, param)| {
|
||||
let pair = Region::late(
|
||||
initial_bound_vars + late_bound_idx as u32,
|
||||
&self.tcx.hir(),
|
||||
param,
|
||||
);
|
||||
let pair =
|
||||
Region::late(initial_bound_vars + late_bound_idx as u32, self.tcx.hir(), param);
|
||||
let r = late_region_as_bound_region(self.tcx, &pair.1);
|
||||
lifetimes.insert(pair.0, pair.1);
|
||||
r
|
||||
@ -2200,9 +2197,9 @@ fn visit_early_late<F>(
|
||||
if self.map.late_bound.contains(¶m.hir_id) {
|
||||
let late_bound_idx = named_late_bound_vars;
|
||||
named_late_bound_vars += 1;
|
||||
Some(Region::late(late_bound_idx, &self.tcx.hir(), param))
|
||||
Some(Region::late(late_bound_idx, self.tcx.hir(), param))
|
||||
} else {
|
||||
Some(Region::early(&self.tcx.hir(), &mut next_early_index, param))
|
||||
Some(Region::early(self.tcx.hir(), &mut next_early_index, param))
|
||||
}
|
||||
}
|
||||
GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => {
|
||||
@ -2222,7 +2219,7 @@ fn visit_early_late<F>(
|
||||
})
|
||||
.enumerate()
|
||||
.map(|(late_bound_idx, param)| {
|
||||
let pair = Region::late(late_bound_idx as u32, &self.tcx.hir(), param);
|
||||
let pair = Region::late(late_bound_idx as u32, self.tcx.hir(), param);
|
||||
late_region_as_bound_region(self.tcx, &pair.1)
|
||||
})
|
||||
.collect();
|
||||
|
@ -262,7 +262,7 @@ fn process_method(
|
||||
) {
|
||||
debug!("process_method: {:?}:{}", def_id, ident);
|
||||
|
||||
let map = &self.tcx.hir();
|
||||
let map = self.tcx.hir();
|
||||
let hir_id = map.local_def_id_to_hir_id(def_id);
|
||||
self.nest_typeck_results(def_id, |v| {
|
||||
if let Some(mut method_data) = v.save_ctxt.get_method_data(hir_id, ident, span) {
|
||||
@ -361,7 +361,7 @@ fn process_fn(
|
||||
ty_params: &'tcx hir::Generics<'tcx>,
|
||||
body: hir::BodyId,
|
||||
) {
|
||||
let map = &self.tcx.hir();
|
||||
let map = self.tcx.hir();
|
||||
self.nest_typeck_results(item.def_id, |v| {
|
||||
let body = map.body(body);
|
||||
if let Some(fn_data) = v.save_ctxt.get_item_data(item) {
|
||||
@ -626,7 +626,7 @@ fn process_impl(&mut self, item: &'tcx hir::Item<'tcx>, impl_: &'tcx hir::Impl<'
|
||||
}
|
||||
}
|
||||
|
||||
let map = &self.tcx.hir();
|
||||
let map = self.tcx.hir();
|
||||
self.nest_typeck_results(item.def_id, |v| {
|
||||
v.visit_ty(&impl_.self_ty);
|
||||
if let Some(trait_ref) = &impl_.of_trait {
|
||||
@ -716,7 +716,7 @@ fn process_trait(
|
||||
// walk generics and methods
|
||||
self.process_generic_params(generics, &qualname, item.hir_id());
|
||||
for method in methods {
|
||||
let map = &self.tcx.hir();
|
||||
let map = self.tcx.hir();
|
||||
self.process_trait_item(map.trait_item(method.id), item.def_id.to_def_id())
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ fn impl_similar_to(
|
||||
/// Used to set on_unimplemented's `ItemContext`
|
||||
/// to be the enclosing (async) block/function/closure
|
||||
fn describe_enclosure(&self, hir_id: hir::HirId) -> Option<&'static str> {
|
||||
let hir = &self.tcx.hir();
|
||||
let hir = self.tcx.hir();
|
||||
let node = hir.find(hir_id)?;
|
||||
match &node {
|
||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. }) => {
|
||||
|
@ -1663,7 +1663,7 @@ fn suggest_traits_to_import(
|
||||
let table_owner = table.borrow().hir_owner;
|
||||
let generics = self.tcx.generics_of(table_owner.to_def_id());
|
||||
let type_param = generics.type_param(param, self.tcx);
|
||||
let hir = &self.tcx.hir();
|
||||
let hir = self.tcx.hir();
|
||||
if let Some(def_id) = type_param.def_id.as_local() {
|
||||
let id = hir.local_def_id_to_hir_id(def_id);
|
||||
// Get the `hir::Param` to verify whether it already has any bounds.
|
||||
|
Loading…
Reference in New Issue
Block a user