summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2012-10-07 10:31:34 -0700
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2012-10-07 10:32:25 -0700
commite1c517ca4815273285ac5699a88ccf0bcdb6103e (patch)
tree22683ff90039c419ca424575e075b19cae689043 /src/libsyntax
parent2a41abb9efee7e07b3989f3a60b994a05c386851 (diff)
downloadrust-e1c517ca4815273285ac5699a88ccf0bcdb6103e.tar.gz
rust-e1c517ca4815273285ac5699a88ccf0bcdb6103e.zip
migrate libsyntax/rustc to auto_serialize2
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs355
-rw-r--r--src/libsyntax/ast_util.rs3
-rw-r--r--src/libsyntax/ext/base.rs2
-rw-r--r--src/libsyntax/ext/expand.rs2
-rw-r--r--src/libsyntax/parse/token.rs21
5 files changed, 219 insertions, 164 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index a50189cf598..1c279f81cc3 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1,33 +1,25 @@
 // The Rust abstract syntax tree.
 
+use std::serialization2::{Serializable,
+                          Deserializable,
+                          Serializer,
+                          Deserializer};
 use codemap::{span, filename};
-use std::serialization::{Serializer,
-                            Deserializer,
-                            serialize_Option,
-                            deserialize_Option,
-                            serialize_uint,
-                            deserialize_uint,
-                            serialize_int,
-                            deserialize_int,
-                            serialize_i64,
-                            deserialize_i64,
-                            serialize_u64,
-                            deserialize_u64,
-                            serialize_str,
-                            deserialize_str,
-                            serialize_bool,
-                            deserialize_bool};
 use parse::token;
 
-/* Note #1972 -- spans are serialized but not deserialized */
-fn serialize_span<S>(_s: S, _v: span) {
+impl span: Serializable {
+    /* Note #1972 -- spans are serialized but not deserialized */
+    fn serialize<S: Serializer>(&self, _s: &S) { }
 }
 
-fn deserialize_span<D>(_d: D) -> span {
-    ast_util::dummy_sp()
+impl span: Deserializable {
+    static fn deserialize<D: Deserializer>(_d: &D) -> span {
+        ast_util::dummy_sp()
+    }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type spanned<T> = {node: T, span: span};
 
 
@@ -42,25 +34,30 @@ macro_rules! interner_key (
 // implemented.
 struct ident { repr: uint }
 
-fn serialize_ident<S: Serializer>(s: S, i: ident) {
-    let intr = match unsafe{
-        task::local_data::local_data_get(interner_key!())
-    } {
-        None => fail ~"serialization: TLS interner not set up",
-        Some(intr) => intr
-    };
+impl ident: Serializable {
+    fn serialize<S: Serializer>(&self, s: &S) {
+        let intr = match unsafe {
+            task::local_data::local_data_get(interner_key!())
+        } {
+            None => fail ~"serialization: TLS interner not set up",
+            Some(intr) => intr
+        };
 
-    s.emit_str(*(*intr).get(i));
+        s.emit_owned_str(*(*intr).get(*self));
+    }
 }
-fn deserialize_ident<D: Deserializer>(d: D) -> ident  {
-    let intr = match unsafe{
-        task::local_data::local_data_get(interner_key!())
-    } {
-        None => fail ~"deserialization: TLS interner not set up",
-        Some(intr) => intr
-    };
 
-    (*intr).intern(@d.read_str())
+impl ident: Deserializable {
+    static fn deserialize<D: Deserializer>(d: &D) -> ident {
+        let intr = match unsafe {
+            task::local_data::local_data_get(interner_key!())
+        } {
+            None => fail ~"deserialization: TLS interner not set up",
+            Some(intr) => intr
+        };
+
+        (*intr).intern(@d.read_owned_str())
+    }
 }
 
 impl ident: cmp::Eq {
@@ -75,23 +72,22 @@ impl ident: to_bytes::IterBytes {
 }
 
 // Functions may or may not have names.
-#[auto_serialize]
 type fn_ident = Option<ident>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type path = {span: span,
              global: bool,
              idents: ~[ident],
              rp: Option<@region>,
              types: ~[@ty]};
 
-#[auto_serialize]
 type crate_num = int;
 
-#[auto_serialize]
 type node_id = int;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type def_id = {crate: crate_num, node: node_id};
 
 impl def_id : cmp::Eq {
@@ -104,7 +100,8 @@ impl def_id : cmp::Eq {
 const local_crate: crate_num = 0;
 const crate_node_id: node_id = 0;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum ty_param_bound {
     bound_copy,
     bound_send,
@@ -113,10 +110,12 @@ enum ty_param_bound {
     bound_trait(@ty),
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type ty_param = {ident: ident, id: node_id, bounds: @~[ty_param_bound]};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum def {
     def_fn(def_id, purity),
     def_static_method(def_id, purity),
@@ -293,33 +292,36 @@ enum crate_directive_ {
 
 type crate_directive = spanned<crate_directive_>;
 
-#[auto_serialize]
 type meta_item = spanned<meta_item_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum meta_item_ {
     meta_word(~str),
     meta_list(~str, ~[@meta_item]),
     meta_name_value(~str, lit),
 }
 
-#[auto_serialize]
 type blk = spanned<blk_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type blk_ = {view_items: ~[@view_item],
              stmts: ~[@stmt],
              expr: Option<@expr>,
              id: node_id,
              rules: blk_check_mode};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type pat = {id: node_id, node: pat_, span: span};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type field_pat = {ident: ident, pat: @pat};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum binding_mode {
     bind_by_value,
     bind_by_move,
@@ -375,7 +377,8 @@ impl binding_mode : cmp::Eq {
     pure fn ne(other: &binding_mode) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum pat_ {
     pat_wild,
     // A pat_ident may either be a new bound variable,
@@ -398,7 +401,8 @@ enum pat_ {
     pat_range(@expr, @expr),
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum mutability { m_mutbl, m_imm, m_const, }
 
 impl mutability : to_bytes::IterBytes {
@@ -414,7 +418,8 @@ impl mutability : cmp::Eq {
     pure fn ne(other: &mutability) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum proto {
     proto_bare,    // foreign fn
     proto_uniq,    // fn~
@@ -429,7 +434,8 @@ impl proto : cmp::Eq {
     pure fn ne(other: &proto) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum vstore {
     // FIXME (#2112): Change uint to @expr (actually only constant exprs)
     vstore_fixed(Option<uint>),   // [1,2,3,4]/_ or 4
@@ -438,7 +444,8 @@ enum vstore {
     vstore_slice(@region)         // &[1,2,3,4](foo)?
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum expr_vstore {
     // FIXME (#2112): Change uint to @expr (actually only constant exprs)
     expr_vstore_fixed(Option<uint>),   // [1,2,3,4]/_ or 4
@@ -454,7 +461,8 @@ pure fn is_blockish(p: ast::proto) -> bool {
     }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum binop {
     add,
     subtract,
@@ -483,7 +491,8 @@ impl binop : cmp::Eq {
     pure fn ne(other: &binop) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum unop {
     box(mutability),
     uniq(mutability),
@@ -534,7 +543,8 @@ impl unop : cmp::Eq {
 
 // Generally, after typeck you can get the inferred value
 // using ty::resolved_T(...).
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum inferable<T> {
     expl(T),
     infer(node_id)
@@ -573,7 +583,8 @@ impl<T:cmp::Eq> inferable<T> : cmp::Eq {
 }
 
 // "resolved" mode: the real modes.
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum rmode { by_ref, by_val, by_move, by_copy }
 
 impl rmode : to_bytes::IterBytes {
@@ -591,13 +602,12 @@ impl rmode : cmp::Eq {
 }
 
 // inferable mode.
-#[auto_serialize]
 type mode = inferable<rmode>;
 
-#[auto_serialize]
 type stmt = spanned<stmt_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum stmt_ {
     stmt_decl(@decl, node_id),
 
@@ -608,7 +618,8 @@ enum stmt_ {
     stmt_semi(@expr, node_id),
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum init_op { init_assign, init_move, }
 
 impl init_op : cmp::Eq {
@@ -631,34 +642,37 @@ impl init_op : cmp::Eq {
     pure fn ne(other: &init_op) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type initializer = {op: init_op, expr: @expr};
 
 // FIXME (pending discussion of #1697, #2178...): local should really be
 // a refinement on pat.
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type local_ =  {is_mutbl: bool, ty: @ty, pat: @pat,
                 init: Option<initializer>, id: node_id};
 
-#[auto_serialize]
 type local = spanned<local_>;
 
-#[auto_serialize]
 type decl = spanned<decl_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum decl_ { decl_local(~[@local]), decl_item(@item), }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type arm = {pats: ~[@pat], guard: Option<@expr>, body: blk};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type field_ = {mutbl: mutability, ident: ident, expr: @expr};
 
-#[auto_serialize]
 type field = spanned<field_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum blk_check_mode { default_blk, unsafe_blk, }
 
 impl blk_check_mode : cmp::Eq {
@@ -673,18 +687,22 @@ impl blk_check_mode : cmp::Eq {
     pure fn ne(other: &blk_check_mode) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type expr = {id: node_id, callee_id: node_id, node: expr_, span: span};
 // Extra node ID is only used for index, assign_op, unary, binary
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum log_level { error, debug, other }
 // 0 = error, 1 = debug, 2 = other
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum alt_mode { alt_check, alt_exhaustive, }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum expr_ {
     expr_vstore(@expr, expr_vstore),
     expr_vec(~[@expr], mutability),
@@ -740,15 +758,17 @@ enum expr_ {
     expr_repeat(@expr /* element */, @expr /* count */, mutability)
 }
 
-#[auto_serialize]
-type capture_item = @{
+#[auto_serialize2]
+#[auto_deserialize2]
+type capture_item_ = {
     id: int,
     is_move: bool,
     name: ident, // Currently, can only capture a local var.
     span: span
 };
 
-#[auto_serialize]
+type capture_item = @capture_item_;
+
 type capture_clause = @~[capture_item];
 
 //
@@ -767,7 +787,8 @@ type capture_clause = @~[capture_item];
 // else knows what to do with them, so you'll probably get a syntax
 // error.
 //
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 #[doc="For macro invocations; parsing is delegated to the macro"]
 enum token_tree {
     tt_tok(span, token::token),
@@ -829,10 +850,10 @@ enum token_tree {
 // If you understand that, you have closed to loop and understand the whole
 // macro system. Congratulations.
 //
-#[auto_serialize]
 type matcher = spanned<matcher_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum matcher_ {
     // match one token
     match_tok(token::token),
@@ -843,19 +864,18 @@ enum matcher_ {
     match_nonterminal(ident, ident, uint)
 }
 
-#[auto_serialize]
 type mac = spanned<mac_>;
 
-#[auto_serialize]
 type mac_arg = Option<@expr>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type mac_body_ = {span: span};
 
-#[auto_serialize]
 type mac_body = Option<mac_body_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum mac_ {
     mac_invoc(@path, mac_arg, mac_body), // old macro-invocation
     mac_invoc_tt(@path,~[token_tree]),   // new macro-invocation
@@ -866,10 +886,10 @@ enum mac_ {
     mac_var(uint)
 }
 
-#[auto_serialize]
 type lit = spanned<lit_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum lit_ {
     lit_str(@~str),
     lit_int(i64, int_ty),
@@ -910,21 +930,24 @@ impl ast::lit_: cmp::Eq {
 
 // NB: If you change this, you'll probably want to change the corresponding
 // type structure in middle/ty.rs as well.
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type mt = {ty: @ty, mutbl: mutability};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type ty_field_ = {ident: ident, mt: mt};
 
-#[auto_serialize]
 type ty_field = spanned<ty_field_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type ty_method = {ident: ident, attrs: ~[attribute], purity: purity,
                   decl: fn_decl, tps: ~[ty_param], self_ty: self_ty,
                   id: node_id, span: span};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 // A trait method is either required (meaning it doesn't have an
 // implementation, just a signature) or provided (meaning it has a default
 // implementation).
@@ -933,7 +956,8 @@ enum trait_method {
     provided(@method),
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
 
 impl int_ty : to_bytes::IterBytes {
@@ -962,7 +986,8 @@ impl int_ty : cmp::Eq {
     pure fn ne(other: &int_ty) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
 
 impl uint_ty : to_bytes::IterBytes {
@@ -989,7 +1014,8 @@ impl uint_ty : cmp::Eq {
     pure fn ne(other: &uint_ty) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum float_ty { ty_f, ty_f32, ty_f64, }
 
 impl float_ty : to_bytes::IterBytes {
@@ -1007,11 +1033,13 @@ impl float_ty : cmp::Eq {
     pure fn ne(other: &float_ty) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type ty = {id: node_id, node: ty_, span: span};
 
 // Not represented directly in the AST, referred to by name through a ty_path.
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum prim_ty {
     ty_int(int_ty),
     ty_uint(uint_ty),
@@ -1058,10 +1086,12 @@ impl prim_ty : cmp::Eq {
     pure fn ne(other: &prim_ty) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type region = {id: node_id, node: region_};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum region_ {
     re_anon,
     re_static,
@@ -1069,7 +1099,8 @@ enum region_ {
     re_named(ident)
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum ty_ {
     ty_nil,
     ty_bot, /* bottom type */
@@ -1108,16 +1139,19 @@ impl ty : to_bytes::IterBytes {
 }
 
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type arg = {mode: mode, ty: @ty, ident: ident, id: node_id};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type fn_decl =
     {inputs: ~[arg],
      output: @ty,
      cf: ret_style};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum purity {
     pure_fn, // declared with "pure fn"
     unsafe_fn, // declared with "unsafe fn"
@@ -1138,7 +1172,8 @@ impl purity : cmp::Eq {
     pure fn ne(other: &purity) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum ret_style {
     noreturn, // functions with return type _|_ that always
               // raise an error or exit (i.e. never return to the caller)
@@ -1163,7 +1198,8 @@ impl ret_style : cmp::Eq {
     pure fn ne(other: &ret_style) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum self_ty_ {
     sty_static,                         // no self: static method
     sty_by_ref,                         // old by-reference self: ``
@@ -1217,20 +1253,22 @@ impl self_ty_ : cmp::Eq {
     pure fn ne(other: &self_ty_) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
 type self_ty = spanned<self_ty_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type method = {ident: ident, attrs: ~[attribute],
                tps: ~[ty_param], self_ty: self_ty,
                purity: purity, decl: fn_decl, body: blk,
                id: node_id, span: span, self_id: node_id,
                vis: visibility};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type _mod = {view_items: ~[@view_item], items: ~[@item]};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum foreign_abi {
     foreign_abi_rust_intrinsic,
     foreign_abi_cdecl,
@@ -1238,7 +1276,8 @@ enum foreign_abi {
 }
 
 // Foreign mods can be named or anonymous
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum foreign_mod_sort { named, anonymous }
 
 impl foreign_mod_sort : cmp::Eq {
@@ -1262,39 +1301,48 @@ impl foreign_abi : cmp::Eq {
     pure fn ne(other: &foreign_abi) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type foreign_mod =
     {sort: foreign_mod_sort,
      view_items: ~[@view_item],
      items: ~[@foreign_item]};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type variant_arg = {ty: @ty, id: node_id};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum variant_kind {
     tuple_variant_kind(~[variant_arg]),
     struct_variant_kind(@struct_def),
     enum_variant_kind(enum_def)
 }
 
-#[auto_serialize]
-enum enum_def = { variants: ~[variant], common: Option<@struct_def> };
+#[auto_serialize2]
+#[auto_deserialize2]
+type enum_def_ = { variants: ~[variant], common: Option<@struct_def> };
+
+#[auto_serialize2]
+#[auto_deserialize2]
+enum enum_def = enum_def_;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type variant_ = {name: ident, attrs: ~[attribute], kind: variant_kind,
                  id: node_id, disr_expr: Option<@expr>, vis: visibility};
 
-#[auto_serialize]
 type variant = spanned<variant_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type path_list_ident_ = {name: ident, id: node_id};
 
-#[auto_serialize]
 type path_list_ident = spanned<path_list_ident_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum namespace { module_ns, type_value_ns }
 
 impl namespace : cmp::Eq {
@@ -1304,10 +1352,10 @@ impl namespace : cmp::Eq {
     pure fn ne(other: &namespace) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
 type view_path = spanned<view_path_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum view_path_ {
 
     // quux = foo::bar::baz
@@ -1324,11 +1372,13 @@ enum view_path_ {
     view_path_list(@path, ~[path_list_ident], node_id)
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type view_item = {node: view_item_, attrs: ~[attribute],
                   vis: visibility, span: span};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum view_item_ {
     view_item_use(ident, ~[@meta_item], node_id),
     view_item_import(~[@view_path]),
@@ -1336,13 +1386,13 @@ enum view_item_ {
 }
 
 // Meta-data associated with an item
-#[auto_serialize]
 type attribute = spanned<attribute_>;
 
 // Distinguishes between attributes that decorate items and attributes that
 // are contained as statements within items. These two cases need to be
 // distinguished for pretty-printing.
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum attr_style { attr_outer, attr_inner, }
 
 impl attr_style : cmp::Eq {
@@ -1353,7 +1403,8 @@ impl attr_style : cmp::Eq {
 }
 
 // doc-comments are promoted to attributes that have is_sugared_doc = true
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type attribute_ = {style: attr_style, value: meta_item, is_sugared_doc: bool};
 
 /*
@@ -1365,10 +1416,12 @@ type attribute_ = {style: attr_style, value: meta_item, is_sugared_doc: bool};
   conceptually, the impl_id stands in for the pair of (this class, this
   trait)
  */
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type trait_ref = {path: @path, ref_id: node_id, impl_id: node_id};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum visibility { public, private, inherited }
 
 impl visibility : cmp::Eq {
@@ -1385,23 +1438,25 @@ impl visibility : cmp::Eq {
     pure fn ne(other: &visibility) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type struct_field_ = {
     kind: struct_field_kind,
     id: node_id,
     ty: @ty
 };
 
-#[auto_serialize]
 type struct_field = spanned<struct_field_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum struct_field_kind {
     named_field(ident, class_mutability, visibility),
     unnamed_field   // element of a tuple-like struct
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type struct_def = {
     traits: ~[@trait_ref],   /* traits this struct implements */
     fields: ~[@struct_field], /* fields */
@@ -1417,12 +1472,14 @@ type struct_def = {
   FIXME (#3300): Should allow items to be anonymous. Right now
   we just use dummy names for anon items.
  */
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type item = {ident: ident, attrs: ~[attribute],
              id: node_id, node: item_,
              vis: visibility, span: span};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum item_ {
     item_const(@ty, @expr),
     item_fn(fn_decl, purity, ~[ty_param], blk),
@@ -1439,7 +1496,8 @@ enum item_ {
     item_mac(mac),
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum class_mutability { class_mutable, class_immutable }
 
 impl class_mutability : to_bytes::IterBytes {
@@ -1460,26 +1518,27 @@ impl class_mutability : cmp::Eq {
     pure fn ne(other: &class_mutability) -> bool { !self.eq(other) }
 }
 
-#[auto_serialize]
 type class_ctor = spanned<class_ctor_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type class_ctor_ = {id: node_id,
                     attrs: ~[attribute],
                     self_id: node_id,
                     dec: fn_decl,
                     body: blk};
 
-#[auto_serialize]
 type class_dtor = spanned<class_dtor_>;
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type class_dtor_ = {id: node_id,
                     attrs: ~[attribute],
                     self_id: node_id,
                     body: blk};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type foreign_item =
     {ident: ident,
      attrs: ~[attribute],
@@ -1488,7 +1547,8 @@ type foreign_item =
      span: span,
      vis: visibility};
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum foreign_item_ {
     foreign_item_fn(fn_decl, purity, ~[ty_param]),
     foreign_item_const(@ty)
@@ -1497,7 +1557,8 @@ enum foreign_item_ {
 // The data we save and restore about an inlined item or method.  This is not
 // part of the AST that we parse from a file, but it becomes part of the tree
 // that we trans.
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum inlined_item {
     ii_item(@item),
     ii_method(def_id /* impl id */, @method),
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index e8099de246c..47cbdb7ac6c 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -406,7 +406,8 @@ fn dtor_dec() -> fn_decl {
 // ______________________________________________________________________
 // Enumerating the IDs which appear in an AST
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 type id_range = {min: node_id, max: node_id};
 
 fn empty(range: id_range) -> bool {
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 9a31cc1d8f6..53880baea9b 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -54,7 +54,7 @@ enum syntax_extension {
     // macro_defining() is obsolete, remove when #old_macros go away.
     macro_defining(macro_definer),
 
-    // #[auto_serialize] and such. will probably survive death of #old_macros
+    // #[auto_serialize2] and such. will probably survive death of #old_macros
     item_decorator(item_decorator),
 
     // Token-tree expanders
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 22e2cfcde6b..2d0b2f4c80a 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -124,7 +124,7 @@ fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
 }
 
 // This is a secondary mechanism for invoking syntax extensions on items:
-// "decorator" attributes, such as #[auto_serialize]. These are invoked by an
+// "decorator" attributes, such as #[auto_serialize2]. These are invoked by an
 // attribute prefixing an item, and are interpreted by feeding the item
 // through the named attribute _as a syntax extension_ and splicing in the
 // resulting item vec into place in favour of the decorator. Note that
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 99b789cf63f..19e79a4ae7a 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -1,18 +1,9 @@
 use util::interner;
 use util::interner::interner;
 use std::map::HashMap;
-use std::serialization::{Serializer,
-                            Deserializer,
-                            serialize_uint,
-                            deserialize_uint,
-                            serialize_i64,
-                            deserialize_i64,
-                            serialize_u64,
-                            deserialize_u64,
-                            serialize_bool,
-                            deserialize_bool};
-
-#[auto_serialize]
+
+#[auto_serialize2]
+#[auto_deserialize2]
 enum binop {
     PLUS,
     MINUS,
@@ -26,7 +17,8 @@ enum binop {
     SHR,
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 enum token {
     /* Expression-operator symbols. */
     EQ,
@@ -83,7 +75,8 @@ enum token {
     EOF,
 }
 
-#[auto_serialize]
+#[auto_serialize2]
+#[auto_deserialize2]
 /// For interpolation during macro expansion.
 enum nonterminal {
     nt_item(@ast::item),