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> {
10191019 // the drain is complete and the Drain destructor is run.
10201020 self . head = drain_tail;
10211021
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+
10221027 Drain {
1023- deque : NonNull :: from ( & mut * self ) ,
1028+ deque,
10241029 after_tail : drain_head,
10251030 after_head : head,
10261031 iter : Iter {
10271032 tail : drain_tail,
10281033 head : drain_head,
1029- ring : unsafe { self . buffer_as_mut_slice ( ) } ,
1034+ ring : unsafe { ( & mut * deque . as_ptr ( ) ) . buffer_as_mut_slice ( ) } ,
10301035 } ,
10311036 }
10321037 }
You can’t perform that action at this time.
0 commit comments