about summary refs log tree commit diff
path: root/src/libsyntax/codemap.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-01-05 14:51:03 +0000
committerbors <bors@rust-lang.org>2015-01-05 14:51:03 +0000
commit03268bbf35d3ff2350d987fe7b60375839abdf2e (patch)
tree86ecae7591630a6ccf7a69a47570577a0caea8c6 /src/libsyntax/codemap.rs
parent8e83af6e879535c33fd83d247d16619e39e0b951 (diff)
parent0cb7a4062a3c69bb0c54f0c9136889a1006e4f62 (diff)
downloadrust-03268bbf35d3ff2350d987fe7b60375839abdf2e.tar.gz
rust-03268bbf35d3ff2350d987fe7b60375839abdf2e.zip
auto merge of #20514 : alexcrichton/rust/serialize-associated-type, r=aturon
This commit moves the libserialize crate (and will force the hand of the
rustc-serialize crate) to not require the `old_orphan_check` feature gate as
well as using associated types wherever possible. Concretely, the following
changes were made:

* The error type of `Encoder` and `Decoder` is now an associated type, meaning
  that these traits have no type parameters.

* The `Encoder` and `Decoder` type parameters on the `Encodable` and `Decodable`
  traits have moved to the corresponding method of the trait. This movement
  alleviates the dependency on `old_orphan_check` but implies that
  implementations can no longer be specialized for the type of encoder/decoder
  being implemented.

Due to the trait definitions changing, this is a:

[breaking-change]
Diffstat (limited to 'src/libsyntax/codemap.rs')
-rw-r--r--src/libsyntax/codemap.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 2c7bbcb6faf..a49f2614cd7 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -120,6 +120,7 @@ impl PartialEq for Span {
 
 impl Eq for Span {}
 
+#[cfg(stage0)]
 impl<S:Encoder<E>, E> Encodable<S, E> for Span {
     /* Note #1972 -- spans are encoded but not decoded */
     fn encode(&self, s: &mut S) -> Result<(), E> {
@@ -127,12 +128,28 @@ impl<S:Encoder<E>, E> Encodable<S, E> for Span {
     }
 }
 
+#[cfg(not(stage0))]
+impl Encodable for Span {
+    /* Note #1972 -- spans are encoded but not decoded */
+    fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
+        s.emit_nil()
+    }
+}
+
+#[cfg(stage0)]
 impl<D:Decoder<E>, E> Decodable<D, E> for Span {
     fn decode(_d: &mut D) -> Result<Span, E> {
         Ok(DUMMY_SP)
     }
 }
 
+#[cfg(not(stage0))]
+impl Decodable for Span {
+    fn decode<D: Decoder>(_d: &mut D) -> Result<Span, D::Error> {
+        Ok(DUMMY_SP)
+    }
+}
+
 pub fn spanned<T>(lo: BytePos, hi: BytePos, t: T) -> Spanned<T> {
     respan(mk_sp(lo, hi), t)
 }