Skip to content

Commit e853cc0

Browse files
committed
Retire rustc_dep_node_force.
1 parent de7da7f commit e853cc0

File tree

2 files changed

+36
-46
lines changed

2 files changed

+36
-46
lines changed

compiler/rustc_macros/src/query.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
421421
let mut query_stream = quote! {};
422422
let mut query_description_stream = quote! {};
423423
let mut dep_node_def_stream = quote! {};
424-
let mut dep_node_force_stream = quote! {};
425424
let mut try_load_from_on_disk_cache_stream = quote! {};
426425
let mut cached_queries = quote! {};
427426

@@ -498,33 +497,10 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
498497
[#attribute_stream] #name(#arg),
499498
});
500499

501-
// Add a match arm to force the query given the dep node
502-
dep_node_force_stream.extend(quote! {
503-
::rustc_middle::dep_graph::DepKind::#name => {
504-
if <#arg as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key() {
505-
if let Some(key) = <#arg as DepNodeParams<TyCtxt<'_>>>::recover($tcx, $dep_node) {
506-
force_query::<crate::ty::query::queries::#name<'_>, _>(
507-
$tcx,
508-
key,
509-
DUMMY_SP,
510-
*$dep_node
511-
);
512-
return true;
513-
}
514-
}
515-
}
516-
});
517-
518500
add_query_description_impl(&query, modifiers, &mut query_description_stream);
519501
}
520502
}
521503

522-
dep_node_force_stream.extend(quote! {
523-
::rustc_middle::dep_graph::DepKind::Null => {
524-
bug!("Cannot force dep node: {:?}", $dep_node)
525-
}
526-
});
527-
528504
TokenStream::from(quote! {
529505
macro_rules! rustc_query_append {
530506
([$($macro:tt)*][$($other:tt)*]) => {
@@ -545,15 +521,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
545521
);
546522
}
547523
}
548-
macro_rules! rustc_dep_node_force {
549-
([$dep_node:expr, $tcx:expr] $($other:tt)*) => {
550-
match $dep_node.kind {
551-
$($other)*
552-
553-
#dep_node_force_stream
554-
}
555-
}
556-
}
557524
macro_rules! rustc_cached_queries {
558525
($($macro:tt)*) => {
559526
$($macro)*(#cached_queries);

compiler/rustc_middle/src/ty/query/mod.rs

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,43 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool
168168
return false;
169169
}
170170

171-
rustc_dep_node_force!([dep_node, tcx]
172-
// These are inputs that are expected to be pre-allocated and that
173-
// should therefore always be red or green already.
174-
DepKind::CrateMetadata |
175-
176-
// These are anonymous nodes.
177-
DepKind::TraitSelect |
178-
179-
// We don't have enough information to reconstruct the query key of
180-
// these.
181-
DepKind::CompileCodegenUnit => {
182-
bug!("force_from_dep_node: encountered {:?}", dep_node)
171+
macro_rules! force_from_dep_node {
172+
($($(#[$attr:meta])* [$($modifiers:tt)*] $name:ident($K:ty),)*) => {
173+
match dep_node.kind {
174+
// These are inputs that are expected to be pre-allocated and that
175+
// should therefore always be red or green already.
176+
DepKind::CrateMetadata |
177+
178+
// These are anonymous nodes.
179+
DepKind::TraitSelect |
180+
181+
// We don't have enough information to reconstruct the query key of
182+
// these.
183+
DepKind::CompileCodegenUnit |
184+
185+
// Forcing this makes no sense.
186+
DepKind::Null => {
187+
bug!("force_from_dep_node: encountered {:?}", dep_node)
188+
}
189+
190+
$(DepKind::$name => {
191+
debug_assert!(<$K as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key());
192+
193+
if let Some(key) = <$K as DepNodeParams<TyCtxt<'_>>>::recover(tcx, dep_node) {
194+
force_query::<queries::$name<'_>, _>(
195+
tcx,
196+
key,
197+
DUMMY_SP,
198+
*dep_node
199+
);
200+
return true;
201+
}
202+
})*
203+
}
183204
}
184-
);
205+
}
206+
207+
rustc_dep_node_append! { [force_from_dep_node!][] }
185208

186209
false
187210
}

0 commit comments

Comments
 (0)