@@ -1034,16 +1034,23 @@ pub struct FreeRegionInfo {
1034
1034
1035
1035
/// This struct should only be created by `create_def`.
1036
1036
#[ derive( Copy , Clone ) ]
1037
- pub struct TyCtxtFeed < ' tcx > {
1037
+ pub struct TyCtxtFeed < ' tcx , KEY : Copy > {
1038
1038
pub tcx : TyCtxt < ' tcx > ,
1039
1039
// Do not allow direct access, as downstream code must not mutate this field.
1040
- def_id : LocalDefId ,
1040
+ key : KEY ,
1041
1041
}
1042
1042
1043
- impl < ' tcx > TyCtxtFeed < ' tcx > {
1043
+ impl < ' tcx , KEY : Copy > TyCtxtFeed < ' tcx , KEY > {
1044
+ #[ inline( always) ]
1045
+ pub fn key ( & self ) -> KEY {
1046
+ self . key
1047
+ }
1048
+ }
1049
+
1050
+ impl < ' tcx > TyCtxtFeed < ' tcx , LocalDefId > {
1044
1051
#[ inline( always) ]
1045
1052
pub fn def_id ( & self ) -> LocalDefId {
1046
- self . def_id
1053
+ self . key
1047
1054
}
1048
1055
}
1049
1056
@@ -1515,7 +1522,7 @@ impl<'tcx> TyCtxtAt<'tcx> {
1515
1522
self ,
1516
1523
parent : LocalDefId ,
1517
1524
data : hir:: definitions:: DefPathData ,
1518
- ) -> TyCtxtFeed < ' tcx > {
1525
+ ) -> TyCtxtFeed < ' tcx , LocalDefId > {
1519
1526
// This function modifies `self.definitions` using a side-effect.
1520
1527
// We need to ensure that these side effects are re-run by the incr. comp. engine.
1521
1528
// Depending on the forever-red node will tell the graph that the calling query
@@ -1536,9 +1543,9 @@ impl<'tcx> TyCtxtAt<'tcx> {
1536
1543
// This is fine because:
1537
1544
// - those queries are `eval_always` so we won't miss their result changing;
1538
1545
// - 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) ;
1540
1547
1541
- let feed = TyCtxtFeed { tcx : self . tcx , def_id } ;
1548
+ let feed = TyCtxtFeed { tcx : self . tcx , key } ;
1542
1549
feed. def_span ( self . span ) ;
1543
1550
feed
1544
1551
}
0 commit comments