@@ -1470,21 +1470,28 @@ impl<'tcx> TyCtxt<'tcx> {
1470
1470
1471
1471
/// Create a new definition within the incr. comp. engine.
1472
1472
pub fn create_def ( self , parent : LocalDefId , data : hir:: definitions:: DefPathData ) -> LocalDefId {
1473
- // The following call has the side effect of modifying the tables inside `definitions`.
1474
- // These very tables are relied on by the incr. comp. engine to decode DepNodes and to
1475
- // decode the on-disk cache.
1476
- let def_id = self . definitions . write ( ) . create_def ( parent, data) ;
1477
-
1473
+ // This function modifies `self.definitions` using a side-effect.
1478
1474
// We need to ensure that these side effects are re-run by the incr. comp. engine.
1475
+ // Depending on the forever-red node will tell the graph that the calling query
1476
+ // needs to be re-evaluated.
1479
1477
use rustc_query_system:: dep_graph:: DepNodeIndex ;
1480
1478
self . dep_graph . read_index ( DepNodeIndex :: FOREVER_RED_NODE ) ;
1481
1479
1480
+ // The following call has the side effect of modifying the tables inside `definitions`.
1481
+ // These very tables are relied on by the incr. comp. engine to decode DepNodes and to
1482
+ // decode the on-disk cache.
1483
+ //
1482
1484
// Any LocalDefId which is used within queries, either as key or result, either:
1483
1485
// - has been created before the construction of the TyCtxt;
1484
1486
// - has been created by this call to `create_def`.
1485
1487
// As a consequence, this LocalDefId is always re-created before it is needed by the incr.
1486
1488
// comp. engine itself.
1487
- def_id
1489
+ //
1490
+ // This call also writes to the value of `source_span` and `expn_that_defined` queries.
1491
+ // This is fine because:
1492
+ // - those queries are `eval_always` so we won't miss their result changing;
1493
+ // - this write will have happened before these queries are called.
1494
+ self . definitions . write ( ) . create_def ( parent, data)
1488
1495
}
1489
1496
1490
1497
pub fn iter_local_def_id ( self ) -> impl Iterator < Item = LocalDefId > + ' tcx {
0 commit comments