@@ -999,31 +999,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
999
999
/// Returns the [DropIdx] for the innermost drop if the function unwound at
1000
1000
/// this point. The `DropIdx` will be created if it doesn't already exist.
1001
1001
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 )
1024
1005
}
1025
1006
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
1027
1008
/// some ancestor scope instead of the current scope.
1028
1009
/// It is possible to unwind to some ancestor scope if some drop panics as
1029
1010
/// the program breaks out of a if-then scope.
0 commit comments