Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable drop range analysis #93284

Merged
merged 3 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions compiler/rustc_typeck/src/check/generator_interior/drop_ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,27 @@ pub fn compute_drop_ranges<'a, 'tcx>(
def_id: DefId,
body: &'tcx Body<'tcx>,
) -> DropRanges {
let consumed_borrowed_places = find_consumed_and_borrowed(fcx, def_id, body);
if super::ENABLE_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);
let mut drop_ranges = build_control_flow_graph(
fcx.tcx.hir(),
fcx.tcx,
&fcx.typeck_results.borrow(),
consumed_borrowed_places,
body,
num_exprs,
);
let num_exprs = fcx.tcx.region_scope_tree(def_id).body_expr_count(body.id()).unwrap_or(0);
let mut drop_ranges = build_control_flow_graph(
fcx.tcx.hir(),
fcx.tcx,
&fcx.typeck_results.borrow(),
consumed_borrowed_places,
body,
num_exprs,
);

drop_ranges.propagate_to_fixpoint();
drop_ranges.propagate_to_fixpoint();

DropRanges { tracked_value_map: drop_ranges.tracked_value_map, nodes: drop_ranges.nodes }
DropRanges { tracked_value_map: drop_ranges.tracked_value_map, nodes: drop_ranges.nodes }
} else {
// If drop range tracking is not enabled, skip all the analysis and produce an
// empty set of DropRanges.
DropRanges { tracked_value_map: FxHashMap::default(), nodes: IndexVec::new() }
}
}

/// Applies `f` to consumable node in the HIR subtree pointed to by `place`.
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/async-await/issue-93197.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Regression test for #93197
// build-pass
eholk marked this conversation as resolved.
Show resolved Hide resolved
// edition:2021

#![feature(try_blocks)]

use std::sync::{mpsc, mpsc::SendError};

pub async fn foo() {
let (tx, _) = mpsc::channel();

let _: Result<(), SendError<&str>> = try { tx.send("hello")?; };
}

fn main() {}