Skip to content

Commit b04bc5c

Browse files
committed
rollup merge of rust-lang#20033: alexcrichton/deprecate-serialise
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]
2 parents 9b99436 + a76a802 commit b04bc5c

File tree

25 files changed

+288
-226
lines changed

25 files changed

+288
-226
lines changed

src/librustc/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ extern crate collections;
4040
#[phase(plugin, link)] extern crate log;
4141
#[phase(plugin, link)] extern crate syntax;
4242

43+
extern crate "serialize" as rustc_serialize; // used by deriving
44+
4345
#[cfg(test)]
4446
extern crate test;
4547

src/librustc/middle/def.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use syntax::ast_util::local_def;
2020

2121
use std::cell::RefCell;
2222

23-
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
23+
#[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
2424
pub enum Def {
2525
DefFn(ast::DefId, bool /* is_ctor */),
2626
DefStaticMethod(/* method */ ast::DefId, MethodProvenance),
@@ -73,13 +73,13 @@ pub struct Export {
7373
pub def_id: ast::DefId, // The definition of the target.
7474
}
7575

76-
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
76+
#[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
7777
pub enum MethodProvenance {
7878
FromTrait(ast::DefId),
7979
FromImpl(ast::DefId),
8080
}
8181

82-
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
82+
#[deriving(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
8383
pub enum TyParamProvenance {
8484
FromSelf(ast::DefId),
8585
FromParam(ast::DefId),

src/librustc/middle/region.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ use syntax::visit::{Visitor, FnKind};
3636
/// placate the same deriving in `ty::FreeRegion`, but we may want to
3737
/// actually attach a more meaningful ordering to scopes than the one
3838
/// generated via deriving here.
39-
#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)]
39+
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable,
40+
RustcDecodable, Show, Copy)]
4041
pub enum CodeExtent {
4142
Misc(ast::NodeId)
4243
}

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use syntax::visit;
3333
use syntax::visit::Visitor;
3434
use util::nodemap::NodeMap;
3535

36-
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
36+
#[deriving(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show)]
3737
pub enum DefRegion {
3838
DefStaticRegion,
3939
DefEarlyBoundRegion(/* space */ subst::ParamSpace,

src/librustc/middle/subst.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ impl RegionSubsts {
187187
///////////////////////////////////////////////////////////////////////////
188188
// ParamSpace
189189

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

src/librustc/middle/ty.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ pub struct mt<'tcx> {
246246
pub mutbl: ast::Mutability,
247247
}
248248

249-
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
249+
#[deriving(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show)]
250250
pub enum TraitStore {
251251
/// Box<Trait>
252252
UniqTraitStore,
@@ -277,13 +277,13 @@ pub enum ast_ty_to_ty_cache_entry<'tcx> {
277277
atttce_resolved(Ty<'tcx>) /* resolved to a type, irrespective of region */
278278
}
279279

280-
#[deriving(Clone, PartialEq, Decodable, Encodable)]
280+
#[deriving(Clone, PartialEq, RustcDecodable, RustcEncodable)]
281281
pub struct ItemVariances {
282282
pub types: VecPerParamSpace<Variance>,
283283
pub regions: VecPerParamSpace<Variance>,
284284
}
285285

286-
#[deriving(Clone, Copy, PartialEq, Decodable, Encodable, Show)]
286+
#[deriving(Clone, PartialEq, RustcDecodable, RustcEncodable, Show, Copy)]
287287
pub enum Variance {
288288
Covariant, // T<A> <: T<B> iff A <: B -- e.g., function return type
289289
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
430430
}
431431
}
432432

433-
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, PartialOrd, Show)]
433+
#[deriving(Clone, Copy, RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Show)]
434434
pub struct param_index {
435435
pub space: subst::ParamSpace,
436436
pub index: uint
@@ -510,7 +510,7 @@ pub struct MethodCall {
510510
pub adjustment: ExprAdjustment
511511
}
512512

513-
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show, Encodable, Decodable)]
513+
#[deriving(Clone, PartialEq, Eq, Hash, Show, RustcEncodable, RustcDecodable, Copy)]
514514
pub enum ExprAdjustment {
515515
NoAdjustment,
516516
AutoDeref(uint),
@@ -973,15 +973,15 @@ pub struct ParamTy {
973973
/// is the outer fn.
974974
///
975975
/// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index
976-
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
976+
#[deriving(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show, Copy)]
977977
pub struct DebruijnIndex {
978978
// We maintain the invariant that this is never 0. So 1 indicates
979979
// the innermost binder. To ensure this, create with `DebruijnIndex::new`.
980980
pub depth: uint,
981981
}
982982

983983
/// Representation of regions:
984-
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
984+
#[deriving(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Show, Copy)]
985985
pub enum Region {
986986
// Region bound in a type or fn declaration which will be
987987
// substituted 'early' -- that is, at the same time when type
@@ -1028,7 +1028,7 @@ pub struct UpvarId {
10281028
pub closure_expr_id: ast::NodeId,
10291029
}
10301030

1031-
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show, Encodable, Decodable)]
1031+
#[deriving(Clone, PartialEq, Eq, Hash, Show, RustcEncodable, RustcDecodable, Copy)]
10321032
pub enum BorrowKind {
10331033
/// Data must be immutable and is aliasable.
10341034
ImmBorrow,
@@ -1121,7 +1121,7 @@ pub enum BorrowKind {
11211121
/// - Through mutation, the borrowed upvars can actually escape
11221122
/// the closure, so sometimes it is necessary for them to be larger
11231123
/// than the closure lifetime itself.
1124-
#[deriving(Copy, PartialEq, Clone, Encodable, Decodable, Show)]
1124+
#[deriving(PartialEq, Clone, RustcEncodable, RustcDecodable, Show, Copy)]
11251125
pub struct UpvarBorrow {
11261126
pub kind: BorrowKind,
11271127
pub region: ty::Region,
@@ -1146,15 +1146,17 @@ impl Region {
11461146
}
11471147
}
11481148

1149-
#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)]
1149+
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
1150+
RustcEncodable, RustcDecodable, Show, Copy)]
11501151
/// A "free" region `fr` can be interpreted as "some region
11511152
/// at least as big as the scope `fr.scope`".
11521153
pub struct FreeRegion {
11531154
pub scope: region::CodeExtent,
11541155
pub bound_region: BoundRegion
11551156
}
11561157

1157-
#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)]
1158+
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash,
1159+
RustcEncodable, RustcDecodable, Show, Copy)]
11581160
pub enum BoundRegion {
11591161
/// An anonymous region parameter for a given fn (&T)
11601162
BrAnon(uint),
@@ -1412,7 +1414,8 @@ pub struct ExistentialBounds {
14121414

14131415
pub type BuiltinBounds = EnumSet<BuiltinBound>;
14141416

1415-
#[deriving(Copy, Clone, Encodable, PartialEq, Eq, Decodable, Hash, Show)]
1417+
#[deriving(Clone, RustcEncodable, PartialEq, Eq, RustcDecodable, Hash,
1418+
Show, Copy)]
14161419
#[repr(uint)]
14171420
pub enum BuiltinBound {
14181421
BoundSend,
@@ -1463,7 +1466,7 @@ pub struct FloatVid {
14631466
pub index: uint
14641467
}
14651468

1466-
#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)]
1469+
#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
14671470
pub struct RegionVid {
14681471
pub index: uint
14691472
}
@@ -1485,7 +1488,7 @@ pub enum InferTy {
14851488
FreshIntTy(uint),
14861489
}
14871490

1488-
#[deriving(Clone, Copy, Encodable, Decodable, Eq, Hash, Show)]
1491+
#[deriving(Clone, RustcEncodable, RustcDecodable, Eq, Hash, Show, Copy)]
14891492
pub enum InferRegion {
14901493
ReVar(RegionVid),
14911494
ReSkolemized(uint, BoundRegion)
@@ -1571,7 +1574,7 @@ pub struct TypeParameterDef<'tcx> {
15711574
pub default: Option<Ty<'tcx>>,
15721575
}
15731576

1574-
#[deriving(Encodable, Decodable, Clone, Show)]
1577+
#[deriving(RustcEncodable, RustcDecodable, Clone, Show)]
15751578
pub struct RegionParameterDef {
15761579
pub name: ast::Name,
15771580
pub def_id: ast::DefId,
@@ -6223,7 +6226,7 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
62236226
}
62246227

62256228
/// A free variable referred to in a function.
6226-
#[deriving(Copy, Encodable, Decodable)]
6229+
#[deriving(Copy, RustcEncodable, RustcDecodable)]
62276230
pub struct Freevar {
62286231
/// The variable being accessed free.
62296232
pub def: def::Def,

0 commit comments

Comments
 (0)