@@ -1131,10 +1131,12 @@ macro_rules! define_provider_struct {
1131
1131
/// then `force_from_dep_node()` should not fail for it. Otherwise, you can just
1132
1132
/// add it to the "We don't have enough information to reconstruct..." group in
1133
1133
/// 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 {
1137
1138
use crate :: hir:: def_id:: LOCAL_CRATE ;
1139
+ use crate :: dep_graph:: RecoverKey ;
1138
1140
1139
1141
// We must avoid ever having to call force_from_dep_node() for a
1140
1142
// DepNode::CodegenUnit:
@@ -1171,17 +1173,26 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
1171
1173
( ) => { ( def_id!( ) ) . krate }
1172
1174
} ;
1173
1175
1174
- macro_rules! force {
1175
- ( $query: ident, $key: expr) => {
1176
+ macro_rules! force_ex {
1177
+ ( $tcx : expr , $ query: ident, $key: expr) => {
1176
1178
{
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
+ ) ;
1178
1184
}
1179
1185
}
1180
1186
} ;
1181
1187
1188
+ macro_rules! force {
1189
+ ( $query: ident, $key: expr) => { force_ex!( tcx, $query, $key) }
1190
+ } ;
1191
+
1182
1192
// FIXME(#45015): We should try move this boilerplate code into a macro
1183
1193
// somehow.
1184
- match dep_node. kind {
1194
+
1195
+ rustc_dep_node_force ! ( [ dep_node, tcx]
1185
1196
// These are inputs that are expected to be pre-allocated and that
1186
1197
// should therefore always be red or green already
1187
1198
DepKind :: AllLocalTraitImpls |
@@ -1274,7 +1285,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
1274
1285
DepKind :: MirKeys => { force!( mir_keys, LOCAL_CRATE ) ; }
1275
1286
DepKind :: CrateVariances => { force!( crate_variances, LOCAL_CRATE ) ; }
1276
1287
DepKind :: AssociatedItems => { force!( associated_item, def_id!( ) ) ; }
1277
- DepKind :: TypeOfItem => { force ! ( type_of, def_id!( ) ) ; }
1278
1288
DepKind :: GenericsOfItem => { force!( generics_of, def_id!( ) ) ; }
1279
1289
DepKind :: PredicatesOfItem => { force!( predicates_of, def_id!( ) ) ; }
1280
1290
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>,
1332
1342
DepKind :: FnArgNames => { force!( fn_arg_names, def_id!( ) ) ; }
1333
1343
DepKind :: RenderedConst => { force!( rendered_const, def_id!( ) ) ; }
1334
1344
DepKind :: DylibDepFormats => { force!( dylib_dependency_formats, krate!( ) ) ; }
1335
- DepKind :: IsPanicRuntime => { force ! ( is_panic_runtime, krate!( ) ) ; }
1336
1345
DepKind :: IsCompilerBuiltins => { force!( is_compiler_builtins, krate!( ) ) ; }
1337
1346
DepKind :: HasGlobalAllocator => { force!( has_global_allocator, krate!( ) ) ; }
1338
1347
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>,
1349
1358
DepKind :: CheckTraitItemWellFormed => { force!( check_trait_item_well_formed, def_id!( ) ) ; }
1350
1359
DepKind :: CheckImplItemWellFormed => { force!( check_impl_item_well_formed, def_id!( ) ) ; }
1351
1360
DepKind :: ReachableNonGenerics => { force!( reachable_non_generics, krate!( ) ) ; }
1352
- DepKind :: NativeLibraries => { force ! ( native_libraries, krate!( ) ) ; }
1353
1361
DepKind :: EntryFn => { force!( entry_fn, krate!( ) ) ; }
1354
1362
DepKind :: PluginRegistrarFn => { force!( plugin_registrar_fn, krate!( ) ) ; }
1355
1363
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>,
1432
1440
DepKind :: BackendOptimizationLevel => {
1433
1441
force!( backend_optimization_level, krate!( ) ) ;
1434
1442
}
1435
- }
1443
+ ) ;
1436
1444
1437
1445
true
1438
1446
}
@@ -1493,7 +1501,7 @@ impl_load_from_cache!(
1493
1501
SymbolName => def_symbol_name,
1494
1502
ConstIsRvaluePromotableToStatic => const_is_rvalue_promotable_to_static,
1495
1503
CheckMatch => check_match,
1496
- TypeOfItem => type_of,
1504
+ TypeOf => type_of,
1497
1505
GenericsOfItem => generics_of,
1498
1506
PredicatesOfItem => predicates_of,
1499
1507
UsedTraitImports => used_trait_imports,
0 commit comments