Skip to content

Commit

Permalink
serialize: Fully deprecate the library
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
alexcrichton committed Dec 22, 2014
1 parent 34d6800 commit a76a802
Show file tree
Hide file tree
Showing 25 changed files with 288 additions and 226 deletions.
2 changes: 2 additions & 0 deletions src/librustc/lib.rs
Expand Up @@ -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;


Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/def.rs
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/region.rs
Expand Up @@ -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)
} }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/resolve_lifetime.rs
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/subst.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
35 changes: 19 additions & 16 deletions src/librustc/middle/ty.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -973,15 +973,15 @@ 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`.
pub depth: uint, pub depth: uint,
} }


/// 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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -1146,15 +1146,17 @@ 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 {
pub scope: region::CodeExtent, pub scope: region::CodeExtent,
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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
} }
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

5 comments on commit a76a802

@bors
Copy link
Contributor

@bors bors commented on a76a802 Dec 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from aturon
at alexcrichton@a76a802

@bors
Copy link
Contributor

@bors bors commented on a76a802 Dec 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/rust/deprecate-serialise = a76a802 into auto

@bors
Copy link
Contributor

@bors bors commented on a76a802 Dec 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status: {"merge_sha": "f3978a72e8ccbff7205875fc35605624585849a3"}

@bors
Copy link
Contributor

@bors bors commented on a76a802 Dec 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/rust/deprecate-serialise = a76a802 merged ok, testing candidate = f3978a72

Please sign in to comment.