File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1019,14 +1019,19 @@ impl<T> VecDeque<T> {
1019
1019
// the drain is complete and the Drain destructor is run.
1020
1020
self . head = drain_tail;
1021
1021
1022
+ // `deque` and `ring` overlap in what they point to, so we must make sure
1023
+ // that `ring` is "derived-from" `deque`, or else even just creating ring
1024
+ // from `self` already invalidates `deque`.
1025
+ let deque = NonNull :: from ( & mut * self ) ;
1026
+
1022
1027
Drain {
1023
- deque : NonNull :: from ( & mut * self ) ,
1028
+ deque,
1024
1029
after_tail : drain_head,
1025
1030
after_head : head,
1026
1031
iter : Iter {
1027
1032
tail : drain_tail,
1028
1033
head : drain_head,
1029
- ring : unsafe { self . buffer_as_mut_slice ( ) } ,
1034
+ ring : unsafe { ( & mut * deque . as_ptr ( ) ) . buffer_as_mut_slice ( ) } ,
1030
1035
} ,
1031
1036
}
1032
1037
}
You can’t perform that action at this time.
0 commit comments