@@ -773,7 +773,7 @@ impl DropRangeVisitor<'tcx> {
773
773
debug ! ( "reinitializing {:?} at {}" , hir_id, location) ;
774
774
self . drop_range ( hir_id) . reinit ( location)
775
775
} else {
776
- warn ! ( "reinitializing {:?} is not supported" , expr) ;
776
+ debug ! ( "reinitializing {:?} is not supported" , expr) ;
777
777
}
778
778
}
779
779
}
@@ -899,6 +899,7 @@ impl<'tcx> Visitor<'tcx> for DropRangeVisitor<'tcx> {
899
899
reinit = Some ( lhs) ;
900
900
}
901
901
ExprKind :: Loop ( body, ..) => {
902
+ // FIXME: we probably need to iterate this to a fixpoint.
902
903
let body_drop_ranges = self . fork_drop_ranges ( ) ;
903
904
let old_drop_ranges = self . swap_drop_ranges ( body_drop_ranges) ;
904
905
@@ -1026,8 +1027,8 @@ impl DropRange {
1026
1027
}
1027
1028
1028
1029
fn is_dropped_at ( & self , id : usize ) -> bool {
1029
- match self . events . iter ( ) . try_fold ( false , |is_dropped, event| {
1030
- if event. location ( ) < id {
1030
+ let dropped = match self . events . iter ( ) . try_fold ( false , |is_dropped, event| {
1031
+ if event. location ( ) <= id {
1031
1032
Ok ( match event {
1032
1033
Event :: Drop ( _) => true ,
1033
1034
Event :: Reinit ( _) => false ,
@@ -1037,7 +1038,9 @@ impl DropRange {
1037
1038
}
1038
1039
} ) {
1039
1040
Ok ( is_dropped) | Err ( is_dropped) => is_dropped,
1040
- }
1041
+ } ;
1042
+ trace ! ( "is_dropped_at({}): events = {:?}, dropped = {}" , id, self . events, dropped) ;
1043
+ dropped
1041
1044
}
1042
1045
1043
1046
fn drop ( & mut self , location : usize ) {
@@ -1052,13 +1055,14 @@ impl DropRange {
1052
1055
///
1053
1056
/// After merging, the value will be dead at the end of the range only if it was dead
1054
1057
/// at the end of both self and other.
1058
+ #[ tracing:: instrument]
1055
1059
fn merge_with ( & mut self , other : & DropRange , join_point : usize ) {
1056
1060
let join_event = if self . is_dropped_at ( join_point) && other. is_dropped_at ( join_point) {
1057
1061
Event :: Drop ( join_point)
1058
1062
} else {
1059
1063
Event :: Reinit ( join_point)
1060
1064
} ;
1061
- let mut events: Vec < _ > = self
1065
+ let events: Vec < _ > = self
1062
1066
. events
1063
1067
. iter ( )
1064
1068
. merge ( [ join_event] . iter ( ) )
@@ -1067,11 +1071,7 @@ impl DropRange {
1067
1071
. cloned ( )
1068
1072
. collect ( ) ;
1069
1073
1070
- events. push ( if self . is_dropped_at ( join_point) && other. is_dropped_at ( join_point) {
1071
- Event :: Drop ( join_point)
1072
- } else {
1073
- Event :: Reinit ( join_point)
1074
- } ) ;
1074
+ trace ! ( "events after merging: {:?}" , events) ;
1075
1075
1076
1076
self . events = events;
1077
1077
}
@@ -1080,13 +1080,15 @@ impl DropRange {
1080
1080
///
1081
1081
/// Used to model branching control flow.
1082
1082
fn fork_at ( & self , split_point : usize ) -> Self {
1083
- Self {
1083
+ let result = Self {
1084
1084
events : vec ! [ if self . is_dropped_at( split_point) {
1085
1085
Event :: Drop ( split_point)
1086
1086
} else {
1087
1087
Event :: Reinit ( split_point)
1088
1088
} ] ,
1089
- }
1089
+ } ;
1090
+ trace ! ( "forking at {}: {:?}; result = {:?}" , split_point, self . events, result) ;
1091
+ result
1090
1092
}
1091
1093
1092
1094
fn trimmed ( & self , trim_from : usize ) -> Self {
@@ -1096,12 +1098,14 @@ impl DropRange {
1096
1098
Event :: Reinit ( trim_from)
1097
1099
} ;
1098
1100
1099
- Self {
1101
+ let result = Self {
1100
1102
events : [ start]
1101
1103
. iter ( )
1102
1104
. chain ( self . events . iter ( ) . skip_while ( |event| event. location ( ) <= trim_from) )
1103
1105
. cloned ( )
1104
1106
. collect ( ) ,
1105
- }
1107
+ } ;
1108
+ trace ! ( "trimmed {:?} at {}, got {:?}" , self , trim_from, result) ;
1109
+ result
1106
1110
}
1107
1111
}
0 commit comments