@@ -81,7 +81,7 @@ use std::mem;
8181use std:: ops:: { Bound , Deref } ;
8282use std:: sync:: Arc ;
8383
84- use super :: { ImplPolarity , ResolverOutputs , RvalueScopes } ;
84+ use super :: { ImplPolarity , RvalueScopes } ;
8585
8686pub trait OnDiskCache < ' tcx > : rustc_data_structures:: sync:: Sync {
8787 /// Creates a new `OnDiskCache` instance from the serialized data in `data`.
@@ -1034,16 +1034,29 @@ pub struct FreeRegionInfo {
10341034
10351035/// This struct should only be created by `create_def`.
10361036#[ derive( Copy , Clone ) ]
1037- pub struct TyCtxtFeed < ' tcx > {
1037+ pub struct TyCtxtFeed < ' tcx , KEY : Copy > {
10381038 pub tcx : TyCtxt < ' tcx > ,
10391039 // Do not allow direct access, as downstream code must not mutate this field.
1040- def_id : LocalDefId ,
1040+ key : KEY ,
10411041}
10421042
1043- impl < ' tcx > TyCtxtFeed < ' tcx > {
1043+ impl < ' tcx > TyCtxt < ' tcx > {
1044+ pub fn feed_unit_query ( self ) -> TyCtxtFeed < ' tcx , ( ) > {
1045+ TyCtxtFeed { tcx : self , key : ( ) }
1046+ }
1047+ }
1048+
1049+ impl < ' tcx , KEY : Copy > TyCtxtFeed < ' tcx , KEY > {
1050+ #[ inline( always) ]
1051+ pub fn key ( & self ) -> KEY {
1052+ self . key
1053+ }
1054+ }
1055+
1056+ impl < ' tcx > TyCtxtFeed < ' tcx , LocalDefId > {
10441057 #[ inline( always) ]
10451058 pub fn def_id ( & self ) -> LocalDefId {
1046- self . def_id
1059+ self . key
10471060 }
10481061}
10491062
@@ -1099,7 +1112,6 @@ pub struct GlobalCtxt<'tcx> {
10991112
11001113 /// Output of the resolver.
11011114 pub ( crate ) untracked_resolutions : ty:: ResolverGlobalCtxt ,
1102- untracked_resolver_for_lowering : Steal < ty:: ResolverAstLowering > ,
11031115 /// The entire crate as AST. This field serves as the input for the hir_crate query,
11041116 /// which lowers it from AST to HIR. It must not be read or used by anything else.
11051117 pub untracked_crate : Steal < Lrc < ast:: Crate > > ,
@@ -1262,7 +1274,8 @@ impl<'tcx> TyCtxt<'tcx> {
12621274 lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
12631275 arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
12641276 hir_arena : & ' tcx WorkerLocal < hir:: Arena < ' tcx > > ,
1265- resolver_outputs : ResolverOutputs ,
1277+ definitions : Definitions ,
1278+ untracked_resolutions : ty:: ResolverGlobalCtxt ,
12661279 krate : Lrc < ast:: Crate > ,
12671280 dep_graph : DepGraph ,
12681281 on_disk_cache : Option < & ' tcx dyn OnDiskCache < ' tcx > > ,
@@ -1271,11 +1284,6 @@ impl<'tcx> TyCtxt<'tcx> {
12711284 crate_name : & str ,
12721285 output_filenames : OutputFilenames ,
12731286 ) -> GlobalCtxt < ' tcx > {
1274- let ResolverOutputs {
1275- definitions,
1276- global_ctxt : untracked_resolutions,
1277- ast_lowering : untracked_resolver_for_lowering,
1278- } = resolver_outputs;
12791287 let data_layout = s. target . parse_data_layout ( ) . unwrap_or_else ( |err| {
12801288 s. emit_fatal ( err) ;
12811289 } ) ;
@@ -1304,7 +1312,6 @@ impl<'tcx> TyCtxt<'tcx> {
13041312 lifetimes : common_lifetimes,
13051313 consts : common_consts,
13061314 untracked_resolutions,
1307- untracked_resolver_for_lowering : Steal :: new ( untracked_resolver_for_lowering) ,
13081315 untracked_crate : Steal :: new ( krate) ,
13091316 on_disk_cache,
13101317 queries,
@@ -1515,7 +1522,7 @@ impl<'tcx> TyCtxtAt<'tcx> {
15151522 self ,
15161523 parent : LocalDefId ,
15171524 data : hir:: definitions:: DefPathData ,
1518- ) -> TyCtxtFeed < ' tcx > {
1525+ ) -> TyCtxtFeed < ' tcx , LocalDefId > {
15191526 // This function modifies `self.definitions` using a side-effect.
15201527 // We need to ensure that these side effects are re-run by the incr. comp. engine.
15211528 // Depending on the forever-red node will tell the graph that the calling query
@@ -1536,9 +1543,9 @@ impl<'tcx> TyCtxtAt<'tcx> {
15361543 // This is fine because:
15371544 // - those queries are `eval_always` so we won't miss their result changing;
15381545 // - this write will have happened before these queries are called.
1539- let def_id = self . definitions . write ( ) . create_def ( parent, data) ;
1546+ let key = self . definitions . write ( ) . create_def ( parent, data) ;
15401547
1541- let feed = TyCtxtFeed { tcx : self . tcx , def_id } ;
1548+ let feed = TyCtxtFeed { tcx : self . tcx , key } ;
15421549 feed. def_span ( self . span ) ;
15431550 feed
15441551 }
@@ -3107,7 +3114,6 @@ fn ptr_eq<T, U>(t: *const T, u: *const U) -> bool {
31073114
31083115pub fn provide ( providers : & mut ty:: query:: Providers ) {
31093116 providers. resolutions = |tcx, ( ) | & tcx. untracked_resolutions ;
3110- providers. resolver_for_lowering = |tcx, ( ) | & tcx. untracked_resolver_for_lowering ;
31113117 providers. module_reexports =
31123118 |tcx, id| tcx. resolutions ( ( ) ) . reexport_map . get ( & id) . map ( |v| & v[ ..] ) ;
31133119 providers. crate_name = |tcx, id| {
0 commit comments