about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mk/crates.mk13
-rw-r--r--src/doc/index.md5
-rw-r--r--src/libextra/dlist.rs27
-rw-r--r--src/libextra/json.rs22
-rw-r--r--src/libextra/lib.rs13
-rw-r--r--src/libextra/ringbuf.rs27
-rw-r--r--src/libextra/treemap.rs67
-rw-r--r--src/librustc/lib.rs1
-rw-r--r--src/librustc/metadata/csearch.rs2
-rw-r--r--src/librustc/metadata/decoder.rs6
-rw-r--r--src/librustc/metadata/encoder.rs4
-rw-r--r--src/librustc/middle/astencode.rs12
-rw-r--r--src/librustdoc/lib.rs3
-rw-r--r--src/libserialize/ebml.rs (renamed from src/libextra/ebml.rs)28
-rw-r--r--src/libserialize/lib.rs33
-rw-r--r--src/libserialize/serialize.rs (renamed from src/libextra/serialize.rs)125
-rw-r--r--src/libsyntax/ast.rs5
-rw-r--r--src/libsyntax/codemap.rs2
-rw-r--r--src/libsyntax/ext/deriving/decodable.rs7
-rw-r--r--src/libsyntax/ext/deriving/encodable.rs6
-rw-r--r--src/libsyntax/ext/deriving/generic.rs2
-rw-r--r--src/libsyntax/lib.rs1
-rw-r--r--src/libsyntax/parse/mod.rs2
-rw-r--r--src/libsyntax/parse/token.rs2
-rw-r--r--src/libuuid/lib.rs9
-rw-r--r--src/test/run-pass/auto-encode.rs2
-rw-r--r--src/test/run-pass/deriving-encodable-decodable.rs10
-rw-r--r--src/test/run-pass/deriving-global.rs2
-rw-r--r--src/test/run-pass/issue-4016.rs5
-rw-r--r--src/test/run-pass/issue-4036.rs9
30 files changed, 259 insertions, 193 deletions
diff --git a/mk/crates.mk b/mk/crates.mk
index dd94d268bec..ea573b9db8d 100644
--- a/mk/crates.mk
+++ b/mk/crates.mk
@@ -49,25 +49,26 @@
 # automatically generated for all stage/host/target combinations.
 ################################################################################
 
-TARGET_CRATES := std extra green rustuv native flate arena glob term semver uuid sync
+TARGET_CRATES := std extra green rustuv native flate arena glob term semver uuid serialize sync
 HOST_CRATES := syntax rustc rustdoc
 CRATES := $(TARGET_CRATES) $(HOST_CRATES)
 TOOLS := compiletest rustdoc rustc
 
 DEPS_std := native:rustrt
-DEPS_extra := std term sync
+DEPS_extra := std serialize sync term
 DEPS_green := std
 DEPS_rustuv := std native:uv native:uv_support
 DEPS_native := std
-DEPS_syntax := std extra term
-DEPS_rustc := syntax native:rustllvm flate arena sync
-DEPS_rustdoc := rustc native:sundown sync
+DEPS_syntax := std extra term serialize
+DEPS_rustc := syntax native:rustllvm flate arena serialize sync
+DEPS_rustdoc := rustc native:sundown serialize sync
 DEPS_flate := std native:miniz
 DEPS_arena := std extra
 DEPS_glob := std
+DEPS_serialize := std
 DEPS_term := std
 DEPS_semver := std
-DEPS_uuid := std extra
+DEPS_uuid := std serialize
 DEPS_sync := std
 
 TOOL_DEPS_compiletest := extra green rustuv
diff --git a/src/doc/index.md b/src/doc/index.md
index 5aa92c9fec4..54b8b484693 100644
--- a/src/doc/index.md
+++ b/src/doc/index.md
@@ -41,9 +41,10 @@ li {list-style-type: none; }
 * [The `flate` compression library](flate/index.html)
 * [The `glob` file path matching library](glob/index.html)
 * [The `semver` version collation library](semver/index.html)
-* [The `term` terminal-handling library](term/index.html)
-* [The UUID library](uuid/index.html)
+* [The `serialize` value encoding/decoding library](serialize/index.html)
 * [The `sync` library for concurrency-enabled mechanisms and primitives](sync/index.html)
+* [The `term` terminal-handling library](term/index.html)
+* [The `uuid` 128-bit universally unique identifier library](uuid/index.html)
 
 # Tooling
 
diff --git a/src/libextra/dlist.rs b/src/libextra/dlist.rs
index ee80fa1c4c4..88df73845d0 100644
--- a/src/libextra/dlist.rs
+++ b/src/libextra/dlist.rs
@@ -30,6 +30,8 @@ use std::iter;
 
 use container::Deque;
 
+use serialize::{Encodable, Decodable, Encoder, Decoder};
+
 /// A doubly-linked list.
 pub struct DList<T> {
     priv length: uint,
@@ -628,6 +630,31 @@ impl<A: Clone> Clone for DList<A> {
     }
 }
 
+impl<
+    S: Encoder,
+    T: Encodable<S>
+> Encodable<S> for DList<T> {
+    fn encode(&self, s: &mut S) {
+        s.emit_seq(self.len(), |s| {
+            for (i, e) in self.iter().enumerate() {
+                s.emit_seq_elt(i, |s| e.encode(s));
+            }
+        })
+    }
+}
+
+impl<D:Decoder,T:Decodable<D>> Decodable<D> for DList<T> {
+    fn decode(d: &mut D) -> DList<T> {
+        let mut list = DList::new();
+        d.read_seq(|d, len| {
+            for i in range(0u, len) {
+                list.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
+            }
+        });
+        list
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use container::Deque;
diff --git a/src/libextra/json.rs b/src/libextra/json.rs
index ef8e0999521..8b082bf3056 100644
--- a/src/libextra/json.rs
+++ b/src/libextra/json.rs
@@ -51,17 +51,18 @@ A simple JSON document encoding a person, his/her age, address and phone numbers
 
 Rust provides a mechanism for low boilerplate encoding & decoding
 of values to and from JSON via the serialization API.
-To be able to encode a piece of data, it must implement the `extra::serialize::Encodable` trait.
-To be able to decode a piece of data, it must implement the `extra::serialize::Decodable` trait.
+To be able to encode a piece of data, it must implement the `serialize::Encodable` trait.
+To be able to decode a piece of data, it must implement the `serialize::Decodable` trait.
 The Rust compiler provides an annotation to automatically generate
 the code for these traits: `#[deriving(Decodable, Encodable)]`
 
 To encode using Encodable :
 
 ```rust
+extern mod serialize;
 use extra::json;
 use std::io;
-use extra::serialize::Encodable;
+use serialize::Encodable;
 
  #[deriving(Encodable)]
  pub struct TestStruct   {
@@ -125,7 +126,8 @@ fn main() {
 To decode a json string using `Decodable` trait :
 
 ```rust
-use extra::serialize::Decodable;
+extern mod serialize;
+use serialize::Decodable;
 
 #[deriving(Decodable)]
 pub struct MyStruct  {
@@ -150,8 +152,9 @@ Create a struct called TestStruct1 and serialize and deserialize it to and from
 using the serialization API, using the derived serialization code.
 
 ```rust
+extern mod serialize;
 use extra::json;
-use extra::serialize::{Encodable, Decodable};
+use serialize::{Encodable, Decodable};
 
  #[deriving(Decodable, Encodable)] //generate Decodable, Encodable impl.
  pub struct TestStruct1  {
@@ -181,9 +184,10 @@ This example use the ToJson impl to unserialize the json string.
 Example of `ToJson` trait implementation for TestStruct1.
 
 ```rust
+extern mod serialize;
 use extra::json;
 use extra::json::ToJson;
-use extra::serialize::{Encodable, Decodable};
+use serialize::{Encodable, Decodable};
 use extra::treemap::TreeMap;
 
 #[deriving(Decodable, Encodable)] // generate Decodable, Encodable impl.
@@ -312,7 +316,7 @@ impl<'a> Encoder<'a> {
     }
 
     /// Encode the specified struct into a json [u8]
-    pub fn buffer_encode<T:Encodable<Encoder<'a>>>(to_encode_object: &T) -> ~[u8]  {
+    pub fn buffer_encode<T:serialize::Encodable<Encoder<'a>>>(to_encode_object: &T) -> ~[u8]  {
        //Serialize the object in a string using a writer
         let mut m = MemWriter::new();
         {
@@ -323,7 +327,7 @@ impl<'a> Encoder<'a> {
     }
 
     /// Encode the specified struct into a json str
-    pub fn str_encode<T:Encodable<Encoder<'a>>>(to_encode_object: &T) -> ~str  {
+    pub fn str_encode<T:serialize::Encodable<Encoder<'a>>>(to_encode_object: &T) -> ~str  {
         let buff:~[u8] = Encoder::buffer_encode(to_encode_object);
         str::from_utf8_owned(buff).unwrap()
     }
@@ -684,7 +688,7 @@ impl<E: serialize::Encoder> serialize::Encodable<E> for Json {
     }
 }
 
-impl Json{
+impl Json {
     /// Encodes a json value into a io::writer.  Uses a single line.
     pub fn to_writer(&self, wr: &mut io::Writer) -> io::IoResult<()> {
         let mut encoder = Encoder::new(wr);
diff --git a/src/libextra/lib.rs b/src/libextra/lib.rs
index 401ece64a5d..37b4d3cc524 100644
--- a/src/libextra/lib.rs
+++ b/src/libextra/lib.rs
@@ -35,6 +35,17 @@ Rust extras are part of the standard Rust distribution.
 #[deny(missing_doc)];
 
 extern mod sync;
+#[cfg(not(stage0))]
+extern mod serialize;
+
+#[cfg(stage0)]
+pub mod serialize {
+    #[allow(missing_doc)];
+    // Temp re-export until after a snapshot
+    extern mod serialize = "serialize";
+    pub use self::serialize::{Encoder, Decoder, Encodable, Decodable,
+                                   EncoderHelpers, DecoderHelpers};
+}
 
 #[cfg(stage0)]
 macro_rules! if_ok (
@@ -62,7 +73,6 @@ pub mod lru_cache;
 // And ... other stuff
 
 pub mod url;
-pub mod ebml;
 pub mod getopts;
 pub mod json;
 pub mod tempfile;
@@ -85,7 +95,6 @@ mod unicode;
 // Compiler support modules
 
 pub mod test;
-pub mod serialize;
 
 // A curious inner-module that's not exported that contains the binding
 // 'extra' so that macro-expanded references to extra::serialize and such
diff --git a/src/libextra/ringbuf.rs b/src/libextra/ringbuf.rs
index 4da35942935..17631f5bdff 100644
--- a/src/libextra/ringbuf.rs
+++ b/src/libextra/ringbuf.rs
@@ -19,6 +19,8 @@ use std::iter::{Rev, RandomAccessIterator};
 
 use container::Deque;
 
+use serialize::{Encodable, Decodable, Encoder, Decoder};
+
 static INITIAL_CAPACITY: uint = 8u; // 2^3
 static MINIMUM_CAPACITY: uint = 2u;
 
@@ -402,6 +404,31 @@ impl<A> Extendable<A> for RingBuf<A> {
     }
 }
 
+impl<
+    S: Encoder,
+    T: Encodable<S>
+> Encodable<S> for RingBuf<T> {
+    fn encode(&self, s: &mut S) {
+        s.emit_seq(self.len(), |s| {
+            for (i, e) in self.iter().enumerate() {
+                s.emit_seq_elt(i, |s| e.encode(s));
+            }
+        })
+    }
+}
+
+impl<D:Decoder,T:Decodable<D>> Decodable<D> for RingBuf<T> {
+    fn decode(d: &mut D) -> RingBuf<T> {
+        let mut deque = RingBuf::new();
+        d.read_seq(|d, len| {
+            for i in range(0u, len) {
+                deque.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
+            }
+        });
+        deque
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use container::Deque;
diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs
index 6605ea00c44..449e72dd0ec 100644
--- a/src/libextra/treemap.rs
+++ b/src/libextra/treemap.rs
@@ -17,6 +17,8 @@ use std::iter::{Peekable};
 use std::cmp::Ordering;
 use std::ptr;
 
+use serialize::{Encodable, Decodable, Encoder, Decoder};
+
 // This is implemented as an AA tree, which is a simplified variation of
 // a red-black tree where red (horizontal) nodes can only be added
 // as a right child. The time complexity is the same, and re-balancing
@@ -1004,6 +1006,71 @@ impl<T: TotalOrd> Extendable<T> for TreeSet<T> {
     }
 }
 
+impl<
+    E: Encoder,
+    K: Encodable<E> + Eq + TotalOrd,
+    V: Encodable<E> + Eq
+> Encodable<E> for TreeMap<K, V> {
+    fn encode(&self, e: &mut E) {
+        e.emit_map(self.len(), |e| {
+            let mut i = 0;
+            for (key, val) in self.iter() {
+                e.emit_map_elt_key(i, |e| key.encode(e));
+                e.emit_map_elt_val(i, |e| val.encode(e));
+                i += 1;
+            }
+        })
+    }
+}
+
+impl<
+    D: Decoder,
+    K: Decodable<D> + Eq + TotalOrd,
+    V: Decodable<D> + Eq
+> Decodable<D> for TreeMap<K, V> {
+    fn decode(d: &mut D) -> TreeMap<K, V> {
+        d.read_map(|d, len| {
+            let mut map = TreeMap::new();
+            for i in range(0u, len) {
+                let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
+                let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
+                map.insert(key, val);
+            }
+            map
+        })
+    }
+}
+
+impl<
+    S: Encoder,
+    T: Encodable<S> + Eq + TotalOrd
+> Encodable<S> for TreeSet<T> {
+    fn encode(&self, s: &mut S) {
+        s.emit_seq(self.len(), |s| {
+            let mut i = 0;
+            for e in self.iter() {
+                s.emit_seq_elt(i, |s| e.encode(s));
+                i += 1;
+            }
+        })
+    }
+}
+
+impl<
+    D: Decoder,
+    T: Decodable<D> + Eq + TotalOrd
+> Decodable<D> for TreeSet<T> {
+    fn decode(d: &mut D) -> TreeSet<T> {
+        d.read_seq(|d, len| {
+            let mut set = TreeSet::new();
+            for i in range(0u, len) {
+                set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
+            }
+            set
+        })
+    }
+}
+
 #[cfg(test)]
 mod test_treemap {
 
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index d4a6c29752d..52ddc8c8108 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -35,6 +35,7 @@ extern mod extra;
 extern mod flate;
 extern mod arena;
 extern mod syntax;
+extern mod serialize;
 extern mod sync;
 
 use back::link;
diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs
index 1a65b326bbd..8a6ba824dcb 100644
--- a/src/librustc/metadata/csearch.rs
+++ b/src/librustc/metadata/csearch.rs
@@ -18,8 +18,8 @@ use middle::ty;
 use middle::typeck;
 
 use std::vec;
+use reader = serialize::ebml::reader;
 use std::rc::Rc;
-use reader = extra::ebml::reader;
 use syntax::ast;
 use syntax::ast_map;
 use syntax::diagnostic::expect;
diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs
index 8ba98e84dfa..d18017d0043 100644
--- a/src/librustc/metadata/decoder.rs
+++ b/src/librustc/metadata/decoder.rs
@@ -31,9 +31,9 @@ use std::io::extensions::u64_from_be_bytes;
 use std::option;
 use std::rc::Rc;
 use std::vec;
-use extra::ebml::reader;
-use extra::ebml;
-use extra::serialize::Decodable;
+use serialize::ebml::reader;
+use serialize::ebml;
+use serialize::Decodable;
 use syntax::ast_map;
 use syntax::attr;
 use syntax::parse::token::{IdentInterner, special_idents};
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index d56d211b713..ba33f57309f 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -22,7 +22,7 @@ use middle::ty;
 use middle::typeck;
 use middle;
 
-use extra::serialize::Encodable;
+use serialize::Encodable;
 use std::cast;
 use std::cell::{Cell, RefCell};
 use std::hashmap::{HashMap, HashSet};
@@ -45,7 +45,7 @@ use syntax::parse::token;
 use syntax::visit::Visitor;
 use syntax::visit;
 use syntax;
-use writer = extra::ebml::writer;
+use writer = serialize::ebml::writer;
 
 // used by astencode:
 type abbrev_map = @RefCell<HashMap<ty::t, tyencode::ty_abbrev>>;
diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs
index 29ea3475d34..8adbd37462b 100644
--- a/src/librustc/middle/astencode.rs
+++ b/src/librustc/middle/astencode.rs
@@ -37,12 +37,12 @@ use std::cast;
 use std::io::Seek;
 use std::rc::Rc;
 
-use extra::ebml::reader;
-use extra::ebml;
-use extra::serialize;
-use extra::serialize::{Encoder, Encodable, EncoderHelpers, DecoderHelpers};
-use extra::serialize::{Decoder, Decodable};
-use writer = extra::ebml::writer;
+use serialize::ebml::reader;
+use serialize::ebml;
+use serialize;
+use serialize::{Encoder, Encodable, EncoderHelpers, DecoderHelpers};
+use serialize::{Decoder, Decodable};
+use writer = serialize::ebml::writer;
 
 #[cfg(test)] use syntax::parse;
 #[cfg(test)] use syntax::print::pprust;
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index bf096a7e49b..7256e8923fa 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -18,6 +18,7 @@
 extern mod syntax;
 extern mod rustc;
 extern mod extra;
+extern mod serialize;
 extern mod sync;
 
 use std::local_data;
@@ -27,7 +28,7 @@ use std::str;
 use extra::getopts;
 use extra::getopts::groups;
 use extra::json;
-use extra::serialize::{Decodable, Encodable};
+use serialize::{Decodable, Encodable};
 use extra::time;
 
 pub mod clean;
diff --git a/src/libextra/ebml.rs b/src/libserialize/ebml.rs
index 1900313ab6c..9d1c099c6f0 100644
--- a/src/libextra/ebml.rs
+++ b/src/libserialize/ebml.rs
@@ -83,15 +83,19 @@ pub enum EbmlEncoderTag {
 
 pub mod reader {
     use std::char;
-    use super::*;
-
-    use serialize;
 
     use std::cast::transmute;
     use std::int;
     use std::option::{None, Option, Some};
     use std::io::extensions::u64_from_be_bytes;
 
+    use serialize;
+
+    use super::{ EsVec, EsMap, EsEnum, EsVecLen, EsVecElt, EsMapLen, EsMapKey,
+        EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64, EsI32, EsI16, EsI8,
+        EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal, EsEnumBody, EsUint,
+        EsOpaque, EsLabel, EbmlEncoderTag, Doc, TaggedDoc };
+
     // ebml reading
 
     pub struct Res {
@@ -588,8 +592,6 @@ pub mod reader {
 }
 
 pub mod writer {
-    use super::*;
-
     use std::cast;
     use std::clone::Clone;
     use std::io;
@@ -597,6 +599,13 @@ pub mod writer {
     use std::io::MemWriter;
     use std::io::extensions::u64_to_be_bytes;
 
+    use super::{ EsVec, EsMap, EsEnum, EsVecLen, EsVecElt, EsMapLen, EsMapKey,
+        EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64, EsI32, EsI16, EsI8,
+        EsBool, EsF64, EsF32, EsChar, EsStr, EsMapVal, EsEnumBody, EsUint,
+        EsOpaque, EsLabel, EbmlEncoderTag };
+
+    use serialize;
+
     // ebml writing
     pub struct Encoder<'a> {
         // FIXME(#5665): this should take a trait object. Note that if you
@@ -775,7 +784,7 @@ pub mod writer {
         }
     }
 
-    impl<'a> ::serialize::Encoder for Encoder<'a> {
+    impl<'a> serialize::Encoder for Encoder<'a> {
         fn emit_nil(&mut self) {}
 
         fn emit_uint(&mut self, v: uint) {
@@ -952,8 +961,7 @@ pub mod writer {
 mod tests {
     use ebml::reader;
     use ebml::writer;
-    use serialize::Encodable;
-    use serialize;
+    use {Encodable, Decodable};
 
     use std::io::MemWriter;
     use std::option::{None, Option, Some};
@@ -1017,7 +1025,7 @@ mod tests {
             }
             let ebml_doc = reader::Doc(wr.get_ref());
             let mut deser = reader::Decoder(ebml_doc);
-            let v1 = serialize::Decodable::decode(&mut deser);
+            let v1 = Decodable::decode(&mut deser);
             debug!("v1 == {:?}", v1);
             assert_eq!(v, v1);
         }
@@ -1031,7 +1039,7 @@ mod tests {
 #[cfg(test)]
 mod bench {
     use ebml::reader;
-    use test::BenchHarness;
+    use extra::test::BenchHarness;
 
     #[bench]
     pub fn vuint_at_A_aligned(bh: &mut BenchHarness) {
diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs
new file mode 100644
index 00000000000..5f473b25369
--- /dev/null
+++ b/src/libserialize/lib.rs
@@ -0,0 +1,33 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Support code for encoding and decoding types.
+
+/*
+Core encoding and decoding interfaces.
+*/
+
+#[crate_id = "serialize#0.10-pre"];
+#[crate_type = "rlib"];
+#[crate_type = "dylib"];
+#[license = "MIT/ASL2"];
+#[allow(missing_doc)];
+#[forbid(non_camel_case_types)];
+#[feature(macro_rules,managed_boxes)];
+
+// test harness access
+#[cfg(test)]
+extern mod extra;
+
+pub use self::serialize::{Decoder, Encoder, Decodable, Encodable,
+    DecoderHelpers, EncoderHelpers};
+
+mod serialize;
+pub mod ebml;
diff --git a/src/libextra/serialize.rs b/src/libserialize/serialize.rs
index 9b1b1e0548e..c4f0a7a1830 100644
--- a/src/libextra/serialize.rs
+++ b/src/libserialize/serialize.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -14,18 +14,10 @@
 Core encoding and decoding interfaces.
 */
 
-#[allow(missing_doc)];
-#[forbid(non_camel_case_types)];
-
-
 use std::hashmap::{HashMap, HashSet};
 use std::rc::Rc;
 use std::trie::{TrieMap, TrieSet};
 use std::vec;
-use ringbuf::RingBuf;
-use container::Deque;
-use dlist::DList;
-use treemap::{TreeMap, TreeSet};
 
 pub trait Encoder {
     // Primitive types:
@@ -615,56 +607,6 @@ impl<
 }
 
 impl<
-    S: Encoder,
-    T: Encodable<S>
-> Encodable<S> for DList<T> {
-    fn encode(&self, s: &mut S) {
-        s.emit_seq(self.len(), |s| {
-            for (i, e) in self.iter().enumerate() {
-                s.emit_seq_elt(i, |s| e.encode(s));
-            }
-        })
-    }
-}
-
-impl<D:Decoder,T:Decodable<D>> Decodable<D> for DList<T> {
-    fn decode(d: &mut D) -> DList<T> {
-        let mut list = DList::new();
-        d.read_seq(|d, len| {
-            for i in range(0u, len) {
-                list.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
-            }
-        });
-        list
-    }
-}
-
-impl<
-    S: Encoder,
-    T: Encodable<S>
-> Encodable<S> for RingBuf<T> {
-    fn encode(&self, s: &mut S) {
-        s.emit_seq(self.len(), |s| {
-            for (i, e) in self.iter().enumerate() {
-                s.emit_seq_elt(i, |s| e.encode(s));
-            }
-        })
-    }
-}
-
-impl<D:Decoder,T:Decodable<D>> Decodable<D> for RingBuf<T> {
-    fn decode(d: &mut D) -> RingBuf<T> {
-        let mut deque = RingBuf::new();
-        d.read_seq(|d, len| {
-            for i in range(0u, len) {
-                deque.push_back(d.read_seq_elt(i, |d| Decodable::decode(d)));
-            }
-        });
-        deque
-    }
-}
-
-impl<
     E: Encoder,
     K: Encodable<E> + Hash + IterBytes + Eq,
     V: Encodable<E>
@@ -782,71 +724,6 @@ impl<D: Decoder> Decodable<D> for TrieSet {
     }
 }
 
-impl<
-    E: Encoder,
-    K: Encodable<E> + Eq + TotalOrd,
-    V: Encodable<E> + Eq
-> Encodable<E> for TreeMap<K, V> {
-    fn encode(&self, e: &mut E) {
-        e.emit_map(self.len(), |e| {
-            let mut i = 0;
-            for (key, val) in self.iter() {
-                e.emit_map_elt_key(i, |e| key.encode(e));
-                e.emit_map_elt_val(i, |e| val.encode(e));
-                i += 1;
-            }
-        })
-    }
-}
-
-impl<
-    D: Decoder,
-    K: Decodable<D> + Eq + TotalOrd,
-    V: Decodable<D> + Eq
-> Decodable<D> for TreeMap<K, V> {
-    fn decode(d: &mut D) -> TreeMap<K, V> {
-        d.read_map(|d, len| {
-            let mut map = TreeMap::new();
-            for i in range(0u, len) {
-                let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
-                let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
-                map.insert(key, val);
-            }
-            map
-        })
-    }
-}
-
-impl<
-    S: Encoder,
-    T: Encodable<S> + Eq + TotalOrd
-> Encodable<S> for TreeSet<T> {
-    fn encode(&self, s: &mut S) {
-        s.emit_seq(self.len(), |s| {
-            let mut i = 0;
-            for e in self.iter() {
-                s.emit_seq_elt(i, |s| e.encode(s));
-                i += 1;
-            }
-        })
-    }
-}
-
-impl<
-    D: Decoder,
-    T: Decodable<D> + Eq + TotalOrd
-> Decodable<D> for TreeSet<T> {
-    fn decode(d: &mut D) -> TreeSet<T> {
-        d.read_seq(|d, len| {
-            let mut set = TreeSet::new();
-            for i in range(0u, len) {
-                set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
-            }
-            set
-        })
-    }
-}
-
 // ___________________________________________________________________________
 // Helper routines
 //
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 228329cbda1..abfd119acbb 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -22,7 +22,7 @@ use std::hashmap::HashMap;
 use std::option::Option;
 use std::rc::Rc;
 use std::to_str::ToStr;
-use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
+use serialize::{Encodable, Decodable, Encoder, Decoder};
 
 /// A pointer abstraction. FIXME(eddyb) #10676 use Rc<T> in the future.
 pub type P<T> = @T;
@@ -1204,6 +1204,7 @@ pub enum InlinedItem {
 
 #[cfg(test)]
 mod test {
+    use serialize;
     use extra;
     use codemap::*;
     use super::*;
@@ -1230,6 +1231,6 @@ mod test {
             },
         };
         // doesn't matter which encoder we use....
-        let _f = (@e as @extra::serialize::Encodable<extra::json::Encoder>);
+        let _f = (@e as @serialize::Encodable<extra::json::Encoder>);
     }
 }
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 2ada3ac16ea..a6c1a373d88 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -23,7 +23,7 @@ source code snippets, etc.
 
 use std::cell::RefCell;
 use std::cmp;
-use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
+use serialize::{Encodable, Decodable, Encoder, Decoder};
 
 pub trait Pos {
     fn from_uint(n: uint) -> Self;
diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs
index 019a4dfe7cc..ad7b3a2e950 100644
--- a/src/libsyntax/ext/deriving/decodable.rs
+++ b/src/libsyntax/ext/deriving/decodable.rs
@@ -28,12 +28,12 @@ pub fn expand_deriving_decodable(cx: &ExtCtxt,
     let trait_def = TraitDef {
         cx: cx, span: span,
 
-        path: Path::new_(~["extra", "serialize", "Decodable"], None,
+        path: Path::new_(~["serialize", "Decodable"], None,
                          ~[~Literal(Path::new_local("__D"))], true),
         additional_bounds: ~[],
         generics: LifetimeBounds {
             lifetimes: ~[],
-            bounds: ~[("__D", ~[Path::new(~["extra", "serialize", "Decoder"])])],
+            bounds: ~[("__D", ~[Path::new(~["serialize", "Decoder"])])],
         },
         methods: ~[
             MethodDef {
@@ -56,8 +56,7 @@ pub fn expand_deriving_decodable(cx: &ExtCtxt,
 fn decodable_substructure(cx: &ExtCtxt, trait_span: Span,
                           substr: &Substructure) -> @Expr {
     let decoder = substr.nonself_args[0];
-    let recurse = ~[cx.ident_of("extra"),
-                    cx.ident_of("serialize"),
+    let recurse = ~[cx.ident_of("serialize"),
                     cx.ident_of("Decodable"),
                     cx.ident_of("decode")];
     // throw an underscore in front to suppress unused variable warnings
diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs
index c50c9f18389..66b744ecbcb 100644
--- a/src/libsyntax/ext/deriving/encodable.rs
+++ b/src/libsyntax/ext/deriving/encodable.rs
@@ -22,7 +22,7 @@ For example, a type like:
 
 would generate two implementations like:
 
-impl<S:extra::serialize::Encoder> Encodable<S> for Node {
+impl<S:serialize::Encoder> Encodable<S> for Node {
     fn encode(&self, s: &S) {
         s.emit_struct("Node", 1, || {
             s.emit_field("id", 0, || s.emit_uint(self.id))
@@ -89,12 +89,12 @@ pub fn expand_deriving_encodable(cx: &ExtCtxt,
     let trait_def = TraitDef {
         cx: cx, span: span,
 
-        path: Path::new_(~["extra", "serialize", "Encodable"], None,
+        path: Path::new_(~["serialize", "Encodable"], None,
                          ~[~Literal(Path::new_local("__E"))], true),
         additional_bounds: ~[],
         generics: LifetimeBounds {
             lifetimes: ~[],
-            bounds: ~[("__E", ~[Path::new(~["extra", "serialize", "Encoder"])])],
+            bounds: ~[("__E", ~[Path::new(~["serialize", "Encoder"])])],
         },
         methods: ~[
             MethodDef {
diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs
index 8eaff592765..992ee3175ed 100644
--- a/src/libsyntax/ext/deriving/generic.rs
+++ b/src/libsyntax/ext/deriving/generic.rs
@@ -204,7 +204,7 @@ pub struct TraitDef<'a> {
     /// other than the current trait
     additional_bounds: ~[Ty<'a>],
 
-    /// Any extra lifetimes and/or bounds, e.g. `D: extra::serialize::Decoder`
+    /// Any extra lifetimes and/or bounds, e.g. `D: serialize::Decoder`
     generics: LifetimeBounds<'a>,
 
     methods: ~[MethodDef<'a>]
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index bcad19f2122..3f305a4eb0e 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -33,6 +33,7 @@ This API is completely unstable and subject to change.
 #[deny(non_camel_case_types)];
 
 extern mod extra;
+extern mod serialize;
 extern mod term;
 
 pub mod util {
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 328f0e7f221..faebd97e7c2 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -284,7 +284,7 @@ pub fn maybe_aborted<T>(result: T, mut p: Parser) -> T {
 #[cfg(test)]
 mod test {
     use super::*;
-    use extra::serialize::Encodable;
+    use serialize::Encodable;
     use extra;
     use std::io;
     use std::io::MemWriter;
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index f1dd844fc7c..090774ec76f 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -15,7 +15,7 @@ use parse::token;
 use util::interner::{RcStr, StrInterner};
 use util::interner;
 
-use extra::serialize::{Decodable, Decoder, Encodable, Encoder};
+use serialize::{Decodable, Decoder, Encodable, Encoder};
 use std::cast;
 use std::char;
 use std::fmt;
diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs
index 60e69af324e..1951c52237f 100644
--- a/src/libuuid/lib.rs
+++ b/src/libuuid/lib.rs
@@ -59,7 +59,10 @@ Examples of string representations:
 #[crate_type = "dylib"];
 #[license = "MIT/ASL2"];
 
+// test harness access
+#[cfg(test)]
 extern mod extra;
+extern mod serialize;
 
 use std::str;
 use std::vec;
@@ -73,7 +76,7 @@ use std::cmp::Eq;
 use std::cast::{transmute,transmute_copy};
 use std::to_bytes::{IterBytes, Cb};
 
-use extra::serialize::{Encoder, Encodable, Decoder, Decodable};
+use serialize::{Encoder, Encodable, Decoder, Decodable};
 
 /// A 128-bit (16 byte) buffer containing the ID
 pub type UuidBytes = [u8, ..16];
@@ -784,8 +787,8 @@ mod test {
 
     #[test]
     fn test_serialize_round_trip() {
-        use extra::ebml;
-        use extra::serialize::{Encodable, Decodable};
+        use serialize::ebml;
+        use serialize::{Encodable, Decodable};
 
         let u = Uuid::new_v4();
         let mut wr = MemWriter::new();
diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs
index f3af7d652cd..027b329b178 100644
--- a/src/test/run-pass/auto-encode.rs
+++ b/src/test/run-pass/auto-encode.rs
@@ -26,7 +26,7 @@ use EBWriter = extra::ebml::writer;
 use std::cmp::Eq;
 use std::cmp;
 use std::io;
-use extra::serialize::{Decodable, Encodable};
+use serialize::{Decodable, Encodable};
 use extra::time;
 
 fn test_ebml<'a, A:
diff --git a/src/test/run-pass/deriving-encodable-decodable.rs b/src/test/run-pass/deriving-encodable-decodable.rs
index 444790bcce9..dedacd92535 100644
--- a/src/test/run-pass/deriving-encodable-decodable.rs
+++ b/src/test/run-pass/deriving-encodable-decodable.rs
@@ -16,14 +16,14 @@
 
 #[feature(struct_variant, managed_boxes)];
 
-extern mod extra;
+extern mod serialize;
 
 use std::io::MemWriter;
 use std::rand::{random, Rand};
-use extra::serialize::{Encodable, Decodable};
-use extra::ebml;
-use extra::ebml::writer::Encoder;
-use extra::ebml::reader::Decoder;
+use serialize::{Encodable, Decodable};
+use serialize::ebml;
+use serialize::ebml::writer::Encoder;
+use serialize::ebml::reader::Decoder;
 
 #[deriving(Encodable, Decodable, Eq, Rand)]
 struct A;
diff --git a/src/test/run-pass/deriving-global.rs b/src/test/run-pass/deriving-global.rs
index ce51e2dcd70..a7a3784877c 100644
--- a/src/test/run-pass/deriving-global.rs
+++ b/src/test/run-pass/deriving-global.rs
@@ -11,7 +11,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod extra; // {En,De}codable
+extern mod serialize; // {En,De}codable
 mod submod {
     // if any of these are implemented without global calls for any
     // function calls, then being in a submodule will (correctly)
diff --git a/src/test/run-pass/issue-4016.rs b/src/test/run-pass/issue-4016.rs
index c1f40d302c8..87a52de2269 100644
--- a/src/test/run-pass/issue-4016.rs
+++ b/src/test/run-pass/issue-4016.rs
@@ -9,10 +9,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// xfail-fast
+
 extern mod extra;
+extern mod serialize;
 
 use extra::json;
-use extra::serialize::Decodable;
+use serialize::Decodable;
 
 trait JD : Decodable<json::Decoder> { }
 
diff --git a/src/test/run-pass/issue-4036.rs b/src/test/run-pass/issue-4036.rs
index 5665bff571e..b746e524d7f 100644
--- a/src/test/run-pass/issue-4036.rs
+++ b/src/test/run-pass/issue-4036.rs
@@ -8,15 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// xfail-fast
+
 // Issue #4036: Test for an issue that arose around fixing up type inference
 // byproducts in vtable records.
 
 extern mod extra;
-use self::extra::json;
-use self::extra::serialize;
+extern mod serialize;
+use extra::json;
+use serialize::Decodable;
 
 pub fn main() {
     let json = json::from_str("[1]").unwrap();
     let mut decoder = json::Decoder::new(json);
-    let _x: ~[int] = serialize::Decodable::decode(&mut decoder);
+    let _x: ~[int] = Decodable::decode(&mut decoder);
 }