about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/etc/gdb_providers.py8
-rw-r--r--src/etc/lldb_providers.py12
-rw-r--r--src/etc/natvis/liballoc.natvis15
-rw-r--r--src/test/debuginfo/pretty-std.rs4
-rw-r--r--src/test/ui/hygiene/panic-location.run.stderr2
5 files changed, 16 insertions, 25 deletions
diff --git a/src/etc/gdb_providers.py b/src/etc/gdb_providers.py
index c351c3450f5..32b8d8e24c6 100644
--- a/src/etc/gdb_providers.py
+++ b/src/etc/gdb_providers.py
@@ -144,20 +144,16 @@ class StdVecDequeProvider:
     def __init__(self, valobj):
         self.valobj = valobj
         self.head = int(valobj["head"])
-        self.tail = int(valobj["tail"])
+        self.size = int(valobj["len"])
         self.cap = int(valobj["buf"]["cap"])
         self.data_ptr = unwrap_unique_or_non_null(valobj["buf"]["ptr"])
-        if self.head >= self.tail:
-            self.size = self.head - self.tail
-        else:
-            self.size = self.cap + self.head - self.tail
 
     def to_string(self):
         return "VecDeque(size={})".format(self.size)
 
     def children(self):
         return _enumerate_array_elements(
-            (self.data_ptr + ((self.tail + index) % self.cap)) for index in xrange(self.size)
+            (self.data_ptr + ((self.head + index) % self.cap)) for index in xrange(self.size)
         )
 
     @staticmethod
diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py
index 8a9927e7d96..697ad4293c3 100644
--- a/src/etc/lldb_providers.py
+++ b/src/etc/lldb_providers.py
@@ -356,7 +356,7 @@ class StdSliceSyntheticProvider:
 class StdVecDequeSyntheticProvider:
     """Pretty-printer for alloc::collections::vec_deque::VecDeque<T>
 
-    struct VecDeque<T> { tail: usize, head: usize, buf: RawVec<T> }
+    struct VecDeque<T> { head: usize, len: usize, buf: RawVec<T> }
     """
 
     def __init__(self, valobj, dict):
@@ -373,7 +373,7 @@ class StdVecDequeSyntheticProvider:
     def get_child_index(self, name):
         # type: (str) -> int
         index = name.lstrip('[').rstrip(']')
-        if index.isdigit() and self.tail <= index and (self.tail + index) % self.cap < self.head:
+        if index.isdigit() and int(index) < self.size:
             return int(index)
         else:
             return -1
@@ -381,20 +381,16 @@ class StdVecDequeSyntheticProvider:
     def get_child_at_index(self, index):
         # type: (int) -> SBValue
         start = self.data_ptr.GetValueAsUnsigned()
-        address = start + ((index + self.tail) % self.cap) * self.element_type_size
+        address = start + ((index + self.head) % self.cap) * self.element_type_size
         element = self.data_ptr.CreateValueFromAddress("[%s]" % index, address, self.element_type)
         return element
 
     def update(self):
         # type: () -> None
         self.head = self.valobj.GetChildMemberWithName("head").GetValueAsUnsigned()
-        self.tail = self.valobj.GetChildMemberWithName("tail").GetValueAsUnsigned()
+        self.size = self.valobj.GetChildMemberWithName("len").GetValueAsUnsigned()
         self.buf = self.valobj.GetChildMemberWithName("buf")
         self.cap = self.buf.GetChildMemberWithName("cap").GetValueAsUnsigned()
-        if self.head >= self.tail:
-            self.size = self.head - self.tail
-        else:
-            self.size = self.cap + self.head - self.tail
 
         self.data_ptr = unwrap_unique_or_non_null(self.buf.GetChildMemberWithName("ptr"))
 
diff --git a/src/etc/natvis/liballoc.natvis b/src/etc/natvis/liballoc.natvis
index 41f4a3767f5..c4ad98ec1d3 100644
--- a/src/etc/natvis/liballoc.natvis
+++ b/src/etc/natvis/liballoc.natvis
@@ -12,20 +12,19 @@
     </Expand>
   </Type>
   <Type Name="alloc::collections::vec_deque::VecDeque&lt;*&gt;">
-    <DisplayString>{{ len={tail &lt;= head ? head - tail : buf.cap - tail + head} }}</DisplayString>
+    <DisplayString>{{ len={len} }}</DisplayString>
     <Expand>
-      <Item Name="[len]" ExcludeView="simple">tail &lt;= head ? head - tail : buf.cap - tail + head</Item>
+      <Item Name="[len]" ExcludeView="simple">len</Item>
       <Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
       <CustomListItems>
-        <Variable Name="i" InitialValue="tail" />
-
-        <Size>tail &lt;= head ? head - tail : buf.cap - tail + head</Size>
+        <Variable Name="i" InitialValue="0" />
+        <Size>len</Size>
         <Loop>
-          <If Condition="i == head">
+          <If Condition="i == len">
             <Break/>
           </If>
-          <Item>buf.ptr.pointer.pointer[i]</Item>
-          <Exec>i = (i + 1 == buf.cap ? 0 : i + 1)</Exec>
+          <Item>buf.ptr.pointer.pointer[(i + head) % buf.cap]</Item>
+          <Exec>i = i + 1</Exec>
         </Loop>
       </CustomListItems>
     </Expand>
diff --git a/src/test/debuginfo/pretty-std.rs b/src/test/debuginfo/pretty-std.rs
index d8c6344e0b6..7bb2810c2b2 100644
--- a/src/test/debuginfo/pretty-std.rs
+++ b/src/test/debuginfo/pretty-std.rs
@@ -138,7 +138,7 @@
 // cdb-command: dx vecdeque
 // cdb-check:vecdeque         : { len=0x2 } [Type: alloc::collections::vec_deque::VecDeque<i32,alloc::alloc::Global>]
 // cdb-check:    [<Raw View>]     [Type: alloc::collections::vec_deque::VecDeque<i32,alloc::alloc::Global>]
-// cdb-check:    [len]            : 0x2
+// cdb-check:    [len]            : 0x2 [Type: unsigned [...]]
 // cdb-check:    [capacity]       : 0x8 [Type: unsigned [...]]
 // cdb-check:    [0x0]            : 90 [Type: int]
 // cdb-check:    [0x1]            : 20 [Type: int]
@@ -175,7 +175,7 @@ fn main() {
     linkedlist.push_front(128);
 
     // VecDeque
-    let mut vecdeque = VecDeque::new();
+    let mut vecdeque = VecDeque::with_capacity(8);
     vecdeque.push_back(20);
     vecdeque.push_front(90);
 
diff --git a/src/test/ui/hygiene/panic-location.run.stderr b/src/test/ui/hygiene/panic-location.run.stderr
index 216b31586da..0b23b1cc2f4 100644
--- a/src/test/ui/hygiene/panic-location.run.stderr
+++ b/src/test/ui/hygiene/panic-location.run.stderr
@@ -1,2 +1,2 @@
-thread 'main' panicked at 'capacity overflow', $SRC_DIR/alloc/src/collections/vec_deque/mod.rs:LL:COL
+thread 'main' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:518:5
 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace