diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-18 22:52:48 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-22 00:14:56 -0800 |
| commit | a76a80276852f05f30adaa4d2a8a2729b5fc0bfa (patch) | |
| tree | 118a535c640013b22519f38dfa9af893dc5986a4 /src/libsyntax | |
| parent | 34d680009205de2302b902d8f9f5f7ae7a042f1a (diff) | |
| download | rust-a76a80276852f05f30adaa4d2a8a2729b5fc0bfa.tar.gz rust-a76a80276852f05f30adaa4d2a8a2729b5fc0bfa.zip | |
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]
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/abi.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 209 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/decodable.rs | 32 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/encodable.rs | 25 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/mod.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/ext/mtwt.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 12 |
11 files changed, 181 insertions, 135 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 70bad90aea1..b1599cb807d 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -26,7 +26,7 @@ pub enum Os { OsDragonfly, } -#[deriving(Copy, PartialEq, Eq, Hash, Encodable, Decodable, Clone)] +#[deriving(PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Clone, Copy)] pub enum Abi { // NB: This ordering MUST match the AbiDatas array below. // (This is ensured by the test indices_are_correct().) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a294706ef2c..b37914ed429 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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 /// 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); impl Name { @@ -187,7 +188,7 @@ impl<S: Encoder<E>, E> Encodable<S, E> for Ident { } } -impl<D:Decoder<E>, E> Decodable<D, E> for Ident { +impl<D: Decoder<E>, E> Decodable<D, E> for Ident { fn decode(d: &mut D) -> Result<Ident, E> { Ok(str_to_ident(try!(d.read_str()).as_slice())) } @@ -196,14 +197,15 @@ impl<D:Decoder<E>, E> Decodable<D, E> for Ident { /// Function name (not all functions have names) 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 id: NodeId, pub span: Span, pub name: Name } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct LifetimeDef { pub lifetime: Lifetime, pub bounds: Vec<Lifetime> @@ -212,7 +214,7 @@ pub struct LifetimeDef { /// A "Path" is essentially Rust's notion of a name; for instance: /// std::cmp::PartialEq . It's represented as a sequence of identifiers, /// 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 span: Span, /// 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 /// types. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct PathSegment { /// The identifier portion of this path segment. pub identifier: Ident, @@ -237,7 +239,7 @@ pub struct PathSegment { pub parameters: PathParameters, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum PathParameters { AngleBracketedParameters(AngleBracketedParameterData), ParenthesizedParameters(ParenthesizedParameterData), @@ -315,7 +317,7 @@ impl PathParameters { } /// 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 { /// The lifetime parameters for this path segment. pub lifetimes: Vec<Lifetime>, @@ -333,7 +335,7 @@ impl AngleBracketedParameterData { } /// 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 { /// `(A,B)` pub inputs: Vec<P<Ty>>, @@ -346,7 +348,8 @@ pub type CrateNum = 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 krate: CrateNum, pub node: NodeId, @@ -366,7 +369,7 @@ pub const DUMMY_NODE_ID: NodeId = -1; /// typeck::collect::compute_bounds matches these against /// the "special" built-in traits (see middle::lang_items) and /// detects Copy, Send and Sync. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum TyParamBound { TraitTyParamBound(PolyTraitRef), RegionTyParamBound(Lifetime) @@ -374,7 +377,7 @@ pub enum 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 ident: Ident, pub id: NodeId, @@ -386,7 +389,7 @@ pub struct TyParam { /// Represents lifetimes and type parameters attached to a declaration /// 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 lifetimes: Vec<LifetimeDef>, 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 id: NodeId, pub predicates: Vec<WherePredicate>, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum WherePredicate { BoundPredicate(WhereBoundPredicate), RegionPredicate(WhereRegionPredicate), EqPredicate(WhereEqPredicate) } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct WhereBoundPredicate { pub span: Span, pub bounded_ty: P<Ty>, pub bounds: OwnedSlice<TyParamBound>, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct WhereRegionPredicate { pub span: Span, pub lifetime: 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 id: NodeId, pub span: Span, @@ -444,7 +447,7 @@ pub struct WhereEqPredicate { /// used to drive conditional compilation 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 module: Mod, pub attrs: Vec<Attribute>, @@ -455,7 +458,7 @@ pub struct Crate { pub type MetaItem = Spanned<MetaItem_>; -#[deriving(Clone, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum MetaItem_ { MetaWord(InternedString), 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 view_items: Vec<ViewItem>, pub stmts: Vec<P<Stmt>>, @@ -497,27 +500,27 @@ pub struct Block { pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct Pat { pub id: NodeId, pub node: Pat_, pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct FieldPat { pub ident: Ident, pub pat: P<Pat>, 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 { BindByRef(Mutability), BindByValue(Mutability), } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] pub enum PatWildKind { /// Represents the wildcard pattern `_` PatWildSingle, @@ -526,7 +529,7 @@ pub enum PatWildKind { PatWildMulti, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum Pat_ { /// Represents a wildcard pattern (either `_` or `..`) PatWild(PatWildKind), @@ -555,13 +558,13 @@ pub enum Pat_ { PatMac(Mac), } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] pub enum Mutability { MutMutable, MutImmutable, } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] pub enum BinOp { BiAdd, BiSub, @@ -583,7 +586,7 @@ pub enum BinOp { BiGt, } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] pub enum UnOp { UnUniq, UnDeref, @@ -593,7 +596,7 @@ pub enum UnOp { pub type Stmt = Spanned<Stmt_>; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum Stmt_ { /// Could be an item or a local (let) binding: StmtDecl(P<Decl>, NodeId), @@ -607,7 +610,7 @@ pub enum Stmt_ { StmtMac(Mac, MacStmtStyle), } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum MacStmtStyle { /// The macro statement had a trailing semicolon, e.g. `foo! { ... };` /// `foo!(...);`, `foo![...];` @@ -622,7 +625,7 @@ pub enum MacStmtStyle { /// Where a local declaration came from: either a true `let ... = /// ...;`, 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 { LocalLet, LocalFor, @@ -631,7 +634,7 @@ pub enum LocalSource { // FIXME (pending discussion of #1697, #2178...): local should really be // a refinement on pat. /// 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 ty: P<Ty>, pub pat: P<Pat>, @@ -643,7 +646,7 @@ pub struct Local { pub type Decl = Spanned<Decl_>; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum Decl_ { /// A local (let) binding: DeclLocal(P<Local>), @@ -652,7 +655,7 @@ pub enum Decl_ { } /// 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 attrs: Vec<Attribute>, pub pats: Vec<P<Pat>>, @@ -660,7 +663,7 @@ pub struct Arm { pub body: P<Expr>, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct Field { pub ident: SpannedIdent, pub expr: P<Expr>, @@ -669,26 +672,26 @@ pub struct Field { 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 { DefaultBlock, UnsafeBlock(UnsafeSource), } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] pub enum UnsafeSource { CompilerGenerated, UserProvided, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct Expr { pub id: NodeId, pub node: Expr_, pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum Expr_ { /// First expr is the place; second expr is the value. ExprBox(Option<P<Expr>>, P<Expr>), @@ -750,28 +753,28 @@ pub enum Expr_ { /// <Vec<T> as SomeTrait>::SomeAssociatedItem /// ^~~~~ ^~~~~~~~~ ^~~~~~~~~~~~~~~~~~ /// 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 self_type: P<Ty>, pub trait_ref: P<TraitRef>, 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 { Normal, IfLetDesugar { contains_else_clause: bool }, WhileLetDesugar, } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] pub enum CaptureClause { CaptureByValue, CaptureByRef, } /// 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 { /// The type of delimiter pub delim: token::DelimToken, @@ -806,7 +809,7 @@ impl Delimited { } /// A sequence of token treesee -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct SequenceRepetition { /// The sequence of token trees pub tts: Vec<TokenTree>, @@ -820,7 +823,7 @@ pub struct SequenceRepetition { /// A Kleene-style [repetition operator](http://en.wikipedia.org/wiki/Kleene_star) /// for token sequences. -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] pub enum KleeneOp { ZeroOrMore, OneOrMore, @@ -838,7 +841,7 @@ pub enum KleeneOp { /// /// The RHS of an MBE macro is the only place `SubstNt`s are substituted. /// 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"] pub enum TokenTree { /// A single token @@ -928,14 +931,14 @@ pub type Mac = Spanned<Mac_>; /// is being invoked, and the vector of token-trees contains the source /// of the macro invocation. /// 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_ { // NB: the additional ident for a macro_rules-style macro is actually // stored in the enclosing item. Oog. 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 { CookedStr, RawStr(uint) @@ -943,7 +946,7 @@ pub enum StrStyle { 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 { Minus, 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 { SignedIntLit(IntTy, Sign), 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_ { LitStr(InternedString, StrStyle), LitBinary(Rc<Vec<u8> >), @@ -990,13 +993,13 @@ pub enum Lit_ { // NB: If you change this, you'll probably want to change the corresponding // 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 ty: P<Ty>, pub mutbl: Mutability, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct TypeField { pub ident: Ident, pub mt: MutTy, @@ -1005,7 +1008,7 @@ pub struct TypeField { /// Represents a required method in a trait declaration, /// 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 ident: Ident, pub attrs: Vec<Attribute>, @@ -1023,26 +1026,26 @@ pub struct TypeMethod { /// a default implementation A trait method is either required (meaning it /// doesn't have an implementation, just a signature) or provided (meaning it /// has a default implementation). -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum TraitItem { RequiredMethod(TypeMethod), ProvidedMethod(P<Method>), TypeTraitItem(P<AssociatedType>), } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum ImplItem { MethodImplItem(P<Method>), TypeImplItem(P<Typedef>), } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct AssociatedType { pub attrs: Vec<Attribute>, pub ty_param: TyParam, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct Typedef { pub id: NodeId, pub span: Span, @@ -1052,7 +1055,7 @@ pub struct Typedef { pub typ: P<Ty>, } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum IntTy { TyI, 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 { TyU, 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 { TyF32, TyF64, @@ -1123,7 +1126,7 @@ impl FloatTy { } // 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 id: NodeId, pub ident: Ident, @@ -1133,7 +1136,7 @@ pub struct TypeBinding { // 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 id: NodeId, pub node: Ty_, @@ -1141,7 +1144,7 @@ pub struct Ty { } /// 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 { TyInt(IntTy), TyUint(UintTy), @@ -1151,7 +1154,7 @@ pub enum PrimTy { TyChar } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub enum Onceness { Once, Many @@ -1167,7 +1170,7 @@ impl fmt::Show for Onceness { } /// 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 lifetimes: Vec<LifetimeDef>, pub unsafety: Unsafety, @@ -1176,7 +1179,7 @@ pub struct ClosureTy { pub bounds: TyParamBounds, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct BareFnTy { pub unsafety: Unsafety, pub abi: Abi, @@ -1184,7 +1187,7 @@ pub struct BareFnTy { 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 pub enum Ty_ { TyVec(P<Ty>), @@ -1219,13 +1222,13 @@ pub enum Ty_ { TyInfer, } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] pub enum AsmDialect { AsmAtt, AsmIntel } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct InlineAsm { pub asm: InternedString, pub asm_str_style: StrStyle, @@ -1239,7 +1242,7 @@ pub struct InlineAsm { } /// 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 ty: P<Ty>, pub pat: P<Pat>, @@ -1267,14 +1270,14 @@ impl Arg { } /// 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 inputs: Vec<Arg>, pub output: FunctionRetTy, pub variadic: bool } -#[deriving(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub enum Unsafety { Unsafe, 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 { /// Functions with return type ! that always /// 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 -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum ExplicitSelf_ { /// No self SelfStatic, @@ -1322,7 +1325,7 @@ pub enum 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 attrs: Vec<Attribute>, pub id: NodeId, @@ -1330,7 +1333,7 @@ pub struct Method { pub node: Method_, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum Method_ { /// Represents a method declaration MethDecl(Ident, @@ -1345,7 +1348,7 @@ pub enum Method_ { MethMac(Mac), } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct Mod { /// A span from the first token past `{` to the last token until `}`. /// For `mod foo;`, the inner span ranges from the first token @@ -1355,31 +1358,31 @@ pub struct Mod { 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 abi: Abi, pub view_items: Vec<ViewItem>, 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 ty: P<Ty>, pub id: NodeId, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum VariantKind { TupleVariantKind(Vec<VariantArg>), StructVariantKind(P<StructDef>), } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct EnumDef { 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 name: Ident, pub attrs: Vec<Attribute>, @@ -1391,7 +1394,7 @@ pub struct 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_ { PathListIdent { name: Ident, id: NodeId }, PathListMod { id: NodeId } @@ -1409,7 +1412,7 @@ pub type PathListItem = Spanned<PathListItem_>; pub type ViewPath = Spanned<ViewPath_>; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum ViewPath_ { /// `foo::bar::baz as quux` @@ -1426,7 +1429,7 @@ pub enum ViewPath_ { 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 node: ViewItem_, pub attrs: Vec<Attribute>, @@ -1434,7 +1437,7 @@ pub struct ViewItem { pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum ViewItem_ { /// Ident: name used to refer to this crate in the code /// 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 /// are contained as statements within items. These two cases need to be /// 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 { AttrOuter, AttrInner, } -#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] pub struct AttrId(pub uint); /// 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 id: AttrId, 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. /// If this impl is an ItemImpl, the impl_id is redundant (it could be the /// 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 path: Path, pub ref_id: NodeId, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub struct PolyTraitRef { /// The `'a` in `<'a> Foo<&'a T>` pub bound_lifetimes: Vec<LifetimeDef>, @@ -1488,7 +1491,7 @@ pub struct PolyTraitRef { 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 { Public, 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 kind: StructFieldKind, pub id: NodeId, @@ -1522,7 +1525,7 @@ impl 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 { NamedField(Ident, Visibility), /// 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 { /// Fields, not including ctor pub fields: Vec<StructField>, @@ -1551,7 +1554,7 @@ pub struct StructDef { FIXME (#3300): Should allow items to be anonymous. Right now 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 ident: Ident, pub attrs: Vec<Attribute>, @@ -1561,7 +1564,7 @@ pub struct Item { pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum Item_ { ItemStatic(P<Ty>, Mutability, 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 ident: Ident, pub attrs: Vec<Attribute>, @@ -1615,7 +1618,7 @@ pub struct ForeignItem { pub vis: Visibility, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum ForeignItem_ { ForeignItemFn(P<FnDecl>, Generics), 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 { FnUnboxedClosureKind, FnMutUnboxedClosureKind, @@ -1640,7 +1643,7 @@ pub enum UnboxedClosureKind { /// 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. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)] pub enum InlinedItem { IIItem(P<Item>), IITraitItem(DefId /* impl id */, TraitItem), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 02771809ae6..48d39079c5b 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -343,7 +343,7 @@ pub fn empty_generics() -> Generics { // ______________________________________________________________________ // Enumerating the IDs which appear in an AST -#[deriving(Copy, Encodable, Decodable, Show)] +#[deriving(RustcEncodable, RustcDecodable, Show, Copy)] pub struct IdRange { pub min: NodeId, pub max: NodeId, diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 127cc5ed51d..cddf1a9923a 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -340,14 +340,14 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me } /// Represents the #[deprecated="foo"] and friends attributes. -#[deriving(Encodable,Decodable,Clone,Show)] +#[deriving(RustcEncodable,RustcDecodable,Clone,Show)] pub struct Stability { pub level: StabilityLevel, pub text: Option<InternedString> } /// The available stability levels. -#[deriving(Copy,Encodable,Decodable,PartialEq,PartialOrd,Clone,Show)] +#[deriving(RustcEncodable,RustcDecodable,PartialEq,PartialOrd,Clone,Show,Copy)] pub enum StabilityLevel { Deprecated, 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 { ReprAny, 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 { SignedInt(ast::IntTy), UnsignedInt(ast::UintTy) diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index c726e17a8fa..221c4fca586 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -92,7 +92,7 @@ pub struct Span { 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 node: T, pub span: Span, @@ -218,7 +218,7 @@ pub struct ExpnInfo { 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 const NO_EXPANSION: ExpnId = ExpnId(-1); diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 0a8d59da896..4878a690bb9 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -21,6 +21,16 @@ use parse::token::InternedString; use parse::token; 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, span: Span, mitem: &MetaItem, @@ -28,17 +38,28 @@ pub fn expand_deriving_decodable<F>(cx: &mut ExtCtxt, push: F) where 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 { span: span, attributes: Vec::new(), - path: Path::new_(vec!("serialize", "Decodable"), None, + path: Path::new_(vec!(krate, "Decodable"), None, vec!(box Literal(Path::new_local("__D")), box Literal(Path::new_local("__E"))), true), additional_bounds: Vec::new(), generics: LifetimeBounds { lifetimes: Vec::new(), bounds: vec!(("__D", None, vec!(Path::new_( - vec!("serialize", "Decoder"), None, + vec!(krate, "Decoder"), None, vec!(box Literal(Path::new_local("__E"))), true))), ("__E", None, vec!())) }, @@ -54,7 +75,7 @@ pub fn expand_deriving_decodable<F>(cx: &mut ExtCtxt, box Literal(Path::new_local("__E"))), true)), attributes: Vec::new(), 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, - substr: &Substructure) -> P<Expr> { + substr: &Substructure, + krate: &str) -> P<Expr> { 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("decode")); // throw an underscore in front to suppress unused variable warnings diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 30851ebeaae..1b8d01f1cd0 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -97,6 +97,16 @@ use ext::deriving::generic::ty::*; use parse::token; 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, span: Span, mitem: &MetaItem, @@ -104,17 +114,28 @@ pub fn expand_deriving_encodable<F>(cx: &mut ExtCtxt, push: F) where 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 { span: span, attributes: Vec::new(), - path: Path::new_(vec!("serialize", "Encodable"), None, + path: Path::new_(vec!(krate, "Encodable"), None, vec!(box Literal(Path::new_local("__S")), box Literal(Path::new_local("__E"))), true), additional_bounds: Vec::new(), generics: LifetimeBounds { lifetimes: Vec::new(), bounds: vec!(("__S", None, vec!(Path::new_( - vec!("serialize", "Encoder"), None, + vec!(krate, "Encoder"), None, vec!(box Literal(Path::new_local("__E"))), true))), ("__E", None, vec!())) }, diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index 839e99c81d1..b5957fd1b8a 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -71,24 +71,22 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt, "Hash" => expand!(hash::expand_deriving_hash), "RustcEncodable" => { - expand!(encodable::expand_deriving_encodable) + expand!(encodable::expand_deriving_rustc_encodable) } "RustcDecodable" => { - expand!(decodable::expand_deriving_decodable) + expand!(decodable::expand_deriving_rustc_decodable) } "Encodable" => { - // NOTE: uncomment after a stage0 snap - // cx.span_warn(titem.span, - // "deriving(Encodable) is deprecated \ - // in favor of deriving(RustcEncodable)"); + cx.span_warn(titem.span, + "deriving(Encodable) is deprecated \ + in favor of deriving(RustcEncodable)"); expand!(encodable::expand_deriving_encodable) } "Decodable" => { - // NOTE: uncomment after a stage0 snap - // cx.span_warn(titem.span, - // "deriving(Decodable) is deprecated \ - // in favor of deriving(RustcDecodable)"); + cx.span_warn(titem.span, + "deriving(Decodable) is deprecated \ + in favor of deriving(RustcDecodable)"); expand!(decodable::expand_deriving_decodable) } diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index f0392912878..6a296333fdb 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -39,7 +39,7 @@ pub struct SCTable { 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_ { EmptyCtxt, Mark (Mrk,SyntaxContext), diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 5f62c74ef07..d5093c5055c 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -34,6 +34,8 @@ extern crate serialize; extern crate term; extern crate libc; +extern crate "serialize" as rustc_serialize; // used by deriving + pub mod util { pub mod interner; #[cfg(test)] diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index dad369792d7..87d65e258de 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -28,7 +28,7 @@ use std::path::BytesContainer; use std::rc::Rc; #[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 { Plus, Minus, @@ -43,7 +43,7 @@ pub enum BinOpToken { } /// A delimeter token -#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Show, Copy)] pub enum DelimToken { /// A round parenthesis: `(` or `)` Paren, @@ -53,14 +53,14 @@ pub enum DelimToken { Brace, } -#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Show, Copy)] pub enum IdentStyle { /// `::` follows the identifier with no whitespace in-between. ModName, Plain, } -#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Show, Copy)] pub enum Lit { Byte(ast::Name), Char(ast::Name), @@ -86,7 +86,7 @@ impl Lit { } #[allow(non_camel_case_types)] -#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Show)] pub enum Token { /* Expression-operator symbols. */ 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. pub enum Nonterminal { NtItem(P<ast::Item>), |
