@@ -624,7 +624,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
624
624
match self . length {
625
625
0 => None ,
626
626
_ => Some ( OccupiedEntry {
627
- handle : self . root . as_mut ( ) . first_kv ( ) ,
627
+ handle : unsafe { self . root . as_mut ( ) . first_kv ( ) } ,
628
628
length : & mut self . length ,
629
629
_marker : PhantomData ,
630
630
} ) ,
@@ -686,7 +686,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
686
686
match self . length {
687
687
0 => None ,
688
688
_ => Some ( OccupiedEntry {
689
- handle : self . root . as_mut ( ) . last_kv ( ) ,
689
+ handle : unsafe { self . root . as_mut ( ) . last_kv ( ) } ,
690
690
length : & mut self . length ,
691
691
_marker : PhantomData ,
692
692
} ) ,
@@ -1052,7 +1052,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
1052
1052
Ok ( left) => left,
1053
1053
Err ( _) => unreachable ! ( ) ,
1054
1054
} ;
1055
- last_kv. bulk_steal_left ( node:: MIN_LEN - right_child_len) ;
1055
+ unsafe { last_kv. bulk_steal_left ( node:: MIN_LEN - right_child_len) } ;
1056
1056
last_edge = last_kv. right_edge ( ) ;
1057
1057
}
1058
1058
@@ -1118,7 +1118,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
1118
1118
GoDown ( handle) => handle,
1119
1119
} ;
1120
1120
1121
- split_edge. move_suffix ( & mut right_node) ;
1121
+ unsafe { split_edge. move_suffix ( & mut right_node) } ;
1122
1122
1123
1123
match ( split_edge. force ( ) , right_node. force ( ) ) {
1124
1124
( Internal ( edge) , Internal ( node) ) => {
@@ -1188,7 +1188,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
1188
1188
break ;
1189
1189
}
1190
1190
}
1191
- self . root . pop_level ( ) ;
1191
+ unsafe { self . root . pop_level ( ) } ;
1192
1192
}
1193
1193
}
1194
1194
@@ -1199,15 +1199,15 @@ impl<K: Ord, V> BTreeMap<K, V> {
1199
1199
let mut cur_node = self . root . as_mut ( ) ;
1200
1200
1201
1201
while let Internal ( node) = cur_node. force ( ) {
1202
- let mut last_kv = node. last_kv ( ) ;
1202
+ let mut last_kv = unsafe { node. last_kv ( ) } ;
1203
1203
1204
1204
if last_kv. can_merge ( ) {
1205
- cur_node = last_kv. merge ( ) . descend ( ) ;
1205
+ cur_node = unsafe { last_kv. merge ( ) } . descend ( ) ;
1206
1206
} else {
1207
1207
let right_len = last_kv. reborrow ( ) . right_edge ( ) . descend ( ) . len ( ) ;
1208
1208
// `MINLEN + 1` to avoid readjust if merge happens on the next level.
1209
1209
if right_len < node:: MIN_LEN + 1 {
1210
- last_kv. bulk_steal_left ( node:: MIN_LEN + 1 - right_len) ;
1210
+ unsafe { last_kv. bulk_steal_left ( node:: MIN_LEN + 1 - right_len) } ;
1211
1211
}
1212
1212
cur_node = last_kv. right_edge ( ) . descend ( ) ;
1213
1213
}
@@ -1225,14 +1225,14 @@ impl<K: Ord, V> BTreeMap<K, V> {
1225
1225
let mut cur_node = self . root . as_mut ( ) ;
1226
1226
1227
1227
while let Internal ( node) = cur_node. force ( ) {
1228
- let mut first_kv = node. first_kv ( ) ;
1228
+ let mut first_kv = unsafe { node. first_kv ( ) } ;
1229
1229
1230
1230
if first_kv. can_merge ( ) {
1231
- cur_node = first_kv. merge ( ) . descend ( ) ;
1231
+ cur_node = unsafe { first_kv. merge ( ) . descend ( ) } ;
1232
1232
} else {
1233
1233
let left_len = first_kv. reborrow ( ) . left_edge ( ) . descend ( ) . len ( ) ;
1234
1234
if left_len < node:: MIN_LEN + 1 {
1235
- first_kv. bulk_steal_right ( node:: MIN_LEN + 1 - left_len) ;
1235
+ unsafe { first_kv. bulk_steal_right ( node:: MIN_LEN + 1 - left_len) } ;
1236
1236
}
1237
1237
cur_node = first_kv. left_edge ( ) . descend ( ) ;
1238
1238
}
@@ -2614,7 +2614,7 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
2614
2614
Merged ( parent) => {
2615
2615
if parent. len ( ) == 0 {
2616
2616
// We must be at the root
2617
- parent. into_root_mut ( ) . pop_level ( ) ;
2617
+ unsafe { parent. into_root_mut ( ) . pop_level ( ) } ;
2618
2618
break ;
2619
2619
} else {
2620
2620
cur_node = parent. forget_type ( ) ;
@@ -2655,7 +2655,7 @@ fn handle_underfull_node<K, V>(
2655
2655
} ;
2656
2656
2657
2657
if handle. can_merge ( ) {
2658
- Merged ( handle. merge ( ) . into_node ( ) )
2658
+ Merged ( unsafe { handle. merge ( ) } . into_node ( ) )
2659
2659
} else {
2660
2660
if is_left {
2661
2661
handle. steal_left ( ) ;
0 commit comments