Skip to content

Commit 686663a

Browse files
committed
Auto merge of rust-lang#93284 - eholk:disable-drop-range-analysis, r=pnkfelix
Disable drop range analysis The previous PR, rust-lang#93165, still performed the drop range analysis despite ignoring the results. Unfortunately, there were ICEs in the analysis as well, so some packages failed to build (see the issue rust-lang#93197 for an example). This change further disables the analysis and just provides dummy results in that case.
2 parents 547f2ba + 9f9d82a commit 686663a

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

compiler/rustc_typeck/src/check/generator_interior/drop_ranges.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,27 @@ pub fn compute_drop_ranges<'a, 'tcx>(
3737
def_id: DefId,
3838
body: &'tcx Body<'tcx>,
3939
) -> DropRanges {
40-
let consumed_borrowed_places = find_consumed_and_borrowed(fcx, def_id, body);
40+
if super::ENABLE_DROP_TRACKING {
41+
let consumed_borrowed_places = find_consumed_and_borrowed(fcx, def_id, body);
4142

42-
let num_exprs = fcx.tcx.region_scope_tree(def_id).body_expr_count(body.id()).unwrap_or(0);
43-
let mut drop_ranges = build_control_flow_graph(
44-
fcx.tcx.hir(),
45-
fcx.tcx,
46-
&fcx.typeck_results.borrow(),
47-
consumed_borrowed_places,
48-
body,
49-
num_exprs,
50-
);
43+
let num_exprs = fcx.tcx.region_scope_tree(def_id).body_expr_count(body.id()).unwrap_or(0);
44+
let mut drop_ranges = build_control_flow_graph(
45+
fcx.tcx.hir(),
46+
fcx.tcx,
47+
&fcx.typeck_results.borrow(),
48+
consumed_borrowed_places,
49+
body,
50+
num_exprs,
51+
);
5152

52-
drop_ranges.propagate_to_fixpoint();
53+
drop_ranges.propagate_to_fixpoint();
5354

54-
DropRanges { tracked_value_map: drop_ranges.tracked_value_map, nodes: drop_ranges.nodes }
55+
DropRanges { tracked_value_map: drop_ranges.tracked_value_map, nodes: drop_ranges.nodes }
56+
} else {
57+
// If drop range tracking is not enabled, skip all the analysis and produce an
58+
// empty set of DropRanges.
59+
DropRanges { tracked_value_map: FxHashMap::default(), nodes: IndexVec::new() }
60+
}
5561
}
5662

5763
/// Applies `f` to consumable node in the HIR subtree pointed to by `place`.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Regression test for #93197
2+
// check-pass
3+
// edition:2021
4+
5+
#![feature(try_blocks)]
6+
7+
use std::sync::{mpsc, mpsc::SendError};
8+
9+
pub async fn foo() {
10+
let (tx, _) = mpsc::channel();
11+
12+
let _: Result<(), SendError<&str>> = try { tx.send("hello")?; };
13+
}
14+
15+
fn main() {}

0 commit comments

Comments
 (0)