serialize: Fully deprecate the library

This commit completes the deprecation story for the in-tree serialization
library. The compiler will now emit a warning whenever it encounters
`deriving(Encodable)` or `deriving(Decodable)`, and the library itself is now
marked `#[unstable]` for when feature staging is enabled.

All users of serialization can migrate to the `rustc-serialize` crate on
crates.io which provides the exact same interface as the libserialize library
in-tree. The new deriving modes are named `RustcEncodable` and `RustcDecodable`
and require `extern crate "rustc-serialize" as rustc_serialize` at the crate
root in order to expand correctly.

To migrate all crates, add the following to your `Cargo.toml`:

    [dependencies]
    rustc-serialize = "0.1.1"

And then add the following to your crate root:

    extern crate "rustc-serialize" as rustc_serialize;

Finally, rename `Encodable` and `Decodable` deriving modes to `RustcEncodable`
and `RustcDecodable`.

[breaking-change]
This commit is contained in:
Alex Crichton 2014-12-18 22:52:48 -08:00
parent 34d6800092
commit a76a802768
25 changed files with 288 additions and 226 deletions

View File

@ -40,6 +40,8 @@ extern crate collections;
#[phase(plugin, link)] extern crate log; #[phase(plugin, link)] extern crate log;
#[phase(plugin, link)] extern crate syntax; #[phase(plugin, link)] extern crate syntax;
extern crate "serialize" as rustc_serialize; // used by deriving
#[cfg(test)] #[cfg(test)]
extern crate test; extern crate test;

View File

@ -20,7 +20,7 @@ use syntax::ast_util::local_def;
use std::cell::RefCell; use std::cell::RefCell;
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum Def { pub enum Def {
DefFn(ast::DefId, bool /* is_ctor */), DefFn(ast::DefId, bool /* is_ctor */),
DefStaticMethod(/* method */ ast::DefId, MethodProvenance), DefStaticMethod(/* method */ ast::DefId, MethodProvenance),
@ -73,13 +73,13 @@ pub struct Export {
pub def_id: ast::DefId, // The definition of the target. pub def_id: ast::DefId, // The definition of the target.
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum MethodProvenance { pub enum MethodProvenance {
FromTrait(ast::DefId), FromTrait(ast::DefId),
FromImpl(ast::DefId), FromImpl(ast::DefId),
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum TyParamProvenance { pub enum TyParamProvenance {
FromSelf(ast::DefId), FromSelf(ast::DefId),
FromParam(ast::DefId), FromParam(ast::DefId),

View File

@ -36,7 +36,8 @@ use syntax::visit::{Visitor, FnKind};
/// placate the same deriving in `ty::FreeRegion`, but we may want to /// placate the same deriving in `ty::FreeRegion`, but we may want to
/// actually attach a more meaningful ordering to scopes than the one /// actually attach a more meaningful ordering to scopes than the one
/// generated via deriving here. /// generated via deriving here.
#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)] #[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable,
RustcDecodable, Show, Copy)]
pub enum CodeExtent { pub enum CodeExtent {
Misc(ast::NodeId) Misc(ast::NodeId)
} }

View File

@ -33,7 +33,7 @@ use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
use util::nodemap::NodeMap; use util::nodemap::NodeMap;
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)] #[deriving(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show)]
pub enum DefRegion { pub enum DefRegion {
DefStaticRegion, DefStaticRegion,
DefEarlyBoundRegion(/* space */ subst::ParamSpace, DefEarlyBoundRegion(/* space */ subst::ParamSpace,

View File

@ -187,8 +187,8 @@ impl RegionSubsts {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// ParamSpace // ParamSpace
#[deriving(Copy, PartialOrd, Ord, PartialEq, Eq, #[deriving(PartialOrd, Ord, PartialEq, Eq, Copy,
Clone, Hash, Encodable, Decodable, Show)] Clone, Hash, RustcEncodable, RustcDecodable, Show)]
pub enum ParamSpace { pub enum ParamSpace {
TypeSpace, // Type parameters attached to a type definition, trait, or impl TypeSpace, // Type parameters attached to a type definition, trait, or impl
SelfSpace, // Self parameter on a trait SelfSpace, // Self parameter on a trait
@ -224,7 +224,7 @@ impl ParamSpace {
/// Vector of things sorted by param space. Used to keep /// Vector of things sorted by param space. Used to keep
/// the set of things declared on the type, self, or method /// the set of things declared on the type, self, or method
/// distinct. /// distinct.
#[deriving(PartialEq, Eq, Clone, Hash, Encodable, Decodable)] #[deriving(PartialEq, Eq, Clone, Hash, RustcEncodable, RustcDecodable)]
pub struct VecPerParamSpace<T> { pub struct VecPerParamSpace<T> {
// This was originally represented as a tuple with one Vec<T> for // This was originally represented as a tuple with one Vec<T> for
// each variant of ParamSpace, and that remains the abstraction // each variant of ParamSpace, and that remains the abstraction

View File

@ -246,7 +246,7 @@ pub struct mt<'tcx> {
pub mutbl: ast::Mutability, pub mutbl: ast::Mutability,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)] #[deriving(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show)]
pub enum TraitStore { pub enum TraitStore {
/// Box<Trait> /// Box<Trait>
UniqTraitStore, UniqTraitStore,
@ -277,13 +277,13 @@ pub enum ast_ty_to_ty_cache_entry<'tcx> {
atttce_resolved(Ty<'tcx>) /* resolved to a type, irrespective of region */ atttce_resolved(Ty<'tcx>) /* resolved to a type, irrespective of region */
} }
#[deriving(Clone, PartialEq, Decodable, Encodable)] #[deriving(Clone, PartialEq, RustcDecodable, RustcEncodable)]
pub struct ItemVariances { pub struct ItemVariances {
pub types: VecPerParamSpace<Variance>, pub types: VecPerParamSpace<Variance>,
pub regions: VecPerParamSpace<Variance>, pub regions: VecPerParamSpace<Variance>,
} }
#[deriving(Clone, Copy, PartialEq, Decodable, Encodable, Show)] #[deriving(Clone, PartialEq, RustcDecodable, RustcEncodable, Show, Copy)]
pub enum Variance { pub enum Variance {
Covariant, // T<A> <: T<B> iff A <: B -- e.g., function return type Covariant, // T<A> <: T<B> iff A <: B -- e.g., function return type
Invariant, // T<A> <: T<B> iff B == A -- e.g., type of mutable cell Invariant, // T<A> <: T<B> iff B == A -- e.g., type of mutable cell
@ -430,7 +430,7 @@ pub fn type_of_adjust<'tcx>(cx: &ctxt<'tcx>, adj: &AutoAdjustment<'tcx>) -> Opti
} }
} }
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, PartialOrd, Show)] #[deriving(Clone, Copy, RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Show)]
pub struct param_index { pub struct param_index {
pub space: subst::ParamSpace, pub space: subst::ParamSpace,
pub index: uint pub index: uint
@ -510,7 +510,7 @@ pub struct MethodCall {
pub adjustment: ExprAdjustment pub adjustment: ExprAdjustment
} }
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show, Encodable, Decodable)] #[deriving(Clone, PartialEq, Eq, Hash, Show, RustcEncodable, RustcDecodable, Copy)]
pub enum ExprAdjustment { pub enum ExprAdjustment {
NoAdjustment, NoAdjustment,
AutoDeref(uint), AutoDeref(uint),
@ -973,7 +973,7 @@ pub struct ParamTy {
/// is the outer fn. /// is the outer fn.
/// ///
/// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index /// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)] #[deriving(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show, Copy)]
pub struct DebruijnIndex { pub struct DebruijnIndex {
// We maintain the invariant that this is never 0. So 1 indicates // We maintain the invariant that this is never 0. So 1 indicates
// the innermost binder. To ensure this, create with `DebruijnIndex::new`. // the innermost binder. To ensure this, create with `DebruijnIndex::new`.
@ -981,7 +981,7 @@ pub struct DebruijnIndex {
} }
/// Representation of regions: /// Representation of regions:
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)] #[deriving(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show, Copy)]
pub enum Region { pub enum Region {
// Region bound in a type or fn declaration which will be // Region bound in a type or fn declaration which will be
// substituted 'early' -- that is, at the same time when type // substituted 'early' -- that is, at the same time when type
@ -1028,7 +1028,7 @@ pub struct UpvarId {
pub closure_expr_id: ast::NodeId, pub closure_expr_id: ast::NodeId,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show, Encodable, Decodable)] #[deriving(Clone, PartialEq, Eq, Hash, Show, RustcEncodable, RustcDecodable, Copy)]
pub enum BorrowKind { pub enum BorrowKind {
/// Data must be immutable and is aliasable. /// Data must be immutable and is aliasable.
ImmBorrow, ImmBorrow,
@ -1121,7 +1121,7 @@ pub enum BorrowKind {
/// - Through mutation, the borrowed upvars can actually escape /// - Through mutation, the borrowed upvars can actually escape
/// the closure, so sometimes it is necessary for them to be larger /// the closure, so sometimes it is necessary for them to be larger
/// than the closure lifetime itself. /// than the closure lifetime itself.
#[deriving(Copy, PartialEq, Clone, Encodable, Decodable, Show)] #[deriving(PartialEq, Clone, RustcEncodable, RustcDecodable, Show, Copy)]
pub struct UpvarBorrow { pub struct UpvarBorrow {
pub kind: BorrowKind, pub kind: BorrowKind,
pub region: ty::Region, pub region: ty::Region,
@ -1146,7 +1146,8 @@ impl Region {
} }
} }
#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)] #[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
RustcEncodable, RustcDecodable, Show, Copy)]
/// A "free" region `fr` can be interpreted as "some region /// A "free" region `fr` can be interpreted as "some region
/// at least as big as the scope `fr.scope`". /// at least as big as the scope `fr.scope`".
pub struct FreeRegion { pub struct FreeRegion {
@ -1154,7 +1155,8 @@ pub struct FreeRegion {
pub bound_region: BoundRegion pub bound_region: BoundRegion
} }
#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)] #[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
RustcEncodable, RustcDecodable, Show, Copy)]
pub enum BoundRegion { pub enum BoundRegion {
/// An anonymous region parameter for a given fn (&T) /// An anonymous region parameter for a given fn (&T)
BrAnon(uint), BrAnon(uint),
@ -1412,7 +1414,8 @@ pub struct ExistentialBounds {
pub type BuiltinBounds = EnumSet<BuiltinBound>; pub type BuiltinBounds = EnumSet<BuiltinBound>;
#[deriving(Copy, Clone, Encodable, PartialEq, Eq, Decodable, Hash, Show)] #[deriving(Clone, RustcEncodable, PartialEq, Eq, RustcDecodable, Hash,
Show, Copy)]
#[repr(uint)] #[repr(uint)]
pub enum BuiltinBound { pub enum BuiltinBound {
BoundSend, BoundSend,
@ -1463,7 +1466,7 @@ pub struct FloatVid {
pub index: uint pub index: uint
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub struct RegionVid { pub struct RegionVid {
pub index: uint pub index: uint
} }
@ -1485,7 +1488,7 @@ pub enum InferTy {
FreshIntTy(uint), FreshIntTy(uint),
} }
#[deriving(Clone, Copy, Encodable, Decodable, Eq, Hash, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, Eq, Hash, Show, Copy)]
pub enum InferRegion { pub enum InferRegion {
ReVar(RegionVid), ReVar(RegionVid),
ReSkolemized(uint, BoundRegion) ReSkolemized(uint, BoundRegion)
@ -1571,7 +1574,7 @@ pub struct TypeParameterDef<'tcx> {
pub default: Option<Ty<'tcx>>, pub default: Option<Ty<'tcx>>,
} }
#[deriving(Encodable, Decodable, Clone, Show)] #[deriving(RustcEncodable, RustcDecodable, Clone, Show)]
pub struct RegionParameterDef { pub struct RegionParameterDef {
pub name: ast::Name, pub name: ast::Name,
pub def_id: ast::DefId, pub def_id: ast::DefId,
@ -6223,7 +6226,7 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
} }
/// A free variable referred to in a function. /// A free variable referred to in a function.
#[deriving(Copy, Encodable, Decodable)] #[deriving(Copy, RustcEncodable, RustcDecodable)]
pub struct Freevar { pub struct Freevar {
/// The variable being accessed free. /// The variable being accessed free.
pub def: def::Def, pub def: def::Def,

View File

@ -113,7 +113,7 @@ impl<T: Clean<U>, U> Clean<Vec<U>> for syntax::owned_slice::OwnedSlice<T> {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Crate { pub struct Crate {
pub name: String, pub name: String,
pub src: FsPath, pub src: FsPath,
@ -195,7 +195,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct ExternalCrate { pub struct ExternalCrate {
pub name: String, pub name: String,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -228,7 +228,7 @@ impl Clean<ExternalCrate> for cstore::crate_metadata {
/// Anything with a source location and set of attributes and, optionally, a /// Anything with a source location and set of attributes and, optionally, a
/// name. That is, anything that can be documented. This doesn't correspond /// name. That is, anything that can be documented. This doesn't correspond
/// directly to the AST's concept of an item; it's a strict superset. /// directly to the AST's concept of an item; it's a strict superset.
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Item { pub struct Item {
/// Stringified span /// Stringified span
pub source: Span, pub source: Span,
@ -304,7 +304,7 @@ impl Item {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum ItemEnum { pub enum ItemEnum {
StructItem(Struct), StructItem(Struct),
EnumItem(Enum), EnumItem(Enum),
@ -333,7 +333,7 @@ pub enum ItemEnum {
AssociatedTypeItem(TyParam), AssociatedTypeItem(TyParam),
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Module { pub struct Module {
pub items: Vec<Item>, pub items: Vec<Item>,
pub is_crate: bool, pub is_crate: bool,
@ -400,7 +400,7 @@ impl Clean<Item> for doctree::Module {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub enum Attribute { pub enum Attribute {
Word(String), Word(String),
List(String, Vec<Attribute> ), List(String, Vec<Attribute> ),
@ -453,7 +453,7 @@ impl<'a> attr::AttrMetaMethods for &'a Attribute {
fn meta_item_list(&self) -> Option<&[P<ast::MetaItem>]> { None } fn meta_item_list(&self) -> Option<&[P<ast::MetaItem>]> { None }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct TyParam { pub struct TyParam {
pub name: String, pub name: String,
pub did: ast::DefId, pub did: ast::DefId,
@ -490,7 +490,7 @@ impl<'tcx> Clean<TyParam> for ty::TypeParameterDef<'tcx> {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub enum TyParamBound { pub enum TyParamBound {
RegionBound(Lifetime), RegionBound(Lifetime),
TraitBound(Type) TraitBound(Type)
@ -632,7 +632,7 @@ impl<'tcx> Clean<Option<Vec<TyParamBound>>> for subst::Substs<'tcx> {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct Lifetime(String); pub struct Lifetime(String);
impl Lifetime { impl Lifetime {
@ -682,7 +682,7 @@ impl Clean<Option<Lifetime>> for ty::Region {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct WherePredicate { pub struct WherePredicate {
pub ty: Type, pub ty: Type,
pub bounds: Vec<TyParamBound> pub bounds: Vec<TyParamBound>
@ -706,7 +706,7 @@ impl Clean<WherePredicate> for ast::WherePredicate {
} }
// maybe use a Generic enum and use ~[Generic]? // maybe use a Generic enum and use ~[Generic]?
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct Generics { pub struct Generics {
pub lifetimes: Vec<Lifetime>, pub lifetimes: Vec<Lifetime>,
pub type_params: Vec<TyParam>, pub type_params: Vec<TyParam>,
@ -734,7 +734,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics<'tcx>, subst::ParamSpace) {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Method { pub struct Method {
pub generics: Generics, pub generics: Generics,
pub self_: SelfTy, pub self_: SelfTy,
@ -773,7 +773,7 @@ impl Clean<Item> for ast::Method {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct TyMethod { pub struct TyMethod {
pub unsafety: ast::Unsafety, pub unsafety: ast::Unsafety,
pub decl: FnDecl, pub decl: FnDecl,
@ -811,7 +811,7 @@ impl Clean<Item> for ast::TypeMethod {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub enum SelfTy { pub enum SelfTy {
SelfStatic, SelfStatic,
SelfValue, SelfValue,
@ -832,7 +832,7 @@ impl Clean<SelfTy> for ast::ExplicitSelf_ {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Function { pub struct Function {
pub decl: FnDecl, pub decl: FnDecl,
pub generics: Generics, pub generics: Generics,
@ -857,7 +857,7 @@ impl Clean<Item> for doctree::Function {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct ClosureDecl { pub struct ClosureDecl {
pub lifetimes: Vec<Lifetime>, pub lifetimes: Vec<Lifetime>,
pub decl: FnDecl, pub decl: FnDecl,
@ -878,14 +878,14 @@ impl Clean<ClosureDecl> for ast::ClosureTy {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct FnDecl { pub struct FnDecl {
pub inputs: Arguments, pub inputs: Arguments,
pub output: FunctionRetTy, pub output: FunctionRetTy,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct Arguments { pub struct Arguments {
pub values: Vec<Argument>, pub values: Vec<Argument>,
} }
@ -938,7 +938,7 @@ impl<'a, 'tcx> Clean<FnDecl> for (ast::DefId, &'a ty::PolyFnSig<'tcx>) {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct Argument { pub struct Argument {
pub type_: Type, pub type_: Type,
pub name: String, pub name: String,
@ -955,7 +955,7 @@ impl Clean<Argument> for ast::Arg {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub enum FunctionRetTy { pub enum FunctionRetTy {
Return(Type), Return(Type),
NoReturn NoReturn
@ -970,7 +970,7 @@ impl Clean<FunctionRetTy> for ast::FunctionRetTy {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Trait { pub struct Trait {
pub unsafety: ast::Unsafety, pub unsafety: ast::Unsafety,
pub items: Vec<TraitMethod>, pub items: Vec<TraitMethod>,
@ -1014,7 +1014,7 @@ impl Clean<Type> for ast::PolyTraitRef {
/// An item belonging to a trait, whether a method or associated. Could be named /// An item belonging to a trait, whether a method or associated. Could be named
/// TraitItem except that's already taken by an exported enum variant. /// TraitItem except that's already taken by an exported enum variant.
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum TraitMethod { pub enum TraitMethod {
RequiredMethod(Item), RequiredMethod(Item),
ProvidedMethod(Item), ProvidedMethod(Item),
@ -1059,7 +1059,7 @@ impl Clean<TraitMethod> for ast::TraitItem {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum ImplMethod { pub enum ImplMethod {
MethodImplItem(Item), MethodImplItem(Item),
TypeImplItem(Item), TypeImplItem(Item),
@ -1132,7 +1132,7 @@ impl<'tcx> Clean<Item> for ty::ImplOrTraitItem<'tcx> {
/// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original /// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
/// type out of the AST/ty::ctxt given one of these, if more information is needed. Most importantly /// type out of the AST/ty::ctxt given one of these, if more information is needed. Most importantly
/// it does not preserve mutability or boxes. /// it does not preserve mutability or boxes.
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub enum Type { pub enum Type {
/// structs/enums/traits (anything that'd be an ast::TyPath) /// structs/enums/traits (anything that'd be an ast::TyPath)
ResolvedPath { ResolvedPath {
@ -1180,7 +1180,7 @@ pub enum Type {
PolyTraitRef(Vec<TyParamBound>), PolyTraitRef(Vec<TyParamBound>),
} }
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Copy)]
pub enum PrimitiveType { pub enum PrimitiveType {
Int, I8, I16, I32, I64, Int, I8, I16, I32, I64,
Uint, U8, U16, U32, U64, Uint, U8, U16, U32, U64,
@ -1192,7 +1192,7 @@ pub enum PrimitiveType {
PrimitiveTuple, PrimitiveTuple,
} }
#[deriving(Clone, Copy, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable, Copy)]
pub enum TypeKind { pub enum TypeKind {
TypeEnum, TypeEnum,
TypeFunction, TypeFunction,
@ -1436,7 +1436,7 @@ impl Clean<Type> for ast::QPath {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum StructField { pub enum StructField {
HiddenStructField, // inserted later by strip passes HiddenStructField, // inserted later by strip passes
TypedStructField(Type), TypedStructField(Type),
@ -1495,7 +1495,7 @@ impl Clean<Option<Visibility>> for ast::Visibility {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Struct { pub struct Struct {
pub struct_type: doctree::StructType, pub struct_type: doctree::StructType,
pub generics: Generics, pub generics: Generics,
@ -1525,7 +1525,7 @@ impl Clean<Item> for doctree::Struct {
/// This is a more limited form of the standard Struct, different in that /// This is a more limited form of the standard Struct, different in that
/// it lacks the things most items have (name, id, parameterization). Found /// it lacks the things most items have (name, id, parameterization). Found
/// only as a variant in an enum. /// only as a variant in an enum.
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct VariantStruct { pub struct VariantStruct {
pub struct_type: doctree::StructType, pub struct_type: doctree::StructType,
pub fields: Vec<Item>, pub fields: Vec<Item>,
@ -1542,7 +1542,7 @@ impl Clean<VariantStruct> for syntax::ast::StructDef {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Enum { pub struct Enum {
pub variants: Vec<Item>, pub variants: Vec<Item>,
pub generics: Generics, pub generics: Generics,
@ -1567,7 +1567,7 @@ impl Clean<Item> for doctree::Enum {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Variant { pub struct Variant {
pub kind: VariantKind, pub kind: VariantKind,
} }
@ -1635,7 +1635,7 @@ impl<'tcx> Clean<Item> for ty::VariantInfo<'tcx> {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum VariantKind { pub enum VariantKind {
CLikeVariant, CLikeVariant,
TupleVariant(Vec<Type>), TupleVariant(Vec<Type>),
@ -1657,7 +1657,7 @@ impl Clean<VariantKind> for ast::VariantKind {
} }
} }
#[deriving(Clone, Encodable, Decodable, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, Show)]
pub struct Span { pub struct Span {
pub filename: String, pub filename: String,
pub loline: uint, pub loline: uint,
@ -1692,7 +1692,7 @@ impl Clean<Span> for syntax::codemap::Span {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct Path { pub struct Path {
pub global: bool, pub global: bool,
pub segments: Vec<PathSegment>, pub segments: Vec<PathSegment>,
@ -1707,7 +1707,7 @@ impl Clean<Path> for ast::Path {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct PathSegment { pub struct PathSegment {
pub name: String, pub name: String,
pub lifetimes: Vec<Lifetime>, pub lifetimes: Vec<Lifetime>,
@ -1763,7 +1763,7 @@ impl Clean<String> for ast::Name {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Typedef { pub struct Typedef {
pub type_: Type, pub type_: Type,
pub generics: Generics, pub generics: Generics,
@ -1786,7 +1786,7 @@ impl Clean<Item> for doctree::Typedef {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct BareFunctionDecl { pub struct BareFunctionDecl {
pub unsafety: ast::Unsafety, pub unsafety: ast::Unsafety,
pub generics: Generics, pub generics: Generics,
@ -1809,7 +1809,7 @@ impl Clean<BareFunctionDecl> for ast::BareFnTy {
} }
} }
#[deriving(Clone, Encodable, Decodable, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, Show)]
pub struct Static { pub struct Static {
pub type_: Type, pub type_: Type,
pub mutability: Mutability, pub mutability: Mutability,
@ -1838,7 +1838,7 @@ impl Clean<Item> for doctree::Static {
} }
} }
#[deriving(Clone, Encodable, Decodable, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, Show)]
pub struct Constant { pub struct Constant {
pub type_: Type, pub type_: Type,
pub expr: String, pub expr: String,
@ -1861,7 +1861,7 @@ impl Clean<Item> for doctree::Constant {
} }
} }
#[deriving(Copy, Show, Clone, Encodable, Decodable, PartialEq)] #[deriving(Show, Clone, RustcEncodable, RustcDecodable, PartialEq, Copy)]
pub enum Mutability { pub enum Mutability {
Mutable, Mutable,
Immutable, Immutable,
@ -1876,7 +1876,7 @@ impl Clean<Mutability> for ast::Mutability {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Impl { pub struct Impl {
pub generics: Generics, pub generics: Generics,
pub trait_: Option<Type>, pub trait_: Option<Type>,
@ -1914,7 +1914,7 @@ impl Clean<Item> for doctree::Impl {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct ViewItem { pub struct ViewItem {
pub inner: ViewItemInner, pub inner: ViewItemInner,
} }
@ -1980,7 +1980,7 @@ impl Clean<Vec<Item>> for ast::ViewItem {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum ViewItemInner { pub enum ViewItemInner {
ExternCrate(String, Option<String>, ast::NodeId), ExternCrate(String, Option<String>, ast::NodeId),
Import(ViewPath) Import(ViewPath)
@ -2003,7 +2003,7 @@ impl Clean<ViewItemInner> for ast::ViewItem_ {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum ViewPath { pub enum ViewPath {
// use source as str; // use source as str;
SimpleImport(String, ImportSource), SimpleImport(String, ImportSource),
@ -2013,7 +2013,7 @@ pub enum ViewPath {
ImportList(ImportSource, Vec<ViewListIdent>), ImportList(ImportSource, Vec<ViewListIdent>),
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct ImportSource { pub struct ImportSource {
pub path: Path, pub path: Path,
pub did: Option<ast::DefId>, pub did: Option<ast::DefId>,
@ -2034,7 +2034,7 @@ impl Clean<ViewPath> for ast::ViewPath {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct ViewListIdent { pub struct ViewListIdent {
pub name: String, pub name: String,
pub source: Option<ast::DefId>, pub source: Option<ast::DefId>,
@ -2247,7 +2247,7 @@ fn resolve_def(cx: &DocContext, id: ast::NodeId) -> Option<ast::DefId> {
}) })
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Macro { pub struct Macro {
pub source: String, pub source: String,
} }
@ -2268,7 +2268,7 @@ impl Clean<Item> for doctree::Macro {
} }
} }
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Stability { pub struct Stability {
pub level: attr::StabilityLevel, pub level: attr::StabilityLevel,
pub text: String pub text: String

View File

@ -70,7 +70,7 @@ impl Module {
} }
} }
#[deriving(Copy, Show, Clone, Encodable, Decodable)] #[deriving(Show, Clone, RustcEncodable, RustcDecodable, Copy)]
pub enum StructType { pub enum StructType {
/// A normal struct /// A normal struct
Plain, Plain,

View File

@ -32,6 +32,8 @@ extern crate syntax;
extern crate "test" as testing; extern crate "test" as testing;
#[phase(plugin, link)] extern crate log; #[phase(plugin, link)] extern crate log;
extern crate "serialize" as rustc_serialize; // used by deriving
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::hash_map::Entry::{Occupied, Vacant};

View File

@ -25,7 +25,7 @@ use clean::{TypeTraitItem, ViewItemItem, PrimitiveItem, Stability};
use html::render::cache; use html::render::cache;
#[deriving(Zero, Encodable, Decodable, PartialEq, Eq)] #[deriving(Zero, RustcEncodable, RustcDecodable, PartialEq, Eq)]
/// The counts for each stability level. /// The counts for each stability level.
#[deriving(Copy)] #[deriving(Copy)]
pub struct Counts { pub struct Counts {
@ -73,7 +73,7 @@ impl Counts {
} }
} }
#[deriving(Encodable, Decodable, PartialEq, Eq)] #[deriving(RustcEncodable, RustcDecodable, PartialEq, Eq)]
/// A summarized module, which includes total counts and summarized children /// A summarized module, which includes total counts and summarized children
/// modules. /// modules.
pub struct ModuleSummary { pub struct ModuleSummary {

View File

@ -57,17 +57,17 @@
//! //!
//! Rust provides a mechanism for low boilerplate encoding & decoding of values to and from JSON via //! Rust provides a mechanism for low boilerplate encoding & decoding of values to and from JSON via
//! the serialization API. //! the serialization API.
//! To be able to encode a piece of data, it must implement the `serialize::Encodable` trait. //! To be able to encode a piece of data, it must implement the `serialize::RustcEncodable` trait.
//! To be able to decode a piece of data, it must implement the `serialize::Decodable` trait. //! To be able to decode a piece of data, it must implement the `serialize::RustcDecodable` trait.
//! The Rust compiler provides an annotation to automatically generate the code for these traits: //! The Rust compiler provides an annotation to automatically generate the code for these traits:
//! `#[deriving(Decodable, Encodable)]` //! `#[deriving(RustcDecodable, RustcEncodable)]`
//! //!
//! The JSON API provides an enum `json::Json` and a trait `ToJson` to encode objects. //! The JSON API provides an enum `json::Json` and a trait `ToJson` to encode objects.
//! The `ToJson` trait provides a `to_json` method to convert an object into a `json::Json` value. //! The `ToJson` trait provides a `to_json` method to convert an object into a `json::Json` value.
//! A `json::Json` value can be encoded as a string or buffer using the functions described above. //! A `json::Json` value can be encoded as a string or buffer using the functions described above.
//! You can also use the `json::Encoder` object, which implements the `Encoder` trait. //! You can also use the `json::Encoder` object, which implements the `Encoder` trait.
//! //!
//! When using `ToJson` the `Encodable` trait implementation is not mandatory. //! When using `ToJson` the `RustcEncodable` trait implementation is not mandatory.
//! //!
//! # Examples of use //! # Examples of use
//! //!
@ -127,7 +127,7 @@
//! } //! }
//! } //! }
//! //!
//! // Only generate `Encodable` trait implementation //! // Only generate `RustcEncodable` trait implementation
//! #[deriving(Encodable)] //! #[deriving(Encodable)]
//! pub struct ComplexNumRecord { //! pub struct ComplexNumRecord {
//! uid: u8, //! uid: u8,
@ -2428,7 +2428,7 @@ mod tests {
use std::num::Float; use std::num::Float;
use std::string; use std::string;
#[deriving(Decodable, Eq, PartialEq, Show)] #[deriving(RustcDecodable, Eq, PartialEq, Show)]
struct OptionData { struct OptionData {
opt: Option<uint>, opt: Option<uint>,
} }
@ -2455,20 +2455,20 @@ mod tests {
ExpectedError("Number".into_string(), "false".into_string())); ExpectedError("Number".into_string(), "false".into_string()));
} }
#[deriving(PartialEq, Encodable, Decodable, Show)] #[deriving(PartialEq, RustcEncodable, RustcDecodable, Show)]
enum Animal { enum Animal {
Dog, Dog,
Frog(string::String, int) Frog(string::String, int)
} }
#[deriving(PartialEq, Encodable, Decodable, Show)] #[deriving(PartialEq, RustcEncodable, RustcDecodable, Show)]
struct Inner { struct Inner {
a: (), a: (),
b: uint, b: uint,
c: Vec<string::String>, c: Vec<string::String>,
} }
#[deriving(PartialEq, Encodable, Decodable, Show)] #[deriving(PartialEq, RustcEncodable, RustcDecodable, Show)]
struct Outer { struct Outer {
inner: Vec<Inner>, inner: Vec<Inner>,
} }
@ -3009,7 +3009,7 @@ mod tests {
); );
} }
#[deriving(Decodable)] #[deriving(RustcDecodable)]
struct FloatStruct { struct FloatStruct {
f: f64, f: f64,
a: Vec<f64> a: Vec<f64>
@ -3058,7 +3058,7 @@ mod tests {
Err(SyntaxError(EOFWhileParsingObject, 3u, 8u))); Err(SyntaxError(EOFWhileParsingObject, 3u, 8u)));
} }
#[deriving(Decodable)] #[deriving(RustcDecodable)]
#[allow(dead_code)] #[allow(dead_code)]
struct DecodeStruct { struct DecodeStruct {
x: f64, x: f64,
@ -3066,7 +3066,7 @@ mod tests {
z: string::String, z: string::String,
w: Vec<DecodeStruct> w: Vec<DecodeStruct>
} }
#[deriving(Decodable)] #[deriving(RustcDecodable)]
enum DecodeEnum { enum DecodeEnum {
A(f64), A(f64),
B(string::String) B(string::String)

View File

@ -15,7 +15,7 @@ Core encoding and decoding interfaces.
*/ */
#![crate_name = "serialize"] #![crate_name = "serialize"]
#![experimental] #![unstable = "deprecated in favor of rustc-serialize on crates.io"]
#![crate_type = "rlib"] #![crate_type = "rlib"]
#![crate_type = "dylib"] #![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@ -44,3 +44,7 @@ mod collection_impls;
pub mod base64; pub mod base64;
pub mod hex; pub mod hex;
pub mod json; pub mod json;
mod rustc_serialize {
pub use serialize::*;
}

View File

@ -26,7 +26,7 @@ pub enum Os {
OsDragonfly, OsDragonfly,
} }
#[deriving(Copy, PartialEq, Eq, Hash, Encodable, Decodable, Clone)] #[deriving(PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Clone, Copy)]
pub enum Abi { pub enum Abi {
// NB: This ordering MUST match the AbiDatas array below. // NB: This ordering MUST match the AbiDatas array below.
// (This is ensured by the test indices_are_correct().) // (This is ensured by the test indices_are_correct().)

View File

@ -157,7 +157,8 @@ pub const ILLEGAL_CTXT : SyntaxContext = 1;
/// A name is a part of an identifier, representing a string or gensym. It's /// A name is a part of an identifier, representing a string or gensym. It's
/// the result of interning. /// the result of interning.
#[deriving(Copy, Eq, Ord, PartialEq, PartialOrd, Hash, Encodable, Decodable, Clone)] #[deriving(Eq, Ord, PartialEq, PartialOrd, Hash,
RustcEncodable, RustcDecodable, Clone, Copy)]
pub struct Name(pub u32); pub struct Name(pub u32);
impl Name { impl Name {
@ -196,14 +197,15 @@ impl<D:Decoder<E>, E> Decodable<D, E> for Ident {
/// Function name (not all functions have names) /// Function name (not all functions have names)
pub type FnIdent = Option<Ident>; pub type FnIdent = Option<Ident>;
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash,
Show, Copy)]
pub struct Lifetime { pub struct Lifetime {
pub id: NodeId, pub id: NodeId,
pub span: Span, pub span: Span,
pub name: Name pub name: Name
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct LifetimeDef { pub struct LifetimeDef {
pub lifetime: Lifetime, pub lifetime: Lifetime,
pub bounds: Vec<Lifetime> pub bounds: Vec<Lifetime>
@ -212,7 +214,7 @@ pub struct LifetimeDef {
/// A "Path" is essentially Rust's notion of a name; for instance: /// A "Path" is essentially Rust's notion of a name; for instance:
/// std::cmp::PartialEq . It's represented as a sequence of identifiers, /// std::cmp::PartialEq . It's represented as a sequence of identifiers,
/// along with a bunch of supporting information. /// along with a bunch of supporting information.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Path { pub struct Path {
pub span: Span, pub span: Span,
/// A `::foo` path, is relative to the crate root rather than current /// A `::foo` path, is relative to the crate root rather than current
@ -224,7 +226,7 @@ pub struct Path {
/// A segment of a path: an identifier, an optional lifetime, and a set of /// A segment of a path: an identifier, an optional lifetime, and a set of
/// types. /// types.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct PathSegment { pub struct PathSegment {
/// The identifier portion of this path segment. /// The identifier portion of this path segment.
pub identifier: Ident, pub identifier: Ident,
@ -237,7 +239,7 @@ pub struct PathSegment {
pub parameters: PathParameters, pub parameters: PathParameters,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum PathParameters { pub enum PathParameters {
AngleBracketedParameters(AngleBracketedParameterData), AngleBracketedParameters(AngleBracketedParameterData),
ParenthesizedParameters(ParenthesizedParameterData), ParenthesizedParameters(ParenthesizedParameterData),
@ -315,7 +317,7 @@ impl PathParameters {
} }
/// A path like `Foo<'a, T>` /// A path like `Foo<'a, T>`
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct AngleBracketedParameterData { pub struct AngleBracketedParameterData {
/// The lifetime parameters for this path segment. /// The lifetime parameters for this path segment.
pub lifetimes: Vec<Lifetime>, pub lifetimes: Vec<Lifetime>,
@ -333,7 +335,7 @@ impl AngleBracketedParameterData {
} }
/// A path like `Foo(A,B) -> C` /// A path like `Foo(A,B) -> C`
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct ParenthesizedParameterData { pub struct ParenthesizedParameterData {
/// `(A,B)` /// `(A,B)`
pub inputs: Vec<P<Ty>>, pub inputs: Vec<P<Ty>>,
@ -346,7 +348,8 @@ pub type CrateNum = u32;
pub type NodeId = u32; pub type NodeId = u32;
#[deriving(Clone, Copy, Eq, Ord, PartialOrd, PartialEq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, Eq, Ord, PartialOrd, PartialEq, RustcEncodable,
RustcDecodable, Hash, Show, Copy)]
pub struct DefId { pub struct DefId {
pub krate: CrateNum, pub krate: CrateNum,
pub node: NodeId, pub node: NodeId,
@ -366,7 +369,7 @@ pub const DUMMY_NODE_ID: NodeId = -1;
/// typeck::collect::compute_bounds matches these against /// typeck::collect::compute_bounds matches these against
/// the "special" built-in traits (see middle::lang_items) and /// the "special" built-in traits (see middle::lang_items) and
/// detects Copy, Send and Sync. /// detects Copy, Send and Sync.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum TyParamBound { pub enum TyParamBound {
TraitTyParamBound(PolyTraitRef), TraitTyParamBound(PolyTraitRef),
RegionTyParamBound(Lifetime) RegionTyParamBound(Lifetime)
@ -374,7 +377,7 @@ pub enum TyParamBound {
pub type TyParamBounds = OwnedSlice<TyParamBound>; pub type TyParamBounds = OwnedSlice<TyParamBound>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct TyParam { pub struct TyParam {
pub ident: Ident, pub ident: Ident,
pub id: NodeId, pub id: NodeId,
@ -386,7 +389,7 @@ pub struct TyParam {
/// Represents lifetimes and type parameters attached to a declaration /// Represents lifetimes and type parameters attached to a declaration
/// of a function, enum, trait, etc. /// of a function, enum, trait, etc.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Generics { pub struct Generics {
pub lifetimes: Vec<LifetimeDef>, pub lifetimes: Vec<LifetimeDef>,
pub ty_params: OwnedSlice<TyParam>, pub ty_params: OwnedSlice<TyParam>,
@ -405,34 +408,34 @@ impl Generics {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct WhereClause { pub struct WhereClause {
pub id: NodeId, pub id: NodeId,
pub predicates: Vec<WherePredicate>, pub predicates: Vec<WherePredicate>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum WherePredicate { pub enum WherePredicate {
BoundPredicate(WhereBoundPredicate), BoundPredicate(WhereBoundPredicate),
RegionPredicate(WhereRegionPredicate), RegionPredicate(WhereRegionPredicate),
EqPredicate(WhereEqPredicate) EqPredicate(WhereEqPredicate)
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct WhereBoundPredicate { pub struct WhereBoundPredicate {
pub span: Span, pub span: Span,
pub bounded_ty: P<Ty>, pub bounded_ty: P<Ty>,
pub bounds: OwnedSlice<TyParamBound>, pub bounds: OwnedSlice<TyParamBound>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct WhereRegionPredicate { pub struct WhereRegionPredicate {
pub span: Span, pub span: Span,
pub lifetime: Lifetime, pub lifetime: Lifetime,
pub bounds: Vec<Lifetime>, pub bounds: Vec<Lifetime>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct WhereEqPredicate { pub struct WhereEqPredicate {
pub id: NodeId, pub id: NodeId,
pub span: Span, pub span: Span,
@ -444,7 +447,7 @@ pub struct WhereEqPredicate {
/// used to drive conditional compilation /// used to drive conditional compilation
pub type CrateConfig = Vec<P<MetaItem>> ; pub type CrateConfig = Vec<P<MetaItem>> ;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Crate { pub struct Crate {
pub module: Mod, pub module: Mod,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -455,7 +458,7 @@ pub struct Crate {
pub type MetaItem = Spanned<MetaItem_>; pub type MetaItem = Spanned<MetaItem_>;
#[deriving(Clone, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum MetaItem_ { pub enum MetaItem_ {
MetaWord(InternedString), MetaWord(InternedString),
MetaList(InternedString, Vec<P<MetaItem>>), MetaList(InternedString, Vec<P<MetaItem>>),
@ -487,7 +490,7 @@ impl PartialEq for MetaItem_ {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Block { pub struct Block {
pub view_items: Vec<ViewItem>, pub view_items: Vec<ViewItem>,
pub stmts: Vec<P<Stmt>>, pub stmts: Vec<P<Stmt>>,
@ -497,27 +500,27 @@ pub struct Block {
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Pat { pub struct Pat {
pub id: NodeId, pub id: NodeId,
pub node: Pat_, pub node: Pat_,
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct FieldPat { pub struct FieldPat {
pub ident: Ident, pub ident: Ident,
pub pat: P<Pat>, pub pat: P<Pat>,
pub is_shorthand: bool, pub is_shorthand: bool,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum BindingMode { pub enum BindingMode {
BindByRef(Mutability), BindByRef(Mutability),
BindByValue(Mutability), BindByValue(Mutability),
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum PatWildKind { pub enum PatWildKind {
/// Represents the wildcard pattern `_` /// Represents the wildcard pattern `_`
PatWildSingle, PatWildSingle,
@ -526,7 +529,7 @@ pub enum PatWildKind {
PatWildMulti, PatWildMulti,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum Pat_ { pub enum Pat_ {
/// Represents a wildcard pattern (either `_` or `..`) /// Represents a wildcard pattern (either `_` or `..`)
PatWild(PatWildKind), PatWild(PatWildKind),
@ -555,13 +558,13 @@ pub enum Pat_ {
PatMac(Mac), PatMac(Mac),
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum Mutability { pub enum Mutability {
MutMutable, MutMutable,
MutImmutable, MutImmutable,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum BinOp { pub enum BinOp {
BiAdd, BiAdd,
BiSub, BiSub,
@ -583,7 +586,7 @@ pub enum BinOp {
BiGt, BiGt,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum UnOp { pub enum UnOp {
UnUniq, UnUniq,
UnDeref, UnDeref,
@ -593,7 +596,7 @@ pub enum UnOp {
pub type Stmt = Spanned<Stmt_>; pub type Stmt = Spanned<Stmt_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum Stmt_ { pub enum Stmt_ {
/// Could be an item or a local (let) binding: /// Could be an item or a local (let) binding:
StmtDecl(P<Decl>, NodeId), StmtDecl(P<Decl>, NodeId),
@ -607,7 +610,7 @@ pub enum Stmt_ {
StmtMac(Mac, MacStmtStyle), StmtMac(Mac, MacStmtStyle),
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum MacStmtStyle { pub enum MacStmtStyle {
/// The macro statement had a trailing semicolon, e.g. `foo! { ... };` /// The macro statement had a trailing semicolon, e.g. `foo! { ... };`
/// `foo!(...);`, `foo![...];` /// `foo!(...);`, `foo![...];`
@ -622,7 +625,7 @@ pub enum MacStmtStyle {
/// Where a local declaration came from: either a true `let ... = /// Where a local declaration came from: either a true `let ... =
/// ...;`, or one desugared from the pattern of a for loop. /// ...;`, or one desugared from the pattern of a for loop.
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum LocalSource { pub enum LocalSource {
LocalLet, LocalLet,
LocalFor, LocalFor,
@ -631,7 +634,7 @@ pub enum LocalSource {
// FIXME (pending discussion of #1697, #2178...): local should really be // FIXME (pending discussion of #1697, #2178...): local should really be
// a refinement on pat. // a refinement on pat.
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;` /// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Local { pub struct Local {
pub ty: P<Ty>, pub ty: P<Ty>,
pub pat: P<Pat>, pub pat: P<Pat>,
@ -643,7 +646,7 @@ pub struct Local {
pub type Decl = Spanned<Decl_>; pub type Decl = Spanned<Decl_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum Decl_ { pub enum Decl_ {
/// A local (let) binding: /// A local (let) binding:
DeclLocal(P<Local>), DeclLocal(P<Local>),
@ -652,7 +655,7 @@ pub enum Decl_ {
} }
/// represents one arm of a 'match' /// represents one arm of a 'match'
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Arm { pub struct Arm {
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
pub pats: Vec<P<Pat>>, pub pats: Vec<P<Pat>>,
@ -660,7 +663,7 @@ pub struct Arm {
pub body: P<Expr>, pub body: P<Expr>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Field { pub struct Field {
pub ident: SpannedIdent, pub ident: SpannedIdent,
pub expr: P<Expr>, pub expr: P<Expr>,
@ -669,26 +672,26 @@ pub struct Field {
pub type SpannedIdent = Spanned<Ident>; pub type SpannedIdent = Spanned<Ident>;
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum BlockCheckMode { pub enum BlockCheckMode {
DefaultBlock, DefaultBlock,
UnsafeBlock(UnsafeSource), UnsafeBlock(UnsafeSource),
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum UnsafeSource { pub enum UnsafeSource {
CompilerGenerated, CompilerGenerated,
UserProvided, UserProvided,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Expr { pub struct Expr {
pub id: NodeId, pub id: NodeId,
pub node: Expr_, pub node: Expr_,
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum Expr_ { pub enum Expr_ {
/// First expr is the place; second expr is the value. /// First expr is the place; second expr is the value.
ExprBox(Option<P<Expr>>, P<Expr>), ExprBox(Option<P<Expr>>, P<Expr>),
@ -750,28 +753,28 @@ pub enum Expr_ {
/// <Vec<T> as SomeTrait>::SomeAssociatedItem /// <Vec<T> as SomeTrait>::SomeAssociatedItem
/// ^~~~~ ^~~~~~~~~ ^~~~~~~~~~~~~~~~~~ /// ^~~~~ ^~~~~~~~~ ^~~~~~~~~~~~~~~~~~
/// self_type trait_name item_name /// self_type trait_name item_name
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct QPath { pub struct QPath {
pub self_type: P<Ty>, pub self_type: P<Ty>,
pub trait_ref: P<TraitRef>, pub trait_ref: P<TraitRef>,
pub item_name: Ident, pub item_name: Ident,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum MatchSource { pub enum MatchSource {
Normal, Normal,
IfLetDesugar { contains_else_clause: bool }, IfLetDesugar { contains_else_clause: bool },
WhileLetDesugar, WhileLetDesugar,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum CaptureClause { pub enum CaptureClause {
CaptureByValue, CaptureByValue,
CaptureByRef, CaptureByRef,
} }
/// A delimited sequence of token trees /// A delimited sequence of token trees
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Delimited { pub struct Delimited {
/// The type of delimiter /// The type of delimiter
pub delim: token::DelimToken, pub delim: token::DelimToken,
@ -806,7 +809,7 @@ impl Delimited {
} }
/// A sequence of token treesee /// A sequence of token treesee
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct SequenceRepetition { pub struct SequenceRepetition {
/// The sequence of token trees /// The sequence of token trees
pub tts: Vec<TokenTree>, pub tts: Vec<TokenTree>,
@ -820,7 +823,7 @@ pub struct SequenceRepetition {
/// A Kleene-style [repetition operator](http://en.wikipedia.org/wiki/Kleene_star) /// A Kleene-style [repetition operator](http://en.wikipedia.org/wiki/Kleene_star)
/// for token sequences. /// for token sequences.
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum KleeneOp { pub enum KleeneOp {
ZeroOrMore, ZeroOrMore,
OneOrMore, OneOrMore,
@ -838,7 +841,7 @@ pub enum KleeneOp {
/// ///
/// The RHS of an MBE macro is the only place `SubstNt`s are substituted. /// The RHS of an MBE macro is the only place `SubstNt`s are substituted.
/// Nothing special happens to misnamed or misplaced `SubstNt`s. /// Nothing special happens to misnamed or misplaced `SubstNt`s.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
#[doc="For macro invocations; parsing is delegated to the macro"] #[doc="For macro invocations; parsing is delegated to the macro"]
pub enum TokenTree { pub enum TokenTree {
/// A single token /// A single token
@ -928,14 +931,14 @@ pub type Mac = Spanned<Mac_>;
/// is being invoked, and the vector of token-trees contains the source /// is being invoked, and the vector of token-trees contains the source
/// of the macro invocation. /// of the macro invocation.
/// There's only one flavor, now, so this could presumably be simplified. /// There's only one flavor, now, so this could presumably be simplified.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum Mac_ { pub enum Mac_ {
// NB: the additional ident for a macro_rules-style macro is actually // NB: the additional ident for a macro_rules-style macro is actually
// stored in the enclosing item. Oog. // stored in the enclosing item. Oog.
MacInvocTT(Path, Vec<TokenTree> , SyntaxContext), // new macro-invocation MacInvocTT(Path, Vec<TokenTree> , SyntaxContext), // new macro-invocation
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum StrStyle { pub enum StrStyle {
CookedStr, CookedStr,
RawStr(uint) RawStr(uint)
@ -943,7 +946,7 @@ pub enum StrStyle {
pub type Lit = Spanned<Lit_>; pub type Lit = Spanned<Lit_>;
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum Sign { pub enum Sign {
Minus, Minus,
Plus Plus
@ -959,7 +962,7 @@ impl<T> Sign where T: Int {
} }
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum LitIntType { pub enum LitIntType {
SignedIntLit(IntTy, Sign), SignedIntLit(IntTy, Sign),
UnsignedIntLit(UintTy), UnsignedIntLit(UintTy),
@ -976,7 +979,7 @@ impl LitIntType {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum Lit_ { pub enum Lit_ {
LitStr(InternedString, StrStyle), LitStr(InternedString, StrStyle),
LitBinary(Rc<Vec<u8> >), LitBinary(Rc<Vec<u8> >),
@ -990,13 +993,13 @@ pub enum Lit_ {
// NB: If you change this, you'll probably want to change the corresponding // NB: If you change this, you'll probably want to change the corresponding
// type structure in middle/ty.rs as well. // type structure in middle/ty.rs as well.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct MutTy { pub struct MutTy {
pub ty: P<Ty>, pub ty: P<Ty>,
pub mutbl: Mutability, pub mutbl: Mutability,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct TypeField { pub struct TypeField {
pub ident: Ident, pub ident: Ident,
pub mt: MutTy, pub mt: MutTy,
@ -1005,7 +1008,7 @@ pub struct TypeField {
/// Represents a required method in a trait declaration, /// Represents a required method in a trait declaration,
/// one without a default implementation /// one without a default implementation
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct TypeMethod { pub struct TypeMethod {
pub ident: Ident, pub ident: Ident,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -1023,26 +1026,26 @@ pub struct TypeMethod {
/// a default implementation A trait method is either required (meaning it /// a default implementation A trait method is either required (meaning it
/// doesn't have an implementation, just a signature) or provided (meaning it /// doesn't have an implementation, just a signature) or provided (meaning it
/// has a default implementation). /// has a default implementation).
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum TraitItem { pub enum TraitItem {
RequiredMethod(TypeMethod), RequiredMethod(TypeMethod),
ProvidedMethod(P<Method>), ProvidedMethod(P<Method>),
TypeTraitItem(P<AssociatedType>), TypeTraitItem(P<AssociatedType>),
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum ImplItem { pub enum ImplItem {
MethodImplItem(P<Method>), MethodImplItem(P<Method>),
TypeImplItem(P<Typedef>), TypeImplItem(P<Typedef>),
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct AssociatedType { pub struct AssociatedType {
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
pub ty_param: TyParam, pub ty_param: TyParam,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Typedef { pub struct Typedef {
pub id: NodeId, pub id: NodeId,
pub span: Span, pub span: Span,
@ -1052,7 +1055,7 @@ pub struct Typedef {
pub typ: P<Ty>, pub typ: P<Ty>,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub enum IntTy { pub enum IntTy {
TyI, TyI,
TyI8, TyI8,
@ -1077,7 +1080,7 @@ impl IntTy {
} }
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub enum UintTy { pub enum UintTy {
TyU, TyU,
TyU8, TyU8,
@ -1102,7 +1105,7 @@ impl fmt::Show for UintTy {
} }
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub enum FloatTy { pub enum FloatTy {
TyF32, TyF32,
TyF64, TyF64,
@ -1123,7 +1126,7 @@ impl FloatTy {
} }
// Bind a type to an associated type: `A=Foo`. // Bind a type to an associated type: `A=Foo`.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct TypeBinding { pub struct TypeBinding {
pub id: NodeId, pub id: NodeId,
pub ident: Ident, pub ident: Ident,
@ -1133,7 +1136,7 @@ pub struct TypeBinding {
// NB PartialEq method appears below. // NB PartialEq method appears below.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Ty { pub struct Ty {
pub id: NodeId, pub id: NodeId,
pub node: Ty_, pub node: Ty_,
@ -1141,7 +1144,7 @@ pub struct Ty {
} }
/// Not represented directly in the AST, referred to by name through a ty_path. /// Not represented directly in the AST, referred to by name through a ty_path.
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum PrimTy { pub enum PrimTy {
TyInt(IntTy), TyInt(IntTy),
TyUint(UintTy), TyUint(UintTy),
@ -1151,7 +1154,7 @@ pub enum PrimTy {
TyChar TyChar
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub enum Onceness { pub enum Onceness {
Once, Once,
Many Many
@ -1167,7 +1170,7 @@ impl fmt::Show for Onceness {
} }
/// Represents the type of a closure /// Represents the type of a closure
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct ClosureTy { pub struct ClosureTy {
pub lifetimes: Vec<LifetimeDef>, pub lifetimes: Vec<LifetimeDef>,
pub unsafety: Unsafety, pub unsafety: Unsafety,
@ -1176,7 +1179,7 @@ pub struct ClosureTy {
pub bounds: TyParamBounds, pub bounds: TyParamBounds,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct BareFnTy { pub struct BareFnTy {
pub unsafety: Unsafety, pub unsafety: Unsafety,
pub abi: Abi, pub abi: Abi,
@ -1184,7 +1187,7 @@ pub struct BareFnTy {
pub decl: P<FnDecl> pub decl: P<FnDecl>
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
/// The different kinds of types recognized by the compiler /// The different kinds of types recognized by the compiler
pub enum Ty_ { pub enum Ty_ {
TyVec(P<Ty>), TyVec(P<Ty>),
@ -1219,13 +1222,13 @@ pub enum Ty_ {
TyInfer, TyInfer,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum AsmDialect { pub enum AsmDialect {
AsmAtt, AsmAtt,
AsmIntel AsmIntel
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct InlineAsm { pub struct InlineAsm {
pub asm: InternedString, pub asm: InternedString,
pub asm_str_style: StrStyle, pub asm_str_style: StrStyle,
@ -1239,7 +1242,7 @@ pub struct InlineAsm {
} }
/// represents an argument in a function header /// represents an argument in a function header
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Arg { pub struct Arg {
pub ty: P<Ty>, pub ty: P<Ty>,
pub pat: P<Pat>, pub pat: P<Pat>,
@ -1267,14 +1270,14 @@ impl Arg {
} }
/// represents the header (not the body) of a function declaration /// represents the header (not the body) of a function declaration
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct FnDecl { pub struct FnDecl {
pub inputs: Vec<Arg>, pub inputs: Vec<Arg>,
pub output: FunctionRetTy, pub output: FunctionRetTy,
pub variadic: bool pub variadic: bool
} }
#[deriving(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash)] #[deriving(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
pub enum Unsafety { pub enum Unsafety {
Unsafe, Unsafe,
Normal, Normal,
@ -1289,7 +1292,7 @@ impl fmt::Show for Unsafety {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum FunctionRetTy { pub enum FunctionRetTy {
/// Functions with return type ! that always /// Functions with return type ! that always
/// raise an error or exit (i.e. never return to the caller) /// raise an error or exit (i.e. never return to the caller)
@ -1308,7 +1311,7 @@ impl FunctionRetTy {
} }
/// Represents the kind of 'self' associated with a method /// Represents the kind of 'self' associated with a method
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum ExplicitSelf_ { pub enum ExplicitSelf_ {
/// No self /// No self
SelfStatic, SelfStatic,
@ -1322,7 +1325,7 @@ pub enum ExplicitSelf_ {
pub type ExplicitSelf = Spanned<ExplicitSelf_>; pub type ExplicitSelf = Spanned<ExplicitSelf_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Method { pub struct Method {
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
pub id: NodeId, pub id: NodeId,
@ -1330,7 +1333,7 @@ pub struct Method {
pub node: Method_, pub node: Method_,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum Method_ { pub enum Method_ {
/// Represents a method declaration /// Represents a method declaration
MethDecl(Ident, MethDecl(Ident,
@ -1345,7 +1348,7 @@ pub enum Method_ {
MethMac(Mac), MethMac(Mac),
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Mod { pub struct Mod {
/// A span from the first token past `{` to the last token until `}`. /// A span from the first token past `{` to the last token until `}`.
/// For `mod foo;`, the inner span ranges from the first token /// For `mod foo;`, the inner span ranges from the first token
@ -1355,31 +1358,31 @@ pub struct Mod {
pub items: Vec<P<Item>>, pub items: Vec<P<Item>>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct ForeignMod { pub struct ForeignMod {
pub abi: Abi, pub abi: Abi,
pub view_items: Vec<ViewItem>, pub view_items: Vec<ViewItem>,
pub items: Vec<P<ForeignItem>>, pub items: Vec<P<ForeignItem>>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct VariantArg { pub struct VariantArg {
pub ty: P<Ty>, pub ty: P<Ty>,
pub id: NodeId, pub id: NodeId,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum VariantKind { pub enum VariantKind {
TupleVariantKind(Vec<VariantArg>), TupleVariantKind(Vec<VariantArg>),
StructVariantKind(P<StructDef>), StructVariantKind(P<StructDef>),
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct EnumDef { pub struct EnumDef {
pub variants: Vec<P<Variant>>, pub variants: Vec<P<Variant>>,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Variant_ { pub struct Variant_ {
pub name: Ident, pub name: Ident,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -1391,7 +1394,7 @@ pub struct Variant_ {
pub type Variant = Spanned<Variant_>; pub type Variant = Spanned<Variant_>;
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum PathListItem_ { pub enum PathListItem_ {
PathListIdent { name: Ident, id: NodeId }, PathListIdent { name: Ident, id: NodeId },
PathListMod { id: NodeId } PathListMod { id: NodeId }
@ -1409,7 +1412,7 @@ pub type PathListItem = Spanned<PathListItem_>;
pub type ViewPath = Spanned<ViewPath_>; pub type ViewPath = Spanned<ViewPath_>;
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum ViewPath_ { pub enum ViewPath_ {
/// `foo::bar::baz as quux` /// `foo::bar::baz as quux`
@ -1426,7 +1429,7 @@ pub enum ViewPath_ {
ViewPathList(Path, Vec<PathListItem> , NodeId) ViewPathList(Path, Vec<PathListItem> , NodeId)
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct ViewItem { pub struct ViewItem {
pub node: ViewItem_, pub node: ViewItem_,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -1434,7 +1437,7 @@ pub struct ViewItem {
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum ViewItem_ { pub enum ViewItem_ {
/// Ident: name used to refer to this crate in the code /// Ident: name used to refer to this crate in the code
/// optional (InternedString,StrStyle): if present, this is a location /// optional (InternedString,StrStyle): if present, this is a location
@ -1450,17 +1453,17 @@ pub type Attribute = Spanned<Attribute_>;
/// Distinguishes between Attributes that decorate items and Attributes that /// Distinguishes between Attributes that decorate items and Attributes that
/// are contained as statements within items. These two cases need to be /// are contained as statements within items. These two cases need to be
/// distinguished for pretty-printing. /// distinguished for pretty-printing.
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum AttrStyle { pub enum AttrStyle {
AttrOuter, AttrOuter,
AttrInner, AttrInner,
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub struct AttrId(pub uint); pub struct AttrId(pub uint);
/// Doc-comments are promoted to attributes that have is_sugared_doc = true /// Doc-comments are promoted to attributes that have is_sugared_doc = true
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Attribute_ { pub struct Attribute_ {
pub id: AttrId, pub id: AttrId,
pub style: AttrStyle, pub style: AttrStyle,
@ -1473,13 +1476,13 @@ pub struct Attribute_ {
/// that the ref_id is for. The impl_id maps to the "self type" of this impl. /// that the ref_id is for. The impl_id maps to the "self type" of this impl.
/// If this impl is an ItemImpl, the impl_id is redundant (it could be the /// If this impl is an ItemImpl, the impl_id is redundant (it could be the
/// same as the impl's node id). /// same as the impl's node id).
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct TraitRef { pub struct TraitRef {
pub path: Path, pub path: Path,
pub ref_id: NodeId, pub ref_id: NodeId,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct PolyTraitRef { pub struct PolyTraitRef {
/// The `'a` in `<'a> Foo<&'a T>` /// The `'a` in `<'a> Foo<&'a T>`
pub bound_lifetimes: Vec<LifetimeDef>, pub bound_lifetimes: Vec<LifetimeDef>,
@ -1488,7 +1491,7 @@ pub struct PolyTraitRef {
pub trait_ref: TraitRef pub trait_ref: TraitRef
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum Visibility { pub enum Visibility {
Public, Public,
Inherited, Inherited,
@ -1503,7 +1506,7 @@ impl Visibility {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct StructField_ { pub struct StructField_ {
pub kind: StructFieldKind, pub kind: StructFieldKind,
pub id: NodeId, pub id: NodeId,
@ -1522,7 +1525,7 @@ impl StructField_ {
pub type StructField = Spanned<StructField_>; pub type StructField = Spanned<StructField_>;
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum StructFieldKind { pub enum StructFieldKind {
NamedField(Ident, Visibility), NamedField(Ident, Visibility),
/// Element of a tuple-like struct /// Element of a tuple-like struct
@ -1538,7 +1541,7 @@ impl StructFieldKind {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct StructDef { pub struct StructDef {
/// Fields, not including ctor /// Fields, not including ctor
pub fields: Vec<StructField>, pub fields: Vec<StructField>,
@ -1551,7 +1554,7 @@ pub struct StructDef {
FIXME (#3300): Should allow items to be anonymous. Right now FIXME (#3300): Should allow items to be anonymous. Right now
we just use dummy names for anon items. we just use dummy names for anon items.
*/ */
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct Item { pub struct Item {
pub ident: Ident, pub ident: Ident,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -1561,7 +1564,7 @@ pub struct Item {
pub span: Span, pub span: Span,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum Item_ { pub enum Item_ {
ItemStatic(P<Ty>, Mutability, P<Expr>), ItemStatic(P<Ty>, Mutability, P<Expr>),
ItemConst(P<Ty>, P<Expr>), ItemConst(P<Ty>, P<Expr>),
@ -1605,7 +1608,7 @@ impl Item_ {
} }
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub struct ForeignItem { pub struct ForeignItem {
pub ident: Ident, pub ident: Ident,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
@ -1615,7 +1618,7 @@ pub struct ForeignItem {
pub vis: Visibility, pub vis: Visibility,
} }
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum ForeignItem_ { pub enum ForeignItem_ {
ForeignItemFn(P<FnDecl>, Generics), ForeignItemFn(P<FnDecl>, Generics),
ForeignItemStatic(P<Ty>, /* is_mutbl */ bool), ForeignItemStatic(P<Ty>, /* is_mutbl */ bool),
@ -1630,7 +1633,7 @@ impl ForeignItem_ {
} }
} }
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum UnboxedClosureKind { pub enum UnboxedClosureKind {
FnUnboxedClosureKind, FnUnboxedClosureKind,
FnMutUnboxedClosureKind, FnMutUnboxedClosureKind,
@ -1640,7 +1643,7 @@ pub enum UnboxedClosureKind {
/// The data we save and restore about an inlined item or method. This is not /// 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 /// part of the AST that we parse from a file, but it becomes part of the tree
/// that we trans. /// that we trans.
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
pub enum InlinedItem { pub enum InlinedItem {
IIItem(P<Item>), IIItem(P<Item>),
IITraitItem(DefId /* impl id */, TraitItem), IITraitItem(DefId /* impl id */, TraitItem),

View File

@ -343,7 +343,7 @@ pub fn empty_generics() -> Generics {
// ______________________________________________________________________ // ______________________________________________________________________
// Enumerating the IDs which appear in an AST // Enumerating the IDs which appear in an AST
#[deriving(Copy, Encodable, Decodable, Show)] #[deriving(RustcEncodable, RustcDecodable, Show, Copy)]
pub struct IdRange { pub struct IdRange {
pub min: NodeId, pub min: NodeId,
pub max: NodeId, pub max: NodeId,

View File

@ -340,14 +340,14 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me
} }
/// Represents the #[deprecated="foo"] and friends attributes. /// Represents the #[deprecated="foo"] and friends attributes.
#[deriving(Encodable,Decodable,Clone,Show)] #[deriving(RustcEncodable,RustcDecodable,Clone,Show)]
pub struct Stability { pub struct Stability {
pub level: StabilityLevel, pub level: StabilityLevel,
pub text: Option<InternedString> pub text: Option<InternedString>
} }
/// The available stability levels. /// The available stability levels.
#[deriving(Copy,Encodable,Decodable,PartialEq,PartialOrd,Clone,Show)] #[deriving(RustcEncodable,RustcDecodable,PartialEq,PartialOrd,Clone,Show,Copy)]
pub enum StabilityLevel { pub enum StabilityLevel {
Deprecated, Deprecated,
Experimental, Experimental,
@ -464,7 +464,7 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
} }
} }
#[deriving(Copy, PartialEq, Show, Encodable, Decodable)] #[deriving(PartialEq, Show, RustcEncodable, RustcDecodable, Copy)]
pub enum ReprAttr { pub enum ReprAttr {
ReprAny, ReprAny,
ReprInt(Span, IntType), ReprInt(Span, IntType),
@ -483,7 +483,7 @@ impl ReprAttr {
} }
} }
#[deriving(Copy, Eq, Hash, PartialEq, Show, Encodable, Decodable)] #[deriving(Eq, Hash, PartialEq, Show, RustcEncodable, RustcDecodable, Copy)]
pub enum IntType { pub enum IntType {
SignedInt(ast::IntTy), SignedInt(ast::IntTy),
UnsignedInt(ast::UintTy) UnsignedInt(ast::UintTy)

View File

@ -92,7 +92,7 @@ pub struct Span {
pub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION }; pub const DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_id: NO_EXPANSION };
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub struct Spanned<T> { pub struct Spanned<T> {
pub node: T, pub node: T,
pub span: Span, pub span: Span,
@ -218,7 +218,7 @@ pub struct ExpnInfo {
pub callee: NameAndSpan pub callee: NameAndSpan
} }
#[deriving(Copy, PartialEq, Eq, Clone, Show, Hash, Encodable, Decodable)] #[deriving(PartialEq, Eq, Clone, Show, Hash, RustcEncodable, RustcDecodable, Copy)]
pub struct ExpnId(u32); pub struct ExpnId(u32);
pub const NO_EXPANSION: ExpnId = ExpnId(-1); pub const NO_EXPANSION: ExpnId = ExpnId(-1);

View File

@ -21,24 +21,45 @@ use parse::token::InternedString;
use parse::token; use parse::token;
use ptr::P; use ptr::P;
pub fn expand_deriving_rustc_decodable<F>(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Item,
push: F) where
F: FnOnce(P<Item>),
{
expand_deriving_decodable_imp(cx, span, mitem, item, push, "rustc_serialize")
}
pub fn expand_deriving_decodable<F>(cx: &mut ExtCtxt, pub fn expand_deriving_decodable<F>(cx: &mut ExtCtxt,
span: Span, span: Span,
mitem: &MetaItem, mitem: &MetaItem,
item: &Item, item: &Item,
push: F) where push: F) where
F: FnOnce(P<Item>), F: FnOnce(P<Item>),
{
expand_deriving_decodable_imp(cx, span, mitem, item, push, "serialize")
}
fn expand_deriving_decodable_imp<F>(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Item,
push: F,
krate: &'static str) where
F: FnOnce(P<Item>),
{ {
let trait_def = TraitDef { let trait_def = TraitDef {
span: span, span: span,
attributes: Vec::new(), attributes: Vec::new(),
path: Path::new_(vec!("serialize", "Decodable"), None, path: Path::new_(vec!(krate, "Decodable"), None,
vec!(box Literal(Path::new_local("__D")), vec!(box Literal(Path::new_local("__D")),
box Literal(Path::new_local("__E"))), true), box Literal(Path::new_local("__E"))), true),
additional_bounds: Vec::new(), additional_bounds: Vec::new(),
generics: LifetimeBounds { generics: LifetimeBounds {
lifetimes: Vec::new(), lifetimes: Vec::new(),
bounds: vec!(("__D", None, vec!(Path::new_( bounds: vec!(("__D", None, vec!(Path::new_(
vec!("serialize", "Decoder"), None, vec!(krate, "Decoder"), None,
vec!(box Literal(Path::new_local("__E"))), true))), vec!(box Literal(Path::new_local("__E"))), true))),
("__E", None, vec!())) ("__E", None, vec!()))
}, },
@ -54,7 +75,7 @@ pub fn expand_deriving_decodable<F>(cx: &mut ExtCtxt,
box Literal(Path::new_local("__E"))), true)), box Literal(Path::new_local("__E"))), true)),
attributes: Vec::new(), attributes: Vec::new(),
combine_substructure: combine_substructure(|a, b, c| { combine_substructure: combine_substructure(|a, b, c| {
decodable_substructure(a, b, c) decodable_substructure(a, b, c, krate)
}), }),
}) })
}; };
@ -63,9 +84,10 @@ pub fn expand_deriving_decodable<F>(cx: &mut ExtCtxt,
} }
fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span, fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
substr: &Substructure) -> P<Expr> { substr: &Substructure,
krate: &str) -> P<Expr> {
let decoder = substr.nonself_args[0].clone(); let decoder = substr.nonself_args[0].clone();
let recurse = vec!(cx.ident_of("serialize"), let recurse = vec!(cx.ident_of(krate),
cx.ident_of("Decodable"), cx.ident_of("Decodable"),
cx.ident_of("decode")); cx.ident_of("decode"));
// throw an underscore in front to suppress unused variable warnings // throw an underscore in front to suppress unused variable warnings

View File

@ -97,24 +97,45 @@ use ext::deriving::generic::ty::*;
use parse::token; use parse::token;
use ptr::P; use ptr::P;
pub fn expand_deriving_rustc_encodable<F>(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Item,
push: F) where
F: FnOnce(P<Item>),
{
expand_deriving_encodable_imp(cx, span, mitem, item, push, "rustc_serialize")
}
pub fn expand_deriving_encodable<F>(cx: &mut ExtCtxt, pub fn expand_deriving_encodable<F>(cx: &mut ExtCtxt,
span: Span, span: Span,
mitem: &MetaItem, mitem: &MetaItem,
item: &Item, item: &Item,
push: F) where push: F) where
F: FnOnce(P<Item>), F: FnOnce(P<Item>),
{
expand_deriving_encodable_imp(cx, span, mitem, item, push, "serialize")
}
fn expand_deriving_encodable_imp<F>(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Item,
push: F,
krate: &'static str) where
F: FnOnce(P<Item>),
{ {
let trait_def = TraitDef { let trait_def = TraitDef {
span: span, span: span,
attributes: Vec::new(), attributes: Vec::new(),
path: Path::new_(vec!("serialize", "Encodable"), None, path: Path::new_(vec!(krate, "Encodable"), None,
vec!(box Literal(Path::new_local("__S")), vec!(box Literal(Path::new_local("__S")),
box Literal(Path::new_local("__E"))), true), box Literal(Path::new_local("__E"))), true),
additional_bounds: Vec::new(), additional_bounds: Vec::new(),
generics: LifetimeBounds { generics: LifetimeBounds {
lifetimes: Vec::new(), lifetimes: Vec::new(),
bounds: vec!(("__S", None, vec!(Path::new_( bounds: vec!(("__S", None, vec!(Path::new_(
vec!("serialize", "Encoder"), None, vec!(krate, "Encoder"), None,
vec!(box Literal(Path::new_local("__E"))), true))), vec!(box Literal(Path::new_local("__E"))), true))),
("__E", None, vec!())) ("__E", None, vec!()))
}, },

View File

@ -71,24 +71,22 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
"Hash" => expand!(hash::expand_deriving_hash), "Hash" => expand!(hash::expand_deriving_hash),
"RustcEncodable" => { "RustcEncodable" => {
expand!(encodable::expand_deriving_encodable) expand!(encodable::expand_deriving_rustc_encodable)
} }
"RustcDecodable" => { "RustcDecodable" => {
expand!(decodable::expand_deriving_decodable) expand!(decodable::expand_deriving_rustc_decodable)
} }
"Encodable" => { "Encodable" => {
// NOTE: uncomment after a stage0 snap cx.span_warn(titem.span,
// cx.span_warn(titem.span, "deriving(Encodable) is deprecated \
// "deriving(Encodable) is deprecated \ in favor of deriving(RustcEncodable)");
// in favor of deriving(RustcEncodable)");
expand!(encodable::expand_deriving_encodable) expand!(encodable::expand_deriving_encodable)
} }
"Decodable" => { "Decodable" => {
// NOTE: uncomment after a stage0 snap cx.span_warn(titem.span,
// cx.span_warn(titem.span, "deriving(Decodable) is deprecated \
// "deriving(Decodable) is deprecated \ in favor of deriving(RustcDecodable)");
// in favor of deriving(RustcDecodable)");
expand!(decodable::expand_deriving_decodable) expand!(decodable::expand_deriving_decodable)
} }

View File

@ -39,7 +39,7 @@ pub struct SCTable {
rename_memo: RefCell<HashMap<(SyntaxContext,Ident,Name),SyntaxContext>>, rename_memo: RefCell<HashMap<(SyntaxContext,Ident,Name),SyntaxContext>>,
} }
#[deriving(Copy, PartialEq, Encodable, Decodable, Hash, Show)] #[deriving(PartialEq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum SyntaxContext_ { pub enum SyntaxContext_ {
EmptyCtxt, EmptyCtxt,
Mark (Mrk,SyntaxContext), Mark (Mrk,SyntaxContext),

View File

@ -34,6 +34,8 @@ extern crate serialize;
extern crate term; extern crate term;
extern crate libc; extern crate libc;
extern crate "serialize" as rustc_serialize; // used by deriving
pub mod util { pub mod util {
pub mod interner; pub mod interner;
#[cfg(test)] #[cfg(test)]

View File

@ -28,7 +28,7 @@ use std::path::BytesContainer;
use std::rc::Rc; use std::rc::Rc;
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Show, Copy)]
pub enum BinOpToken { pub enum BinOpToken {
Plus, Plus,
Minus, Minus,
@ -43,7 +43,7 @@ pub enum BinOpToken {
} }
/// A delimeter token /// A delimeter token
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Show, Copy)]
pub enum DelimToken { pub enum DelimToken {
/// A round parenthesis: `(` or `)` /// A round parenthesis: `(` or `)`
Paren, Paren,
@ -53,14 +53,14 @@ pub enum DelimToken {
Brace, Brace,
} }
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Show, Copy)]
pub enum IdentStyle { pub enum IdentStyle {
/// `::` follows the identifier with no whitespace in-between. /// `::` follows the identifier with no whitespace in-between.
ModName, ModName,
Plain, Plain,
} }
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Show, Copy)]
pub enum Lit { pub enum Lit {
Byte(ast::Name), Byte(ast::Name),
Char(ast::Name), Char(ast::Name),
@ -86,7 +86,7 @@ impl Lit {
} }
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Show)]
pub enum Token { pub enum Token {
/* Expression-operator symbols. */ /* Expression-operator symbols. */
Eq, Eq,
@ -334,7 +334,7 @@ impl Token {
} }
} }
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash)]
/// For interpolation during macro expansion. /// For interpolation during macro expansion.
pub enum Nonterminal { pub enum Nonterminal {
NtItem(P<ast::Item>), NtItem(P<ast::Item>),

View File

@ -37,6 +37,7 @@
extern crate getopts; extern crate getopts;
extern crate regex; extern crate regex;
extern crate serialize; extern crate serialize;
extern crate "serialize" as rustc_serialize;
extern crate term; extern crate term;
pub use self::TestFn::*; pub use self::TestFn::*;
@ -213,7 +214,7 @@ pub struct TestDescAndFn {
pub testfn: TestFn, pub testfn: TestFn,
} }
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Show)] #[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Show, Copy)]
pub struct Metric { pub struct Metric {
value: f64, value: f64,
noise: f64 noise: f64

View File

@ -24,7 +24,9 @@
#[cfg(test)] #[phase(plugin, link)] extern crate log; #[cfg(test)] #[phase(plugin, link)] extern crate log;
#[cfg(stage0)]
extern crate serialize; extern crate serialize;
extern crate "serialize" as rustc_serialize;
extern crate libc; extern crate libc;
pub use self::ParseError::*; pub use self::ParseError::*;
@ -76,7 +78,8 @@ mod imp {
} }
/// A record specifying a time value in seconds and nanoseconds. /// A record specifying a time value in seconds and nanoseconds.
#[deriving(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Show)] #[deriving(Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable,
RustcDecodable, Show, Copy)]
pub struct Timespec { pub struct Timespec {
pub sec: i64, pub sec: i64,
pub nsec: i32, pub nsec: i32,