@@ -1131,10 +1131,12 @@ macro_rules! define_provider_struct {
11311131/// then `force_from_dep_node()` should not fail for it. Otherwise, you can just
11321132/// add it to the "We don't have enough information to reconstruct..." group in
11331133/// the match below.
1134- pub fn force_from_dep_node < ' a , ' gcx , ' lcx > ( tcx : TyCtxt < ' a , ' gcx , ' lcx > ,
1135- dep_node : & DepNode )
1136- -> bool {
1134+ pub fn force_from_dep_node < ' tcx > (
1135+ tcx : TyCtxt < ' _ , ' tcx , ' tcx > ,
1136+ dep_node : & DepNode
1137+ ) -> bool {
11371138 use crate :: hir:: def_id:: LOCAL_CRATE ;
1139+ use crate :: dep_graph:: RecoverKey ;
11381140
11391141 // We must avoid ever having to call force_from_dep_node() for a
11401142 // DepNode::CodegenUnit:
@@ -1171,17 +1173,26 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
11711173 ( ) => { ( def_id!( ) ) . krate }
11721174 } ;
11731175
1174- macro_rules! force {
1175- ( $query: ident, $key: expr) => {
1176+ macro_rules! force_ex {
1177+ ( $tcx : expr , $ query: ident, $key: expr) => {
11761178 {
1177- tcx. force_query:: <crate :: ty:: query:: queries:: $query<' _>>( $key, DUMMY_SP , * dep_node) ;
1179+ $tcx. force_query:: <crate :: ty:: query:: queries:: $query<' _>>(
1180+ $key,
1181+ DUMMY_SP ,
1182+ * dep_node
1183+ ) ;
11781184 }
11791185 }
11801186 } ;
11811187
1188+ macro_rules! force {
1189+ ( $query: ident, $key: expr) => { force_ex!( tcx, $query, $key) }
1190+ } ;
1191+
11821192 // FIXME(#45015): We should try move this boilerplate code into a macro
11831193 // somehow.
1184- match dep_node. kind {
1194+
1195+ rustc_dep_node_force ! ( [ dep_node, tcx]
11851196 // These are inputs that are expected to be pre-allocated and that
11861197 // should therefore always be red or green already
11871198 DepKind :: AllLocalTraitImpls |
@@ -1274,7 +1285,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
12741285 DepKind :: MirKeys => { force!( mir_keys, LOCAL_CRATE ) ; }
12751286 DepKind :: CrateVariances => { force!( crate_variances, LOCAL_CRATE ) ; }
12761287 DepKind :: AssociatedItems => { force!( associated_item, def_id!( ) ) ; }
1277- DepKind :: TypeOfItem => { force ! ( type_of, def_id!( ) ) ; }
12781288 DepKind :: GenericsOfItem => { force!( generics_of, def_id!( ) ) ; }
12791289 DepKind :: PredicatesOfItem => { force!( predicates_of, def_id!( ) ) ; }
12801290 DepKind :: PredicatesDefinedOnItem => { force!( predicates_defined_on, def_id!( ) ) ; }
@@ -1332,7 +1342,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
13321342 DepKind :: FnArgNames => { force!( fn_arg_names, def_id!( ) ) ; }
13331343 DepKind :: RenderedConst => { force!( rendered_const, def_id!( ) ) ; }
13341344 DepKind :: DylibDepFormats => { force!( dylib_dependency_formats, krate!( ) ) ; }
1335- DepKind :: IsPanicRuntime => { force ! ( is_panic_runtime, krate!( ) ) ; }
13361345 DepKind :: IsCompilerBuiltins => { force!( is_compiler_builtins, krate!( ) ) ; }
13371346 DepKind :: HasGlobalAllocator => { force!( has_global_allocator, krate!( ) ) ; }
13381347 DepKind :: HasPanicHandler => { force!( has_panic_handler, krate!( ) ) ; }
@@ -1349,7 +1358,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
13491358 DepKind :: CheckTraitItemWellFormed => { force!( check_trait_item_well_formed, def_id!( ) ) ; }
13501359 DepKind :: CheckImplItemWellFormed => { force!( check_impl_item_well_formed, def_id!( ) ) ; }
13511360 DepKind :: ReachableNonGenerics => { force!( reachable_non_generics, krate!( ) ) ; }
1352- DepKind :: NativeLibraries => { force ! ( native_libraries, krate!( ) ) ; }
13531361 DepKind :: EntryFn => { force!( entry_fn, krate!( ) ) ; }
13541362 DepKind :: PluginRegistrarFn => { force!( plugin_registrar_fn, krate!( ) ) ; }
13551363 DepKind :: ProcMacroDeclsStatic => { force!( proc_macro_decls_static, krate!( ) ) ; }
@@ -1432,7 +1440,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
14321440 DepKind :: BackendOptimizationLevel => {
14331441 force!( backend_optimization_level, krate!( ) ) ;
14341442 }
1435- }
1443+ ) ;
14361444
14371445 true
14381446}
@@ -1493,7 +1501,7 @@ impl_load_from_cache!(
14931501 SymbolName => def_symbol_name,
14941502 ConstIsRvaluePromotableToStatic => const_is_rvalue_promotable_to_static,
14951503 CheckMatch => check_match,
1496- TypeOfItem => type_of,
1504+ TypeOf => type_of,
14971505 GenericsOfItem => generics_of,
14981506 PredicatesOfItem => predicates_of,
14991507 UsedTraitImports => used_trait_imports,
0 commit comments