Skip to content

Commit 8107b56

Browse files
authored
Add an explanation for the create_depgraph_edges
1 parent 70c10f1 commit 8107b56

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/librustc_mir/interpret/const_eval.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,17 @@ pub fn const_eval_provider<'a, 'tcx>(
529529
})
530530
}
531531

532+
// This function creates dep graph edges from statics to all referred to statics.
533+
// This is necessary, because the `const_eval` query cannot directly call itself
534+
// for other statics, because we cannot prevent recursion in queries.
535+
//
536+
// see test/incremental/static_refering_to_other_static2/issue.rs for an example
537+
// where not creating those edges would cause static A, which refers to static B
538+
// to point to the old allocation of static B, even though B has changed.
539+
//
540+
// In the future we will want to remove this funcion in favour of a system that
541+
// makes sure that statics don't need to have edges to other statics as long as
542+
// they are only referring by reference and not inspecting the other static's body.
532543
fn create_depgraph_edges<'a, 'tcx>(
533544
tcx: TyCtxt<'a, 'tcx, 'tcx>,
534545
alloc_id: AllocId,
@@ -548,4 +559,4 @@ fn create_depgraph_edges<'a, 'tcx>(
548559
}
549560
}
550561
}
551-
}
562+
}

0 commit comments

Comments
 (0)