about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-11-28 11:36:04 -0800
committerPatrick Walton <pcwalton@mimiga.net>2012-11-28 11:36:04 -0800
commit669fbddc4435a9ab152332df06a7fcca789c8059 (patch)
treedf3bf0ffa9a9a77d538d6050a183275e3cd3e5c1 /src/libsyntax
parent430583c8b4efdccb19e87b2f312fc22118c6685c (diff)
librustc: Add explicit self to IterBytes. r=nmatsakis
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs128
-rw-r--r--src/libsyntax/ast_util.rs9
-rw-r--r--src/libsyntax/codemap.rs17
-rw-r--r--src/libsyntax/ext/deriving.rs3
-rw-r--r--src/libsyntax/parse/obsolete.rs9
5 files changed, 165 insertions, 1 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index c277aee27de..d09dd6f7bd1 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -62,12 +62,21 @@ impl ident: cmp::Eq {
     pure fn ne(&self, other: &ident) -> bool { !(*self).eq(other) }
 }
 
+#[cfg(stage0)]
 impl ident: to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         self.repr.iter_bytes(lsb0, f)
     }
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ident: to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        self.repr.iter_bytes(lsb0, f)
+    }
+}
+
 // Functions may or may not have names.
 type fn_ident = Option<ident>;
 
@@ -462,6 +471,7 @@ enum binding_mode {
     bind_by_implicit_ref
 }
 
+#[cfg(stage0)]
 impl binding_mode : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         match self {
@@ -478,6 +488,24 @@ impl binding_mode : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl binding_mode : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        match *self {
+          bind_by_value => 0u8.iter_bytes(lsb0, f),
+
+          bind_by_move => 1u8.iter_bytes(lsb0, f),
+
+          bind_by_ref(ref m) =>
+          to_bytes::iter_bytes_2(&2u8, m, lsb0, f),
+
+          bind_by_implicit_ref =>
+          3u8.iter_bytes(lsb0, f),
+        }
+    }
+}
+
 impl binding_mode : cmp::Eq {
     #[cfg(stage0)]
     pure fn eq(other: &binding_mode) -> bool {
@@ -573,12 +601,21 @@ enum pat_ {
 #[auto_deserialize]
 enum mutability { m_mutbl, m_imm, m_const, }
 
+#[cfg(stage0)]
 impl mutability : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as u8).iter_bytes(lsb0, f)
     }
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mutability : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as u8).iter_bytes(lsb0, f)
+    }
+}
+
 impl mutability : cmp::Eq {
     #[cfg(stage0)]
     pure fn eq(other: &mutability) -> bool {
@@ -622,12 +659,21 @@ impl Proto : cmp::Eq {
     pure fn ne(&self, other: &Proto) -> bool { !(*self).eq(other) }
 }
 
+#[cfg(stage0)]
 impl Proto : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as uint).iter_bytes(lsb0, f);
     }
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Proto : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as uint).iter_bytes(lsb0, f);
+    }
+}
+
 #[auto_serialize]
 #[auto_deserialize]
 enum vstore {
@@ -798,6 +844,7 @@ enum inferable<T> {
     infer(node_id)
 }
 
+#[cfg(stage0)]
 impl<T: to_bytes::IterBytes> inferable<T> : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         match self {
@@ -810,6 +857,20 @@ impl<T: to_bytes::IterBytes> inferable<T> : to_bytes::IterBytes {
     }
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: to_bytes::IterBytes> inferable<T> : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        match *self {
+          expl(ref t) =>
+          to_bytes::iter_bytes_2(&0u8, t, lsb0, f),
+
+          infer(ref n) =>
+          to_bytes::iter_bytes_2(&1u8, n, lsb0, f),
+        }
+    }
+}
+
 impl<T:cmp::Eq> inferable<T> : cmp::Eq {
     #[cfg(stage0)]
     pure fn eq(other: &inferable<T>) -> bool {
@@ -858,11 +919,19 @@ impl<T:cmp::Eq> inferable<T> : cmp::Eq {
 #[auto_deserialize]
 enum rmode { by_ref, by_val, by_move, by_copy }
 
+#[cfg(stage0)]
 impl rmode : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as u8).iter_bytes(lsb0, f)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl rmode : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as u8).iter_bytes(lsb0, f)
+    }
+}
 
 
 impl rmode : cmp::Eq {
@@ -1262,11 +1331,19 @@ enum trait_method {
 #[auto_deserialize]
 enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
 
+#[cfg(stage0)]
 impl int_ty : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as u8).iter_bytes(lsb0, f)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl int_ty : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as u8).iter_bytes(lsb0, f)
+    }
+}
 
 impl int_ty : cmp::Eq {
     #[cfg(stage0)]
@@ -1315,11 +1392,19 @@ impl int_ty : cmp::Eq {
 #[auto_deserialize]
 enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
 
+#[cfg(stage0)]
 impl uint_ty : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as u8).iter_bytes(lsb0, f)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl uint_ty : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as u8).iter_bytes(lsb0, f)
+    }
+}
 
 impl uint_ty : cmp::Eq {
     #[cfg(stage0)]
@@ -1364,11 +1449,20 @@ impl uint_ty : cmp::Eq {
 #[auto_deserialize]
 enum float_ty { ty_f, ty_f32, ty_f64, }
 
+#[cfg(stage0)]
 impl float_ty : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as u8).iter_bytes(lsb0, f)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl float_ty : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as u8).iter_bytes(lsb0, f)
+    }
+}
+
 impl float_ty : cmp::Eq {
     #[cfg(stage0)]
     pure fn eq(other: &float_ty) -> bool {
@@ -1589,12 +1683,21 @@ impl Ty : cmp::Eq {
     }
 }
 
+#[cfg(stage0)]
 impl Ty : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f);
     }
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Ty : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f);
+    }
+}
+
 
 #[auto_serialize]
 #[auto_deserialize]
@@ -1616,12 +1719,21 @@ enum purity {
     extern_fn, // declared with "extern fn"
 }
 
+#[cfg(stage0)]
 impl purity : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as u8).iter_bytes(lsb0, f)
     }
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl purity : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as u8).iter_bytes(lsb0, f)
+    }
+}
+
 impl purity : cmp::Eq {
     #[cfg(stage0)]
     pure fn eq(other: &purity) -> bool {
@@ -1647,11 +1759,19 @@ enum ret_style {
     return_val, // everything else
 }
 
+#[cfg(stage0)]
 impl ret_style : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as u8).iter_bytes(lsb0, f)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ret_style : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as u8).iter_bytes(lsb0, f)
+    }
+}
 
 impl ret_style : cmp::Eq {
     #[cfg(stage0)]
@@ -2152,11 +2272,19 @@ enum item_ {
 #[auto_deserialize]
 enum class_mutability { class_mutable, class_immutable }
 
+#[cfg(stage0)]
 impl class_mutability : to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as u8).iter_bytes(lsb0, f)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl class_mutability : to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as u8).iter_bytes(lsb0, f)
+    }
+}
 
 impl class_mutability : cmp::Eq {
     #[cfg(stage0)]
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 73a1c4b7530..12ebca87a80 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -251,12 +251,21 @@ pure fn is_call_expr(e: @expr) -> bool {
 }
 
 // This makes def_id hashable
+#[cfg(stage0)]
 impl def_id : core::to_bytes::IterBytes {
     #[inline(always)]
     pure fn iter_bytes(+lsb0: bool, f: core::to_bytes::Cb) {
         core::to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f);
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl def_id : core::to_bytes::IterBytes {
+    #[inline(always)]
+    pure fn iter_bytes(&self, +lsb0: bool, f: core::to_bytes::Cb) {
+        core::to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f);
+    }
+}
 
 fn block_from_expr(e: @expr) -> blk {
     let blk_ = default_block(~[], option::Some::<@expr>(e), e.id);
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index fafcd09e3dc..2280986ab94 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -90,12 +90,21 @@ impl BytePos: Num {
     static pure fn from_int(+n: int) -> BytePos { BytePos(n as uint) }
 }
 
+#[cfg(stage0)]
 impl BytePos: to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (*self).iter_bytes(lsb0, f)
     }
 }
 
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl BytePos: to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (**self).iter_bytes(lsb0, f)
+    }
+}
+
 impl CharPos: Pos {
     static pure fn from_uint(n: uint) -> CharPos { CharPos(n) }
     pure fn to_uint(&self) -> uint { **self }
@@ -154,11 +163,19 @@ impl CharPos: Num {
     static pure fn from_int(+n: int) -> CharPos { CharPos(n as uint) }
 }
 
+#[cfg(stage0)]
 impl CharPos: to_bytes::IterBytes {
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (*self).iter_bytes(lsb0, f)
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl CharPos: to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (**self).iter_bytes(lsb0, f)
+    }
+}
 
 /**
 Spans represent a region of code, used for error reporting. Positions in spans
diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs
index 4a92086963e..829b53ae22a 100644
--- a/src/libsyntax/ext/deriving.rs
+++ b/src/libsyntax/ext/deriving.rs
@@ -292,7 +292,7 @@ fn create_iter_bytes_method(cx: ext_ctxt,
     let body_block = build::mk_block_(cx, span, move statements);
 
     // Create the method.
-    let self_ty = { node: sty_by_ref, span: span };
+    let self_ty = { node: sty_region(m_imm), span: span };
     let method_ident = cx.ident_of(~"iter_bytes");
     return @{
         ident: method_ident,
@@ -806,6 +806,7 @@ fn expand_deriving_iter_bytes_enum_method(cx: ext_ctxt,
     // Create the method body.
     let self_ident = cx.ident_of(~"self");
     let self_expr = build::mk_path(cx, span, ~[ self_ident ]);
+    let self_expr = build::mk_unary(cx, span, deref, self_expr);
     let arms = dvec::unwrap(move arms);
     let self_match_expr = expr_match(self_expr, move arms);
     let self_match_expr = build::mk_expr(cx, span, move self_match_expr);
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 40df4d5f7d4..a6a7736e3d0 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -49,12 +49,21 @@ impl ObsoleteSyntax : cmp::Eq {
     }
 }
 
+#[cfg(stage0)]
 impl ObsoleteSyntax: to_bytes::IterBytes {
     #[inline(always)]
     pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
         (self as uint).iter_bytes(lsb0, f);
     }
 }
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ObsoleteSyntax: to_bytes::IterBytes {
+    #[inline(always)]
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (*self as uint).iter_bytes(lsb0, f);
+    }
+}
 
 pub trait ObsoleteReporter {
     fn obsolete(sp: span, kind: ObsoleteSyntax);