Add a flag enabling drop range tracking in generators

This commit is contained in:
Tomasz Miąsko 2022-02-02 10:40:39 +01:00 committed by Eric Holk
parent f52c31840d
commit 29185844c4
4 changed files with 5 additions and 7 deletions

View File

@ -730,6 +730,7 @@ macro_rules! tracked {
tracked!(debug_info_for_profiling, true);
tracked!(debug_macros, true);
tracked!(dep_info_omit_d_target, true);
tracked!(drop_tracking, true);
tracked!(dual_proc_macros, true);
tracked!(fewer_names, Some(true));
tracked!(force_unstable_if_unmarked, true);

View File

@ -1173,6 +1173,8 @@ mod parse {
dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED],
"emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) \
(default: no)"),
drop_tracking: bool = (false, parse_bool, [TRACKED],
"enables drop tracking in generators (default: no)"),
dual_proc_macros: bool = (false, parse_bool, [TRACKED],
"load proc macros for both target and host, but only link to the target (default: no)"),
dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],

View File

@ -22,11 +22,6 @@
mod drop_ranges;
// FIXME(eholk): This flag is here to give a quick way to disable drop tracking in case we find
// unexpected breakages while it's still new. It should be removed before too long. For example,
// see #93161.
const ENABLE_DROP_TRACKING: bool = false;
struct InteriorVisitor<'a, 'tcx> {
fcx: &'a FnCtxt<'a, 'tcx>,
types: FxIndexSet<ty::GeneratorInteriorTypeCause<'tcx>>,
@ -82,7 +77,7 @@ fn record(
yield_data.expr_and_pat_count, self.expr_count, source_span
);
if ENABLE_DROP_TRACKING
if self.fcx.sess().opts.debugging_opts.drop_tracking
&& self
.drop_ranges
.is_dropped_at(hir_id, yield_data.expr_and_pat_count)

View File

@ -37,7 +37,7 @@ pub fn compute_drop_ranges<'a, 'tcx>(
def_id: DefId,
body: &'tcx Body<'tcx>,
) -> DropRanges {
if super::ENABLE_DROP_TRACKING {
if fcx.sess().opts.debugging_opts.drop_tracking {
let consumed_borrowed_places = find_consumed_and_borrowed(fcx, def_id, body);
let num_exprs = fcx.tcx.region_scope_tree(def_id).body_expr_count(body.id()).unwrap_or(0);