@@ -199,7 +199,6 @@ pub struct CachedEarlyExit {
199
199
200
200
pub trait Cleanup < ' tcx > {
201
201
fn must_unwind ( & self ) -> bool ;
202
- fn clean_on_unwind ( & self ) -> bool ;
203
202
fn is_lifetime_end ( & self ) -> bool ;
204
203
fn trans < ' blk > ( & self ,
205
204
bcx : Block < ' blk , ' tcx > ,
@@ -776,29 +775,19 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
776
775
//
777
776
// At this point, `popped_scopes` is empty, and so the final block
778
777
// that we return to the user is `Cleanup(AST 24)`.
779
- while !popped_scopes. is_empty ( ) {
780
- let mut scope = popped_scopes. pop ( ) . unwrap ( ) ;
781
-
782
- if scope. cleanups . iter ( ) . any ( |c| cleanup_is_suitable_for ( & * * c, label) )
783
- {
784
- let name = scope. block_name ( "clean" ) ;
785
- debug ! ( "generating cleanups for {}" , name) ;
786
- let bcx_in = self . new_block ( label. is_unwind ( ) ,
787
- & name[ ..] ,
788
- None ) ;
789
- let mut bcx_out = bcx_in;
790
- for cleanup in scope. cleanups . iter ( ) . rev ( ) {
791
- if cleanup_is_suitable_for ( & * * cleanup, label) {
792
- bcx_out = cleanup. trans ( bcx_out,
793
- scope. debug_loc ) ;
794
- }
795
- }
796
- build:: Br ( bcx_out, prev_llbb, DebugLoc :: None ) ;
797
- prev_llbb = bcx_in. llbb ;
798
- } else {
799
- debug ! ( "no suitable cleanups in {}" ,
800
- scope. block_name( "clean" ) ) ;
778
+ while let Some ( mut scope) = popped_scopes. pop ( ) {
779
+ let name = scope. block_name ( "clean" ) ;
780
+ debug ! ( "generating cleanups for {}" , name) ;
781
+ let bcx_in = self . new_block ( label. is_unwind ( ) ,
782
+ & name[ ..] ,
783
+ None ) ;
784
+ let mut bcx_out = bcx_in;
785
+ for cleanup in scope. cleanups . iter ( ) . rev ( ) {
786
+ bcx_out = cleanup. trans ( bcx_out,
787
+ scope. debug_loc ) ;
801
788
}
789
+ build:: Br ( bcx_out, prev_llbb, DebugLoc :: None ) ;
790
+ prev_llbb = bcx_in. llbb ;
802
791
803
792
scope. add_cached_early_exit ( label, prev_llbb) ;
804
793
self . push_scope ( scope) ;
@@ -1038,10 +1027,6 @@ impl<'tcx> Cleanup<'tcx> for DropValue<'tcx> {
1038
1027
true
1039
1028
}
1040
1029
1041
- fn clean_on_unwind ( & self ) -> bool {
1042
- true
1043
- }
1044
-
1045
1030
fn is_lifetime_end ( & self ) -> bool {
1046
1031
false
1047
1032
}
@@ -1085,10 +1070,6 @@ impl<'tcx> Cleanup<'tcx> for FreeValue<'tcx> {
1085
1070
true
1086
1071
}
1087
1072
1088
- fn clean_on_unwind ( & self ) -> bool {
1089
- true
1090
- }
1091
-
1092
1073
fn is_lifetime_end ( & self ) -> bool {
1093
1074
false
1094
1075
}
@@ -1118,10 +1099,6 @@ impl<'tcx> Cleanup<'tcx> for LifetimeEnd {
1118
1099
false
1119
1100
}
1120
1101
1121
- fn clean_on_unwind ( & self ) -> bool {
1122
- true
1123
- }
1124
-
1125
1102
fn is_lifetime_end ( & self ) -> bool {
1126
1103
true
1127
1104
}
@@ -1160,11 +1137,6 @@ pub fn var_scope(tcx: &ty::ctxt,
1160
1137
r
1161
1138
}
1162
1139
1163
- fn cleanup_is_suitable_for ( c : & Cleanup ,
1164
- label : EarlyExitLabel ) -> bool {
1165
- !label. is_unwind ( ) || c. clean_on_unwind ( )
1166
- }
1167
-
1168
1140
///////////////////////////////////////////////////////////////////////////
1169
1141
// These traits just exist to put the methods into this file.
1170
1142
0 commit comments