about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-27 14:35:49 -0700
committerbors <bors@rust-lang.org>2013-08-27 14:35:49 -0700
commit7f32ea8820727f4f4944423133e6b32e2653a1d2 (patch)
tree96ee20983cc3cf4c3ecad104554e4c65db8f9292
parent3ab0561b00d2993706d11bfbbce4a357110195dd (diff)
parent803f941867d1d68710f211535de69bb30f79f917 (diff)
downloadrust-7f32ea8820727f4f4944423133e6b32e2653a1d2.tar.gz
rust-7f32ea8820727f4f4944423133e6b32e2653a1d2.zip
auto merge of #8771 : thestinger/rust/repr, r=catamorphism
-rw-r--r--src/librustc/middle/ty.rs12
-rw-r--r--src/libstd/reflect.rs15
-rw-r--r--src/libstd/repr.rs85
-rw-r--r--src/libstd/unstable/intrinsics.rs3
-rw-r--r--src/libstd/vec.rs11
-rw-r--r--src/test/run-pass/fixed_length_vec_glue.rs2
-rw-r--r--src/test/run-pass/log-knows-the-names-of-variants-in-std.rs2
-rw-r--r--src/test/run-pass/log-knows-the-names-of-variants.rs2
-rw-r--r--src/test/run-pass/rec-align-u32.rs2
-rw-r--r--src/test/run-pass/rec-align-u64.rs2
-rw-r--r--src/test/run-pass/reflect-visit-data.rs18
-rw-r--r--src/test/run-pass/reflect-visit-type.rs3
-rw-r--r--src/test/run-pass/tag-align-shape.rs2
13 files changed, 76 insertions, 83 deletions
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index 6593e5632fb..2a3b5d8c963 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -3476,18 +3476,18 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
         terr_ptr_mutability => ~"pointers differ in mutability",
         terr_ref_mutability => ~"references differ in mutability",
         terr_ty_param_size(values) => {
-            fmt!("expected a type with %? type params \
-                  but found one with %? type params",
+            fmt!("expected a type with %u type params \
+                  but found one with %u type params",
                  values.expected, values.found)
         }
         terr_tuple_size(values) => {
-            fmt!("expected a tuple with %? elements \
-                  but found one with %? elements",
+            fmt!("expected a tuple with %u elements \
+                  but found one with %u elements",
                  values.expected, values.found)
         }
         terr_record_size(values) => {
-            fmt!("expected a record with %? fields \
-                  but found one with %? fields",
+            fmt!("expected a record with %u fields \
+                  but found one with %u fields",
                  values.expected, values.found)
         }
         terr_record_mutability => {
diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs
index 1d093c4c14b..56e0f83e05c 100644
--- a/src/libstd/reflect.rs
+++ b/src/libstd/reflect.rs
@@ -460,16 +460,6 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
         true
     }
 
-    fn visit_var(&self) -> bool {
-        if ! self.inner.visit_var() { return false; }
-        true
-    }
-
-    fn visit_var_integral(&self) -> bool {
-        if ! self.inner.visit_var_integral() { return false; }
-        true
-    }
-
     fn visit_param(&self, i: uint) -> bool {
         if ! self.inner.visit_param(i) { return false; }
         true
@@ -494,11 +484,6 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
         true
     }
 
-    fn visit_constr(&self, inner: *TyDesc) -> bool {
-        if ! self.inner.visit_constr(inner) { return false; }
-        true
-    }
-
     fn visit_closure_ptr(&self, ck: uint) -> bool {
         self.align_to::<@fn()>();
         if ! self.inner.visit_closure_ptr(ck) { return false; }
diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs
index 0218a0e7f3a..ad4658d2f42 100644
--- a/src/libstd/repr.rs
+++ b/src/libstd/repr.rs
@@ -75,35 +75,50 @@ impl Repr for bool {
     }
 }
 
-macro_rules! int_repr(($ty:ident) => (impl Repr for $ty {
+impl Repr for int {
+    fn write_repr(&self, writer: @Writer) {
+        do ::int::to_str_bytes(*self, 10u) |bits| {
+            writer.write(bits);
+        }
+    }
+}
+
+macro_rules! int_repr(($ty:ident, $suffix:expr) => (impl Repr for $ty {
     fn write_repr(&self, writer: @Writer) {
         do ::$ty::to_str_bytes(*self, 10u) |bits| {
             writer.write(bits);
+            writer.write(bytes!($suffix));
         }
     }
 }))
 
-int_repr!(int)
-int_repr!(i8)
-int_repr!(i16)
-int_repr!(i32)
-int_repr!(i64)
-int_repr!(uint)
-int_repr!(u8)
-int_repr!(u16)
-int_repr!(u32)
-int_repr!(u64)
-
-macro_rules! num_repr(($ty:ident) => (impl Repr for $ty {
+int_repr!(i8, "i8")
+int_repr!(i16, "i16")
+int_repr!(i32, "i32")
+int_repr!(i64, "i64")
+int_repr!(uint, "u")
+int_repr!(u8, "u8")
+int_repr!(u16, "u16")
+int_repr!(u32, "u32")
+int_repr!(u64, "u64")
+
+impl Repr for float {
+    fn write_repr(&self, writer: @Writer) {
+        let s = self.to_str();
+        writer.write(s.as_bytes());
+    }
+}
+
+macro_rules! num_repr(($ty:ident, $suffix:expr) => (impl Repr for $ty {
     fn write_repr(&self, writer: @Writer) {
         let s = self.to_str();
         writer.write(s.as_bytes());
+        writer.write(bytes!($suffix));
     }
 }))
 
-num_repr!(float)
-num_repr!(f32)
-num_repr!(f64)
+num_repr!(f32, "f32")
+num_repr!(f64, "f64")
 
 // New implementation using reflect::MovePtr
 
@@ -267,12 +282,14 @@ impl TyVisitor for ReprVisitor {
             self.write_escaped_slice(*s);
         }
     }
+
     fn visit_estr_uniq(&self) -> bool {
         do self.get::<~str> |s| {
             self.writer.write_char('~');
             self.write_escaped_slice(*s);
         }
     }
+
     fn visit_estr_slice(&self) -> bool {
         do self.get::<&str> |s| {
             self.write_escaped_slice(*s);
@@ -307,6 +324,7 @@ impl TyVisitor for ReprVisitor {
         }
     }
 
+    #[cfg(stage0)]
     fn visit_ptr(&self, _mtbl: uint, _inner: *TyDesc) -> bool {
         do self.get::<*c_void> |p| {
             self.writer.write_str(fmt!("(0x%x as *())",
@@ -314,6 +332,15 @@ impl TyVisitor for ReprVisitor {
         }
     }
 
+    #[cfg(not(stage0))]
+    fn visit_ptr(&self, mtbl: uint, _inner: *TyDesc) -> bool {
+        do self.get::<*c_void> |p| {
+            self.writer.write_str(fmt!("(0x%x as *", *p as uint));
+            self.write_mut_qualifier(mtbl);
+            self.writer.write_str("())");
+        }
+    }
+
     fn visit_rptr(&self, mtbl: uint, inner: *TyDesc) -> bool {
         self.writer.write_char('&');
         self.write_mut_qualifier(mtbl);
@@ -536,8 +563,6 @@ impl TyVisitor for ReprVisitor {
 
 
     fn visit_trait(&self) -> bool { true }
-    fn visit_var(&self) -> bool { true }
-    fn visit_var_integral(&self) -> bool { true }
     fn visit_param(&self, _i: uint) -> bool { true }
     fn visit_self(&self) -> bool { true }
     fn visit_type(&self) -> bool { true }
@@ -550,9 +575,6 @@ impl TyVisitor for ReprVisitor {
         }
     }
 
-    // Type no longer exists, vestigial function.
-    fn visit_constr(&self, _inner: *TyDesc) -> bool { fail!(); }
-
     fn visit_closure_ptr(&self, _ck: uint) -> bool { true }
 }
 
@@ -598,11 +620,14 @@ fn test_repr() {
     exact_test(&(&mut x), "&mut 10");
     exact_test(&(@mut [1, 2]), "@mut [1, 2]");
 
+    exact_test(&(0 as *()), "(0x0 as *())");
+    exact_test(&(0 as *mut ()), "(0x0 as *mut ())");
+
     exact_test(&(1,), "(1,)");
     exact_test(&(@[1,2,3,4,5,6,7,8]),
                "@[1, 2, 3, 4, 5, 6, 7, 8]");
     exact_test(&(@[1u8,2u8,3u8,4u8]),
-               "@[1, 2, 3, 4]");
+               "@[1u8, 2u8, 3u8, 4u8]");
     exact_test(&(@["hi", "there"]),
                "@[\"hi\", \"there\"]");
     exact_test(&(~["hi", "there"]),
@@ -615,14 +640,14 @@ fn test_repr() {
                "@{a: 10, b: 1.234}");
     exact_test(&(~P{a:10, b:1.234}),
                "~{a: 10, b: 1.234}");
-    exact_test(&(10_u8, ~"hello"),
-               "(10, ~\"hello\")");
-    exact_test(&(10_u16, ~"hello"),
-               "(10, ~\"hello\")");
-    exact_test(&(10_u32, ~"hello"),
-               "(10, ~\"hello\")");
-    exact_test(&(10_u64, ~"hello"),
-               "(10, ~\"hello\")");
+    exact_test(&(10u8, ~"hello"),
+               "(10u8, ~\"hello\")");
+    exact_test(&(10u16, ~"hello"),
+               "(10u16, ~\"hello\")");
+    exact_test(&(10u32, ~"hello"),
+               "(10u32, ~\"hello\")");
+    exact_test(&(10u64, ~"hello"),
+               "(10u64, ~\"hello\")");
 
     struct Foo;
     exact_test(&(~[Foo, Foo, Foo]), "~[{}, {}, {}]");
diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs
index 0642bb19737..796567bd561 100644
--- a/src/libstd/unstable/intrinsics.rs
+++ b/src/libstd/unstable/intrinsics.rs
@@ -161,13 +161,10 @@ pub trait TyVisitor {
                       n_inputs: uint, retstyle: uint) -> bool;
 
     fn visit_trait(&self) -> bool;
-    fn visit_var(&self) -> bool;
-    fn visit_var_integral(&self) -> bool;
     fn visit_param(&self, i: uint) -> bool;
     fn visit_self(&self) -> bool;
     fn visit_type(&self) -> bool;
     fn visit_opaque_box(&self) -> bool;
-    fn visit_constr(&self, inner: *TyDesc) -> bool;
     fn visit_closure_ptr(&self, ck: uint) -> bool;
 }
 
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 3e9c4b788fe..556842e6544 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -59,7 +59,7 @@ And much, much more.
 #[warn(non_camel_case_types)];
 
 use cast;
-use clone::Clone;
+use clone::{Clone, DeepClone};
 use container::{Container, Mutable};
 use cmp::{Eq, TotalOrd, Ordering, Less, Equal, Greater};
 use cmp;
@@ -2199,13 +2199,20 @@ pub mod bytes {
     }
 }
 
-impl<A:Clone> Clone for ~[A] {
+impl<A: Clone> Clone for ~[A] {
     #[inline]
     fn clone(&self) -> ~[A] {
         self.iter().map(|item| item.clone()).collect()
     }
 }
 
+impl<A: DeepClone> DeepClone for ~[A] {
+    #[inline]
+    fn deep_clone(&self) -> ~[A] {
+        self.iter().map(|item| item.deep_clone()).collect()
+    }
+}
+
 // This works because every lifetime is a sub-lifetime of 'static
 impl<'self, A> Zero for &'self [A] {
     fn zero() -> &'self [A] { &'self [] }
diff --git a/src/test/run-pass/fixed_length_vec_glue.rs b/src/test/run-pass/fixed_length_vec_glue.rs
index d026f041250..eb67c45ed00 100644
--- a/src/test/run-pass/fixed_length_vec_glue.rs
+++ b/src/test/run-pass/fixed_length_vec_glue.rs
@@ -16,5 +16,5 @@ pub fn main() {
     let arr = [1,2,3];
     let struc = Struc {a: 13u8, b: arr, c: 42};
     let s = sys::log_str(&struc);
-    assert_eq!(s, ~"{a: 13, b: [1, 2, 3], c: 42}");
+    assert_eq!(s, ~"{a: 13u8, b: [1, 2, 3], c: 42}");
 }
diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
index 5318e5ca348..ec048d13a18 100644
--- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
+++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
@@ -25,7 +25,7 @@ fn check_log<T>(exp: ~str, v: T) {
 
 pub fn main() {
     let x = list::from_vec([a(22u), b(~"hi")]);
-    let exp = ~"@Cons(a(22), @Cons(b(~\"hi\"), @Nil))";
+    let exp = ~"@Cons(a(22u), @Cons(b(~\"hi\"), @Nil))";
     let act = fmt!("%?", x);
     assert!(act == exp);
     check_log(exp, x);
diff --git a/src/test/run-pass/log-knows-the-names-of-variants.rs b/src/test/run-pass/log-knows-the-names-of-variants.rs
index 7a0d763f7e0..4727e61b1fd 100644
--- a/src/test/run-pass/log-knows-the-names-of-variants.rs
+++ b/src/test/run-pass/log-knows-the-names-of-variants.rs
@@ -19,7 +19,7 @@ enum bar {
 }
 
 pub fn main() {
-    assert_eq!(~"a(22)", fmt!("%?", a(22u)));
+    assert_eq!(~"a(22u)", fmt!("%?", a(22u)));
     assert_eq!(~"b(~\"hi\")", fmt!("%?", b(~"hi")));
     assert_eq!(~"c", fmt!("%?", c));
     assert_eq!(~"d", fmt!("%?", d));
diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs
index f475292093c..11aa2b85204 100644
--- a/src/test/run-pass/rec-align-u32.rs
+++ b/src/test/run-pass/rec-align-u32.rs
@@ -64,6 +64,6 @@ pub fn main() {
         // because `inner`s alignment was 4.
         assert_eq!(sys::size_of::<Outer>(), m::size());
 
-        assert_eq!(y, ~"{c8: 22, t: {c64: 44}}");
+        assert_eq!(y, ~"{c8: 22u8, t: {c64: 44u32}}");
     }
 }
diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs
index 571ad2f3fb2..cca2adc0873 100644
--- a/src/test/run-pass/rec-align-u64.rs
+++ b/src/test/run-pass/rec-align-u64.rs
@@ -86,6 +86,6 @@ pub fn main() {
         // because `Inner`s alignment was 4.
         assert_eq!(sys::size_of::<Outer>(), m::m::size());
 
-        assert_eq!(y, ~"{c8: 22, t: {c64: 44}}");
+        assert_eq!(y, ~"{c8: 22u8, t: {c64: 44u64}}");
     }
 }
diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs
index 72bdc2ee0a6..b56cef4277f 100644
--- a/src/test/run-pass/reflect-visit-data.rs
+++ b/src/test/run-pass/reflect-visit-data.rs
@@ -436,16 +436,6 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> {
         true
     }
 
-    fn visit_var(&self) -> bool {
-        if ! self.inner.visit_var() { return false; }
-        true
-    }
-
-    fn visit_var_integral(&self) -> bool {
-        if ! self.inner.visit_var_integral() { return false; }
-        true
-    }
-
     fn visit_param(&self, i: uint) -> bool {
         if ! self.inner.visit_param(i) { return false; }
         true
@@ -470,11 +460,6 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> {
         true
     }
 
-    fn visit_constr(&self, inner: *TyDesc) -> bool {
-        if ! self.inner.visit_constr(inner) { return false; }
-        true
-    }
-
     fn visit_closure_ptr(&self, ck: uint) -> bool {
         self.align_to::<@fn()>();
         if ! self.inner.visit_closure_ptr(ck) { return false; }
@@ -633,13 +618,10 @@ impl TyVisitor for my_visitor {
 
 
     fn visit_trait(&self) -> bool { true }
-    fn visit_var(&self) -> bool { true }
-    fn visit_var_integral(&self) -> bool { true }
     fn visit_param(&self, _i: uint) -> bool { true }
     fn visit_self(&self) -> bool { true }
     fn visit_type(&self) -> bool { true }
     fn visit_opaque_box(&self) -> bool { true }
-    fn visit_constr(&self, _inner: *TyDesc) -> bool { true }
     fn visit_closure_ptr(&self, _ck: uint) -> bool { true }
 }
 
diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs
index 544f42eb69f..1462d8aace1 100644
--- a/src/test/run-pass/reflect-visit-type.rs
+++ b/src/test/run-pass/reflect-visit-type.rs
@@ -144,13 +144,10 @@ impl TyVisitor for MyVisitor {
 
 
     fn visit_trait(&self) -> bool { true }
-    fn visit_var(&self) -> bool { true }
-    fn visit_var_integral(&self) -> bool { true }
     fn visit_param(&self, _i: uint) -> bool { true }
     fn visit_self(&self) -> bool { true }
     fn visit_type(&self) -> bool { true }
     fn visit_opaque_box(&self) -> bool { true }
-    fn visit_constr(&self, _inner: *TyDesc) -> bool { true }
     fn visit_closure_ptr(&self, _ck: uint) -> bool { true }
 }
 
diff --git a/src/test/run-pass/tag-align-shape.rs b/src/test/run-pass/tag-align-shape.rs
index f86c134eef2..cb93cea2895 100644
--- a/src/test/run-pass/tag-align-shape.rs
+++ b/src/test/run-pass/tag-align-shape.rs
@@ -21,5 +21,5 @@ pub fn main() {
     let x = t_rec {c8: 22u8, t: a_tag(44u64)};
     let y = fmt!("%?", x);
     info!("y = %s", y);
-    assert_eq!(y, ~"{c8: 22, t: a_tag(44)}");
+    assert_eq!(y, ~"{c8: 22u8, t: a_tag(44u64)}");
 }