Skip to content

Commit 531ecf3

Browse files
committed
---
yaml --- r: 64192 b: refs/heads/snap-stage3 c: 9b5d523 h: refs/heads/master v: v3
1 parent 91e4ac4 commit 531ecf3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: e7040e8a249a8cd53931603b89e0d12b0b854398
4+
refs/heads/snap-stage3: 9b5d52312622fb301d9e102b3eeca5a7afcdeb9b
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/repr.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,13 @@ impl ReprVisitor {
206206
inner: *TyDesc)
207207
-> bool {
208208
let mut p = ptr;
209-
let end = ptr::offset(p, len);
210209
let (sz, al) = unsafe { ((*inner).size, (*inner).align) };
211210
self.writer.write_char('[');
212211
let mut first = true;
213-
while (p as uint) < (end as uint) {
212+
let mut left = len;
213+
// unit structs have 0 size, and don't loop forever.
214+
let dec = if sz == 0 {1} else {sz};
215+
while left > 0 {
214216
if first {
215217
first = false;
216218
} else {
@@ -219,6 +221,7 @@ impl ReprVisitor {
219221
self.write_mut_qualifier(mtbl);
220222
self.visit_ptr_inner(p as *c_void, inner);
221223
p = align(ptr::offset(p, sz) as uint, al) as *u8;
224+
left -= dec;
222225
}
223226
self.writer.write_char(']');
224227
true
@@ -635,4 +638,7 @@ fn test_repr() {
635638
"(10, ~\"hello\")");
636639
exact_test(&(10_u64, ~"hello"),
637640
"(10, ~\"hello\")");
641+
642+
struct Foo;
643+
exact_test(&(~[Foo, Foo, Foo]), "~[{}, {}, {}]");
638644
}

0 commit comments

Comments
 (0)