Skip to content

Commit 4374855

Browse files
committed
comment what trace does
1 parent 9394a99 commit 4374855

File tree

1 file changed

+14
-0
lines changed
  • src/librustc_mir/borrow_check/nll/type_check/liveness

1 file changed

+14
-0
lines changed

src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ use rustc_data_structures::fx::FxHashMap;
2828
use std::rc::Rc;
2929
use util::liveness::LiveVariableMap;
3030

31+
/// This is the heart of the liveness computation. For each variable X
32+
/// that requires a liveness computation, it walks over all the uses
33+
/// of X and does a reverse depth-first search ("trace") through the
34+
/// MIR. This search stops when we find a definition of that variable.
35+
/// The points visited in this search is the USE-LIVE set for the variable;
36+
/// of those points is added to all the regions that appear in the variable's
37+
/// type.
38+
///
39+
/// We then also walks through each *drop* of those variables and does
40+
/// another search, stopping when we reach a use or definition. This
41+
/// is the DROP-LIVE set of points. Each of the points in the
42+
/// DROP-LIVE set are to the liveness sets for regions found in the
43+
/// `dropck_outlives` result of the variable's type (in particular,
44+
/// this respects `#[may_dangle]` annotations).
3145
pub(super) fn trace(
3246
typeck: &mut TypeChecker<'_, 'gcx, 'tcx>,
3347
mir: &Mir<'tcx>,

0 commit comments

Comments
 (0)