Skip to content

Commit 565c35a

Browse files
fix doc and dedup diverge_cleanup
1 parent 5131e9d commit 565c35a

File tree

1 file changed

+4
-23
lines changed
  • compiler/rustc_mir_build/src/build

1 file changed

+4
-23
lines changed

Diff for: compiler/rustc_mir_build/src/build/scope.rs

+4-23
Original file line numberDiff line numberDiff line change
@@ -999,31 +999,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
999999
/// Returns the [DropIdx] for the innermost drop if the function unwound at
10001000
/// this point. The `DropIdx` will be created if it doesn't already exist.
10011001
fn diverge_cleanup(&mut self) -> DropIdx {
1002-
let is_generator = self.generator_kind.is_some();
1003-
let (uncached_scope, mut cached_drop) = self
1004-
.scopes
1005-
.scopes
1006-
.iter()
1007-
.enumerate()
1008-
.rev()
1009-
.find_map(|(scope_idx, scope)| {
1010-
scope.cached_unwind_block.map(|cached_block| (scope_idx + 1, cached_block))
1011-
})
1012-
.unwrap_or((0, ROOT_NODE));
1013-
1014-
for scope in &mut self.scopes.scopes[uncached_scope..] {
1015-
for drop in &scope.drops {
1016-
if is_generator || drop.kind == DropKind::Value {
1017-
cached_drop = self.scopes.unwind_drops.add_drop(*drop, cached_drop);
1018-
}
1019-
}
1020-
scope.cached_unwind_block = Some(cached_drop);
1021-
}
1022-
1023-
cached_drop
1002+
// It is okay to use dummy span because the getting scope index on the topmost scope
1003+
// must always succeed.
1004+
self.diverge_cleanup_target(self.scopes.topmost(), DUMMY_SP)
10241005
}
10251006

1026-
/// This is similar to [diverge_cleanup] except its target is set to
1007+
/// This is similar to [diverge_cleanup](Self::diverge_cleanup) except its target is set to
10271008
/// some ancestor scope instead of the current scope.
10281009
/// It is possible to unwind to some ancestor scope if some drop panics as
10291010
/// the program breaks out of a if-then scope.

0 commit comments

Comments
 (0)