diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-03-30 00:17:41 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-04-10 13:36:06 +0200 |
| commit | 69d818333755d4b836a28a4498f2caad71c2d014 (patch) | |
| tree | 14e247f2edb8bb6c657e18d5d20b92610a360c0f /compiler/rustc_resolve | |
| parent | db03a2deb090d5c24f15ef30cf4e5ccb13690b9d (diff) | |
| download | rust-69d818333755d4b836a28a4498f2caad71c2d014.tar.gz rust-69d818333755d4b836a28a4498f2caad71c2d014.zip | |
Store LocalDefId in is_late_bound_map.
This allows to avoid looking at HIR from borrowck.
Diffstat (limited to 'compiler/rustc_resolve')
| -rw-r--r-- | compiler/rustc_resolve/src/late/lifetimes.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index 1460b5efbb0..2bf01146fae 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -427,7 +427,7 @@ fn resolve_lifetimes_trait_definition( tcx: TyCtxt<'_>, local_def_id: LocalDefId, ) -> ResolveLifetimes { - convert_named_region_map(do_resolve(tcx, local_def_id, true, false)) + convert_named_region_map(tcx, do_resolve(tcx, local_def_id, true, false)) } /// Computes the `ResolveLifetimes` map that contains data for an entire `Item`. @@ -435,7 +435,7 @@ fn resolve_lifetimes_trait_definition( /// `named_region_map`, `is_late_bound_map`, etc. #[tracing::instrument(level = "debug", skip(tcx))] fn resolve_lifetimes(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> ResolveLifetimes { - convert_named_region_map(do_resolve(tcx, local_def_id, false, false)) + convert_named_region_map(tcx, do_resolve(tcx, local_def_id, false, false)) } fn do_resolve( @@ -468,7 +468,7 @@ fn do_resolve( named_region_map } -fn convert_named_region_map(named_region_map: NamedRegionMap) -> ResolveLifetimes { +fn convert_named_region_map(tcx: TyCtxt<'_>, named_region_map: NamedRegionMap) -> ResolveLifetimes { let mut rl = ResolveLifetimes::default(); for (hir_id, v) in named_region_map.defs { @@ -477,7 +477,8 @@ fn convert_named_region_map(named_region_map: NamedRegionMap) -> ResolveLifetime } for hir_id in named_region_map.late_bound { let map = rl.late_bound.entry(hir_id.owner).or_default(); - map.insert(hir_id.local_id); + let def_id = tcx.hir().local_def_id(hir_id); + map.insert(def_id); } for (hir_id, v) in named_region_map.late_bound_vars { let map = rl.late_bound_vars.entry(hir_id.owner).or_default(); @@ -537,7 +538,7 @@ fn item_for(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> LocalDefId { fn is_late_bound_map<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, -) -> Option<(LocalDefId, &'tcx FxHashSet<ItemLocalId>)> { +) -> Option<(LocalDefId, &'tcx FxHashSet<LocalDefId>)> { match tcx.def_kind(def_id) { DefKind::AnonConst | DefKind::InlineConst => { let mut def_id = tcx @@ -774,8 +775,10 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { }); } for (&owner, late_bound) in resolved_lifetimes.late_bound.iter() { - late_bound.iter().for_each(|&local_id| { - self.map.late_bound.insert(hir::HirId { owner, local_id }); + late_bound.iter().for_each(|&id| { + let hir_id = self.tcx.local_def_id_to_hir_id(id); + debug_assert_eq!(owner, hir_id.owner); + self.map.late_bound.insert(hir_id); }); } for (&owner, late_bound_vars) in |
