Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f5f98d7

Browse files
committed
Refactor drop_ranges
Splits drop_ranges into drop_ranges::record_consumed_borrow, drop_ranges::cfg_build, and drop_ranges::cfg_propagate. The top level drop_ranges module has an entry point that does all the coordination of the other three phases, using code original in generator_interior.
1 parent 30e1b1e commit f5f98d7

File tree

6 files changed

+455
-410
lines changed

6 files changed

+455
-410
lines changed

compiler/rustc_typeck/src/check/generator_interior.rs

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
//! is calculated in `rustc_const_eval::transform::generator` and may be a subset of the
44
//! types computed here.
55
6-
use self::drop_ranges::{DropRangeVisitor, DropRanges, ExprUseDelegate};
6+
use self::drop_ranges::DropRanges;
77
use super::FnCtxt;
8-
use crate::expr_use_visitor::ExprUseVisitor;
98
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
109
use rustc_errors::pluralize;
1110
use rustc_hir as hir;
@@ -187,42 +186,17 @@ pub fn resolve_interior<'a, 'tcx>(
187186
kind: hir::GeneratorKind,
188187
) {
189188
let body = fcx.tcx.hir().body(body_id);
190-
191-
let mut visitor = {
192-
let mut expr_use_visitor = ExprUseDelegate::new(fcx.tcx.hir());
193-
194-
// Run ExprUseVisitor to find where values are consumed.
195-
ExprUseVisitor::new(
196-
&mut expr_use_visitor,
197-
&fcx.infcx,
198-
def_id.expect_local(),
199-
fcx.param_env,
200-
&fcx.typeck_results.borrow(),
201-
)
202-
.consume_body(body);
203-
204-
let region_scope_tree = fcx.tcx.region_scope_tree(def_id);
205-
let mut drop_range_visitor = DropRangeVisitor::from_uses(
206-
expr_use_visitor,
207-
region_scope_tree.body_expr_count(body.id()).unwrap_or(0),
208-
);
209-
intravisit::walk_body(&mut drop_range_visitor, body);
210-
211-
let mut drop_ranges = drop_range_visitor.into_drop_ranges();
212-
drop_ranges.propagate_to_fixpoint();
213-
214-
InteriorVisitor {
215-
fcx,
216-
types: FxIndexSet::default(),
217-
region_scope_tree,
218-
expr_count: 0,
219-
kind,
220-
prev_unresolved_span: None,
221-
guard_bindings: <_>::default(),
222-
guard_bindings_set: <_>::default(),
223-
linted_values: <_>::default(),
224-
drop_ranges: drop_ranges,
225-
}
189+
let mut visitor = InteriorVisitor {
190+
fcx,
191+
types: FxIndexSet::default(),
192+
region_scope_tree: fcx.tcx.region_scope_tree(def_id),
193+
expr_count: 0,
194+
kind,
195+
prev_unresolved_span: None,
196+
guard_bindings: <_>::default(),
197+
guard_bindings_set: <_>::default(),
198+
linted_values: <_>::default(),
199+
drop_ranges: drop_ranges::compute_drop_ranges(fcx, def_id, body),
226200
};
227201
intravisit::walk_body(&mut visitor, body);
228202

0 commit comments

Comments
 (0)