Skip to content

Commit b1ec9b8

Browse files
committed
Subpart9 for async drop (major3) - elaborate_drops changes
1 parent 9e9f5e4 commit b1ec9b8

File tree

7 files changed

+468
-79
lines changed

7 files changed

+468
-79
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4216,6 +4216,7 @@ dependencies = [
42164216
name = "rustc_mir_dataflow"
42174217
version = "0.0.0"
42184218
dependencies = [
4219+
"itertools",
42194220
"polonius-engine",
42204221
"regex",
42214222
"rustc_abi",

compiler/rustc_mir_build/src/builder/scope.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -884,17 +884,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
884884
fn is_async_drop_impl(
885885
tcx: TyCtxt<'tcx>,
886886
local_decls: &IndexVec<Local, LocalDecl<'tcx>>,
887-
param_env: ty::ParamEnv<'tcx>,
887+
typing_env: ty::TypingEnv<'tcx>,
888888
local: Local,
889889
) -> bool {
890890
let ty = local_decls[local].ty;
891-
if ty.is_async_drop(tcx, param_env) || ty.is_coroutine() {
891+
if ty.is_async_drop(tcx, typing_env) || ty.is_coroutine() {
892892
return true;
893893
}
894-
ty.needs_async_drop(tcx, param_env)
894+
ty.needs_async_drop(tcx, typing_env)
895895
}
896896
fn is_async_drop(&self, local: Local) -> bool {
897-
Self::is_async_drop_impl(self.tcx, &self.local_decls, self.param_env, local)
897+
Self::is_async_drop_impl(self.tcx, &self.local_decls, self.typing_env(), local)
898898
}
899899

900900
fn leave_top_scope(&mut self, block: BasicBlock) -> BasicBlock {
@@ -909,6 +909,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
909909
&& scope.drops.iter().any(|v| v.kind == DropKind::Value && self.is_async_drop(v.local));
910910
let dropline_to = if has_async_drops { Some(self.diverge_dropline()) } else { None };
911911
let scope = self.scopes.scopes.last().expect("leave_top_scope called with no scopes");
912+
let typing_env = self.typing_env();
912913
build_scope_drops(
913914
&mut self.cfg,
914915
&mut self.scopes.unwind_drops,
@@ -919,7 +920,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
919920
dropline_to,
920921
is_coroutine && needs_cleanup,
921922
self.arg_count,
922-
|v: Local| Self::is_async_drop_impl(self.tcx, &self.local_decls, self.param_env, v),
923+
|v: Local| Self::is_async_drop_impl(self.tcx, &self.local_decls, typing_env, v),
923924
)
924925
.into_block()
925926
}
@@ -1703,7 +1704,7 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> {
17031704
let mut dropline_indices = IndexVec::from_elem_n(dropline_target, 1);
17041705
for (drop_idx, drop_data) in drops.drops.iter_enumerated().skip(1) {
17051706
match drop_data.data.kind {
1706-
DropKind::Storage => {
1707+
DropKind::Storage | DropKind::ForLint => {
17071708
let coroutine_drop = self
17081709
.scopes
17091710
.coroutine_drops

compiler/rustc_mir_dataflow/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8+
itertools = "0.12"
89
polonius-engine = "0.13.0"
910
regex = "1"
1011
rustc_abi = { path = "../rustc_abi" }

0 commit comments

Comments
 (0)