1
Fork 0

resolve late lifetimes by item

This reverts commit 22ae20733515d710c1134600bc1e29cdd76f6b9b.
This commit is contained in:
Jack Huey 2021-02-27 21:31:56 -05:00
parent f5fe425c92
commit 19ecfcd0e2
21 changed files with 513 additions and 520 deletions

View file

@ -78,9 +78,4 @@ pub struct ResolveLifetimes {
/// be late-bound if (a) it does NOT appear in a where-clause and
/// (b) it DOES appear in the arguments.
pub late_bound: FxHashMap<LocalDefId, FxHashSet<ItemLocalId>>,
/// For each type and trait definition, maps type parameters
/// to the trait object lifetime defaults computed from them.
pub object_lifetime_defaults:
FxHashMap<LocalDefId, FxHashMap<ItemLocalId, Vec<ObjectLifetimeDefault>>>,
}

View file

@ -1253,7 +1253,12 @@ rustc_queries! {
}
/// Lifetime resolution. See `middle::resolve_lifetimes`.
query resolve_lifetimes(_: CrateNum) -> ResolveLifetimes {
query resolve_lifetimes_definition(_: LocalDefId) -> ResolveLifetimes {
storage(ArenaCacheSelector<'tcx>)
desc { "resolving lifetimes in a definition" }
}
/// Lifetime resolution. See `middle::resolve_lifetimes`.
query resolve_lifetimes(_: LocalDefId) -> ResolveLifetimes {
storage(ArenaCacheSelector<'tcx>)
desc { "resolving lifetimes" }
}
@ -1266,8 +1271,8 @@ rustc_queries! {
desc { "testing if a region is late bound" }
}
query object_lifetime_defaults_map(_: LocalDefId)
-> Option<&'tcx FxHashMap<ItemLocalId, Vec<ObjectLifetimeDefault>>> {
desc { "looking up lifetime defaults for a region" }
-> Option<Vec<ObjectLifetimeDefault>> {
desc { "looking up lifetime defaults for a region on an item" }
}
query visibility(def_id: DefId) -> ty::Visibility {

View file

@ -2641,6 +2641,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
pub fn named_region(self, id: HirId) -> Option<resolve_lifetime::Region> {
debug!(?id, "named_region");
self.named_region_map(id.owner).and_then(|map| map.get(&id.local_id).cloned())
}
@ -2649,9 +2650,8 @@ impl<'tcx> TyCtxt<'tcx> {
.map_or(false, |(owner, set)| owner == id.owner && set.contains(&id.local_id))
}
pub fn object_lifetime_defaults(self, id: HirId) -> Option<&'tcx [ObjectLifetimeDefault]> {
pub fn object_lifetime_defaults(self, id: HirId) -> Option<Vec<ObjectLifetimeDefault>> {
self.object_lifetime_defaults_map(id.owner)
.and_then(|map| map.get(&id.local_id).map(|v| &**v))
}
}