Expand description

Drop range analysis finds the portions of the tree where a value is guaranteed to be dropped (i.e. moved, uninitialized, etc.). This is used to exclude the types of those values from the generator type. See InteriorVisitor::record for where the results of this analysis are used.

There are three phases to this analysis:

  1. Use ExprUseVisitor to identify the interesting values that are consumed and borrowed.
  2. Use DropRangeVisitor to find where the interesting values are dropped or reinitialized, and also build a control flow graph.
  3. Use DropRanges::propagate_to_fixpoint to flow the dropped/reinitialized information through the CFG and find the exact points where we know a value is definitely dropped.

The end result is a data structure that maps the post-order index of each node in the HIR tree to a set of values that are known to be dropped at that location.

Modules

cfg_build 🔒
Implementation of GraphWalk for DropRanges so we can visualize the control flow graph when needed for debugging.

Structs

Tracks information needed to compute drop ranges.
NodeInfo 🔒

Enums

Identifies a value whose drop state we need to track.
Represents a reason why we might not be able to convert a HirId or Place into a tracked value.

Functions

Applies f to consumable node in the HIR subtree pointed to by place.