Skip to content

Commit f835818

Browse files
committed
Avoid using feed_unit_query from within queries
1 parent c696d4c commit f835818

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> hir::Crate<'_> {
427427
tcx.ensure_with_value().early_lint_checks(());
428428
tcx.ensure_with_value().debugger_visualizers(LOCAL_CRATE);
429429
tcx.ensure_with_value().get_lang_items(());
430-
let (mut resolver, krate) = tcx.resolver_for_lowering(()).steal();
430+
let (mut resolver, krate) = tcx.resolver_for_lowering(()).0.steal();
431431

432432
let ast_index = index_crate(&resolver.node_id_to_def_id, &krate);
433433
let mut owners = IndexVec::from_fn_n(

compiler/rustc_driver_impl/src/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<'tcx> PrintExtra<'tcx> {
229229
{
230230
match self {
231231
PrintExtra::AfterParsing { krate, .. } => f(krate),
232-
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering(()).borrow().1),
232+
PrintExtra::NeedsAstMap { tcx } => f(&tcx.resolver_for_lowering(()).0.borrow().1),
233233
}
234234
}
235235

@@ -281,7 +281,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
281281
}
282282
AstTreeExpanded => {
283283
debug!("pretty-printing expanded AST");
284-
format!("{:#?}", ex.tcx().resolver_for_lowering(()).borrow().1)
284+
format!("{:#?}", ex.tcx().resolver_for_lowering(()).0.borrow().1)
285285
}
286286
Hir(s) => {
287287
debug!("pretty printing HIR {:?}", s);

compiler/rustc_interface/src/passes.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn configure_and_expand(
280280

281281
fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) {
282282
let sess = tcx.sess;
283-
let (resolver, krate) = &*tcx.resolver_for_lowering(()).borrow();
283+
let (resolver, krate) = &*tcx.resolver_for_lowering(()).0.borrow();
284284
let mut lint_buffer = resolver.lint_buffer.steal();
285285

286286
if sess.opts.unstable_opts.input_stats {
@@ -534,7 +534,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
534534
fn resolver_for_lowering<'tcx>(
535535
tcx: TyCtxt<'tcx>,
536536
(): (),
537-
) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
537+
) -> (&'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)>, &'tcx ty::ResolverGlobalCtxt) {
538538
let arenas = Resolver::arenas();
539539
let _ = tcx.registered_tools(()); // Uses `crate_for_resolver`.
540540
let (krate, pre_configured_attrs) = tcx.crate_for_resolver(()).steal();
@@ -549,9 +549,8 @@ fn resolver_for_lowering<'tcx>(
549549
ast_lowering: untracked_resolver_for_lowering,
550550
} = resolver.into_outputs();
551551

552-
let feed = tcx.feed_unit_query();
553-
feed.resolutions(tcx.arena.alloc(untracked_resolutions));
554-
tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate))))
552+
let resolutions = tcx.arena.alloc(untracked_resolutions);
553+
(tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate)))), resolutions)
555554
}
556555

557556
pub(crate) fn write_dep_info(tcx: TyCtxt<'_>) {
@@ -610,6 +609,7 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
610609
providers.resolver_for_lowering = resolver_for_lowering;
611610
providers.stripped_cfg_items =
612611
|tcx, _| tcx.arena.alloc_from_iter(tcx.resolutions(()).stripped_cfg_items.steal());
612+
providers.resolutions = |tcx, ()| tcx.resolver_for_lowering(()).1;
613613
providers.early_lint_checks = early_lint_checks;
614614
proc_macro_decls::provide(providers);
615615
rustc_const_eval::provide(providers);

compiler/rustc_middle/src/query/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,11 @@ rustc_queries! {
125125
}
126126

127127
query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {
128-
feedable
129128
no_hash
130129
desc { "getting the resolver outputs" }
131130
}
132131

133-
query resolver_for_lowering(_: ()) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
132+
query resolver_for_lowering(_: ()) -> (&'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)>, &'tcx ty::ResolverGlobalCtxt) {
134133
eval_always
135134
no_hash
136135
desc { "getting the resolver for lowering" }

compiler/rustc_middle/src/ty/context.rs

+1
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ impl<'tcx> TyCtxt<'tcx> {
553553
/// Can only be fed before queries are run, and is thus exempt from any
554554
/// incremental issues. Do not use except for the initial query feeding.
555555
pub fn feed_unit_query(self) -> TyCtxtFeed<'tcx, ()> {
556+
self.dep_graph.assert_ignored();
556557
TyCtxtFeed { tcx: self, key: () }
557558
}
558559

compiler/rustc_passes/src/debugger_visualizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'ast> rustc_ast::visit::Visitor<'ast> for DebuggerVisualizerCollector<'_> {
8787

8888
/// Traverses and collects the debugger visualizers for a specific crate.
8989
fn debugger_visualizers(tcx: TyCtxt<'_>, _: LocalCrate) -> Vec<DebuggerVisualizerFile> {
90-
let resolver_and_krate = tcx.resolver_for_lowering(()).borrow();
90+
let resolver_and_krate = tcx.resolver_for_lowering(()).0.borrow();
9191
let krate = &*resolver_and_krate.1;
9292

9393
let mut visitor = DebuggerVisualizerCollector { sess: tcx.sess, visualizers: Vec::new() };

compiler/rustc_passes/src/lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl<'ast, 'tcx> LanguageItemCollector<'ast, 'tcx> {
243243

244244
/// Traverses and collects all the lang items in all crates.
245245
fn get_lang_items(tcx: TyCtxt<'_>, (): ()) -> LanguageItems {
246-
let resolver = tcx.resolver_for_lowering(()).borrow();
246+
let resolver = tcx.resolver_for_lowering(()).0.borrow();
247247
let (resolver, krate) = &*resolver;
248248

249249
// Initialize the collector.

0 commit comments

Comments
 (0)