Skip to content

Commit 98764c0

Browse files
authored
Rollup merge of rust-lang#102859 - cjgillot:collect-lifetimes, r=oli-obk
Move lifetime resolution module to rustc_hir_analysis. Now that lifetime resolution has been removed from it, this file has nothing to do in `rustc_resolve`. It's purpose is to compute Debruijn indices for lifetimes, so let's put it in type collection.
2 parents b380518 + a474ec5 commit 98764c0

File tree

5 files changed

+5
-21
lines changed

5 files changed

+5
-21
lines changed

compiler/rustc_hir_analysis/src/collect.rs

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ use std::iter;
4646

4747
mod generics_of;
4848
mod item_bounds;
49+
mod lifetimes;
4950
mod predicates_of;
5051
mod type_of;
5152

@@ -57,6 +58,7 @@ fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
5758
}
5859

5960
pub fn provide(providers: &mut Providers) {
61+
lifetimes::provide(providers);
6062
*providers = Providers {
6163
opt_const_param_of: type_of::opt_const_param_of,
6264
type_of: type_of::type_of,

compiler/rustc_resolve/src/late/lifetimes.rs renamed to compiler/rustc_hir_analysis/src/collect/lifetimes.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ trait RegionExt {
3232
fn id(&self) -> Option<DefId>;
3333

3434
fn shifted(self, amount: u32) -> Region;
35-
36-
fn shifted_out_to_binder(self, binder: ty::DebruijnIndex) -> Region;
3735
}
3836

3937
impl RegionExt for Region {
@@ -69,15 +67,6 @@ impl RegionExt for Region {
6967
_ => self,
7068
}
7169
}
72-
73-
fn shifted_out_to_binder(self, binder: ty::DebruijnIndex) -> Region {
74-
match self {
75-
Region::LateBound(debruijn, index, id) => {
76-
Region::LateBound(debruijn.shifted_out_to_binder(binder), index, id)
77-
}
78-
_ => self,
79-
}
80-
}
8170
}
8271

8372
/// Maps the id of each lifetime reference to the lifetime decl
@@ -101,8 +90,8 @@ struct NamedRegionMap {
10190
late_bound_vars: HirIdMap<Vec<ty::BoundVariableKind>>,
10291
}
10392

104-
pub(crate) struct LifetimeContext<'a, 'tcx> {
105-
pub(crate) tcx: TyCtxt<'tcx>,
93+
struct LifetimeContext<'a, 'tcx> {
94+
tcx: TyCtxt<'tcx>,
10695
map: &'a mut NamedRegionMap,
10796
scope: ScopeRef<'a>,
10897

@@ -234,7 +223,7 @@ type ScopeRef<'a> = &'a Scope<'a>;
234223

235224
const ROOT_SCOPE: ScopeRef<'static> = &Scope::Root;
236225

237-
pub fn provide(providers: &mut ty::query::Providers) {
226+
pub(crate) fn provide(providers: &mut ty::query::Providers) {
238227
*providers = ty::query::Providers {
239228
resolve_lifetimes_trait_definition,
240229
resolve_lifetimes,

compiler/rustc_interface/src/passes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
739739
ty::provide(providers);
740740
traits::provide(providers);
741741
rustc_passes::provide(providers);
742-
rustc_resolve::provide(providers);
743742
rustc_traits::provide(providers);
744743
rustc_ty_utils::provide(providers);
745744
rustc_metadata::provide(providers);

compiler/rustc_resolve/src/late.rs

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use std::collections::{hash_map::Entry, BTreeSet};
3434
use std::mem::{replace, take};
3535

3636
mod diagnostics;
37-
pub(crate) mod lifetimes;
3837

3938
type Res = def::Res<NodeId>;
4039

compiler/rustc_resolve/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use rustc_metadata::creader::{CStore, CrateLoader};
4242
use rustc_middle::metadata::ModChild;
4343
use rustc_middle::middle::privacy::AccessLevels;
4444
use rustc_middle::span_bug;
45-
use rustc_middle::ty::query::Providers;
4645
use rustc_middle::ty::{self, DefIdTree, MainDefinition, RegisteredTools, ResolverOutputs};
4746
use rustc_query_system::ich::StableHashingContext;
4847
use rustc_session::cstore::{CrateStore, CrateStoreDyn, MetadataLoaderDyn};
@@ -2082,7 +2081,3 @@ impl Finalize {
20822081
Finalize { node_id, path_span, root_span, report_private: true }
20832082
}
20842083
}
2085-
2086-
pub fn provide(providers: &mut Providers) {
2087-
late::lifetimes::provide(providers);
2088-
}

0 commit comments

Comments
 (0)