Skip to content

Commit e475a69

Browse files
committed
Reword create_def comment.
1 parent e912c8d commit e475a69

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

compiler/rustc_middle/src/ty/context.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -1470,21 +1470,28 @@ impl<'tcx> TyCtxt<'tcx> {
14701470

14711471
/// Create a new definition within the incr. comp. engine.
14721472
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.
14781474
// 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.
14791477
use rustc_query_system::dep_graph::DepNodeIndex;
14801478
self.dep_graph.read_index(DepNodeIndex::FOREVER_RED_NODE);
14811479

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+
//
14821484
// Any LocalDefId which is used within queries, either as key or result, either:
14831485
// - has been created before the construction of the TyCtxt;
14841486
// - has been created by this call to `create_def`.
14851487
// As a consequence, this LocalDefId is always re-created before it is needed by the incr.
14861488
// 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)
14881495
}
14891496

14901497
pub fn iter_local_def_id(self) -> impl Iterator<Item = LocalDefId> + 'tcx {

0 commit comments

Comments
 (0)