From f4d7d099021500c049741d90041869a7890211da Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Mon, 24 Jan 2022 16:11:33 -0800 Subject: [PATCH 1/3] Disable drop range analysis The previous PR, #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 #93197 for an example). This change further disables the analysis and just provides dummy results in that case. --- .../check/generator_interior/drop_ranges.rs | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_typeck/src/check/generator_interior/drop_ranges.rs b/compiler/rustc_typeck/src/check/generator_interior/drop_ranges.rs index 21a8d7b563456..4b8f01e3535bd 100644 --- a/compiler/rustc_typeck/src/check/generator_interior/drop_ranges.rs +++ b/compiler/rustc_typeck/src/check/generator_interior/drop_ranges.rs @@ -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`. From 520bd698602275d045bc518f38105c0924cc1718 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Tue, 25 Jan 2022 15:19:33 -0800 Subject: [PATCH 2/3] Add regression test for #93197 --- src/test/ui/async-await/issue-93197.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/test/ui/async-await/issue-93197.rs diff --git a/src/test/ui/async-await/issue-93197.rs b/src/test/ui/async-await/issue-93197.rs new file mode 100644 index 0000000000000..e1b220d365f18 --- /dev/null +++ b/src/test/ui/async-await/issue-93197.rs @@ -0,0 +1,15 @@ +// Regression test for #93197 +// build-pass +// 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() {} From 9f9d82ab577d80a00b1c4e1a0a0f1b42a47118d7 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 26 Jan 2022 10:47:13 -0800 Subject: [PATCH 3/3] Change test to check-pass --- src/test/ui/async-await/issue-93197.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/async-await/issue-93197.rs b/src/test/ui/async-await/issue-93197.rs index e1b220d365f18..05ec013d0afd8 100644 --- a/src/test/ui/async-await/issue-93197.rs +++ b/src/test/ui/async-await/issue-93197.rs @@ -1,5 +1,5 @@ // Regression test for #93197 -// build-pass +// check-pass // edition:2021 #![feature(try_blocks)]