Skip to content

Commit 9259289

Browse files
committed
Move queries initialization to rustc_ast_lowering
1 parent afd567c commit 9259289

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static ATTRS_ADDITIONS: &[AttrAdditionInfo] = &[
103103
},
104104
];
105105

106-
pub fn delegations_resolutions(
106+
pub(crate) fn delegations_resolutions(
107107
tcx: TyCtxt<'_>,
108108
_: (),
109109
) -> FxIndexMap<LocalDefId, Result<DefId, ErrorGuaranteed>> {

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ use rustc_hir::{
6060
use rustc_index::{Idx, IndexSlice, IndexVec};
6161
use rustc_macros::extension;
6262
use rustc_middle::hir::{self as mid_hir};
63+
use rustc_middle::queries::Providers;
6364
use rustc_middle::span_bug;
6465
use rustc_middle::ty::{DelegationInfo, PerOwnerResolverData, ResolverAstLowering, TyCtxt};
6566
use rustc_session::errors::add_feature_diagnostics;
@@ -81,7 +82,7 @@ macro_rules! arena_vec {
8182
mod asm;
8283
mod block;
8384
mod contract;
84-
pub mod delegation;
85+
mod delegation;
8586
mod errors;
8687
mod expr;
8788
mod format;
@@ -91,6 +92,12 @@ mod pat;
9192
mod path;
9293
pub mod stability;
9394

95+
pub fn provide(providers: &mut Providers) {
96+
providers.hir_crate = lower_to_hir;
97+
providers.lower_delayed_owner = lower_delayed_owner;
98+
providers.delegations_resolutions = delegation::delegations_resolutions;
99+
}
100+
94101
struct LoweringContext<'a, 'hir> {
95102
tcx: TyCtxt<'hir>,
96103
resolver: &'a ResolverAstLowering<'hir>,

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -877,10 +877,6 @@ pub fn write_interface<'tcx>(tcx: TyCtxt<'tcx>) {
877877
pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
878878
let providers = &mut Providers::default();
879879
providers.queries.analysis = analysis;
880-
providers.queries.hir_crate = rustc_ast_lowering::lower_to_hir;
881-
providers.queries.lower_delayed_owner = rustc_ast_lowering::lower_delayed_owner;
882-
providers.queries.delegations_resolutions =
883-
rustc_ast_lowering::delegation::delegations_resolutions;
884880
// `hir_delayed_owner` is fed during `lower_delayed_owner`, by default it returns phantom,
885881
// as if this query was not fed it means that `MaybeOwner` does not exist for provided LocalDefId.
886882
providers.queries.hir_delayed_owner = |_, _| MaybeOwner::Phantom;
@@ -889,6 +885,7 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
889885
providers.queries.resolutions = |tcx, ()| tcx.resolver_for_lowering_raw(()).1;
890886
providers.queries.early_lint_checks = early_lint_checks;
891887
providers.queries.env_var_os = env_var_os;
888+
rustc_ast_lowering::provide(&mut providers.queries);
892889
limits::provide(&mut providers.queries);
893890
proc_macro_decls::provide(&mut providers.queries);
894891
rustc_expand::provide(&mut providers.queries);

0 commit comments

Comments
 (0)