Permalink
Browse files

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]
  • Loading branch information...
1 parent 34d6800 commit a76a80276852f05f30adaa4d2a8a2729b5fc0bfa @alexcrichton alexcrichton committed Dec 19, 2014
View
@@ -40,6 +40,8 @@ extern crate collections;
#[phase(plugin, link)] extern crate log;
#[phase(plugin, link)] extern crate syntax;
+extern crate "serialize" as rustc_serialize; // used by deriving
+
#[cfg(test)]
extern crate test;
@@ -20,7 +20,7 @@ use syntax::ast_util::local_def;
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 {
DefFn(ast::DefId, bool /* is_ctor */),
DefStaticMethod(/* method */ ast::DefId, MethodProvenance),
@@ -73,13 +73,13 @@ pub struct Export {
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 {
FromTrait(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 {
FromSelf(ast::DefId),
FromParam(ast::DefId),
@@ -36,7 +36,8 @@ use syntax::visit::{Visitor, FnKind};
/// placate the same deriving in `ty::FreeRegion`, but we may want to
/// actually attach a more meaningful ordering to scopes than the one
/// 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 {
Misc(ast::NodeId)
}
@@ -33,7 +33,7 @@ use syntax::visit;
use syntax::visit::Visitor;
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 {
DefStaticRegion,
DefEarlyBoundRegion(/* space */ subst::ParamSpace,
@@ -187,8 +187,8 @@ impl RegionSubsts {
///////////////////////////////////////////////////////////////////////////
// ParamSpace
-#[deriving(Copy, PartialOrd, Ord, PartialEq, Eq,
- Clone, Hash, Encodable, Decodable, Show)]
+#[deriving(PartialOrd, Ord, PartialEq, Eq, Copy,
+ Clone, Hash, RustcEncodable, RustcDecodable, Show)]
pub enum ParamSpace {
TypeSpace, // Type parameters attached to a type definition, trait, or impl
SelfSpace, // Self parameter on a trait
@@ -224,7 +224,7 @@ impl ParamSpace {
/// Vector of things sorted by param space. Used to keep
/// the set of things declared on the type, self, or method
/// distinct.
-#[deriving(PartialEq, Eq, Clone, Hash, Encodable, Decodable)]
+#[deriving(PartialEq, Eq, Clone, Hash, RustcEncodable, RustcDecodable)]
pub struct VecPerParamSpace<T> {
// This was originally represented as a tuple with one Vec<T> for
// each variant of ParamSpace, and that remains the abstraction
@@ -246,7 +246,7 @@ pub struct mt<'tcx> {
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 {
/// Box<Trait>
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 */
}
-#[deriving(Clone, PartialEq, Decodable, Encodable)]
+#[deriving(Clone, PartialEq, RustcDecodable, RustcEncodable)]
pub struct ItemVariances {
pub types: VecPerParamSpace<Variance>,
pub regions: VecPerParamSpace<Variance>,
}
-#[deriving(Clone, Copy, PartialEq, Decodable, Encodable, Show)]
+#[deriving(Clone, PartialEq, RustcDecodable, RustcEncodable, Show, Copy)]
pub enum Variance {
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
@@ -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 space: subst::ParamSpace,
pub index: uint
@@ -510,7 +510,7 @@ pub struct MethodCall {
pub adjustment: ExprAdjustment
}
-#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show, Encodable, Decodable)]
+#[deriving(Clone, PartialEq, Eq, Hash, Show, RustcEncodable, RustcDecodable, Copy)]
pub enum ExprAdjustment {
NoAdjustment,
AutoDeref(uint),
@@ -973,15 +973,15 @@ pub struct ParamTy {
/// is the outer fn.
///
/// [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 {
// We maintain the invariant that this is never 0. So 1 indicates
// the innermost binder. To ensure this, create with `DebruijnIndex::new`.
pub depth: uint,
}
/// Representation of regions:
-#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
+#[deriving(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show, Copy)]
pub enum Region {
// Region bound in a type or fn declaration which will be
// substituted 'early' -- that is, at the same time when type
@@ -1028,7 +1028,7 @@ pub struct UpvarId {
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 {
/// Data must be immutable and is aliasable.
ImmBorrow,
@@ -1121,7 +1121,7 @@ pub enum BorrowKind {
/// - Through mutation, the borrowed upvars can actually escape
/// the closure, so sometimes it is necessary for them to be larger
/// than the closure lifetime itself.
-#[deriving(Copy, PartialEq, Clone, Encodable, Decodable, Show)]
+#[deriving(PartialEq, Clone, RustcEncodable, RustcDecodable, Show, Copy)]
pub struct UpvarBorrow {
pub kind: BorrowKind,
pub region: ty::Region,
@@ -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
/// at least as big as the scope `fr.scope`".
pub struct FreeRegion {
pub scope: region::CodeExtent,
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 {
/// An anonymous region parameter for a given fn (&T)
BrAnon(uint),
@@ -1412,7 +1414,8 @@ pub struct ExistentialBounds {
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)]
pub enum BuiltinBound {
BoundSend,
@@ -1463,7 +1466,7 @@ pub struct FloatVid {
pub index: uint
}
-#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub struct RegionVid {
pub index: uint
}
@@ -1485,7 +1488,7 @@ pub enum InferTy {
FreshIntTy(uint),
}
-#[deriving(Clone, Copy, Encodable, Decodable, Eq, Hash, Show)]
+#[deriving(Clone, RustcEncodable, RustcDecodable, Eq, Hash, Show, Copy)]
pub enum InferRegion {
ReVar(RegionVid),
ReSkolemized(uint, BoundRegion)
@@ -1571,7 +1574,7 @@ pub struct TypeParameterDef<'tcx> {
pub default: Option<Ty<'tcx>>,
}
-#[deriving(Encodable, Decodable, Clone, Show)]
+#[deriving(RustcEncodable, RustcDecodable, Clone, Show)]
pub struct RegionParameterDef {
pub name: ast::Name,
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.
-#[deriving(Copy, Encodable, Decodable)]
+#[deriving(Copy, RustcEncodable, RustcDecodable)]
pub struct Freevar {
/// The variable being accessed free.
pub def: def::Def,
Oops, something went wrong.

5 comments on commit a76a802

@bors
Contributor
bors commented on a76a802 Dec 22, 2014

saw approval from aturon
at alexcrichton@a76a802

@bors
Contributor
bors commented on a76a802 Dec 22, 2014

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

@bors
Contributor
bors commented on a76a802 Dec 22, 2014

status: {"merge_sha": "f3978a72e8ccbff7205875fc35605624585849a3"}

@bors
Contributor
bors commented on a76a802 Dec 22, 2014

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

Please sign in to comment.