Skip to content

Commit b85e4cc

Browse files
committed
Fix unsoundness in VecDeque Debug impls
Fixes #53566.
1 parent 241b9b4 commit b85e4cc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/liballoc/collections/vec_deque.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,11 +1988,11 @@ pub struct Iter<'a, T: 'a> {
19881988
#[stable(feature = "collection_debug", since = "1.17.0")]
19891989
impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> {
19901990
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1991+
let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail);
19911992
f.debug_tuple("Iter")
1992-
.field(&self.ring)
1993-
.field(&self.tail)
1994-
.field(&self.head)
1995-
.finish()
1993+
.field(&front)
1994+
.field(&back)
1995+
.finish()
19961996
}
19971997
}
19981998

@@ -2085,11 +2085,11 @@ pub struct IterMut<'a, T: 'a> {
20852085
#[stable(feature = "collection_debug", since = "1.17.0")]
20862086
impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> {
20872087
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2088+
let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail);
20882089
f.debug_tuple("IterMut")
2089-
.field(&self.ring)
2090-
.field(&self.tail)
2091-
.field(&self.head)
2092-
.finish()
2090+
.field(&front)
2091+
.field(&back)
2092+
.finish()
20932093
}
20942094
}
20952095

0 commit comments

Comments
 (0)