rollup merge of #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]
This commit is contained in:
Alex Crichton 2014-12-22 12:46:31 -08:00
commit b04bc5cc49
25 changed files with 288 additions and 226 deletions

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 name: String,
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 name: String,
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
/// 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.
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Item {
/// Stringified span
pub source: Span,
@ -304,7 +304,7 @@ impl Item {
}
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum ItemEnum {
StructItem(Struct),
EnumItem(Enum),
@ -333,7 +333,7 @@ pub enum ItemEnum {
AssociatedTypeItem(TyParam),
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Module {
pub items: Vec<Item>,
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 {
Word(String),
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 }
}
#[deriving(Clone, Encodable, Decodable, PartialEq)]
#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct TyParam {
pub name: String,
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 {
RegionBound(Lifetime),
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);
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 ty: Type,
pub bounds: Vec<TyParamBound>
@ -706,7 +706,7 @@ impl Clean<WherePredicate> for ast::WherePredicate {
}
// maybe use a Generic enum and use ~[Generic]?
#[deriving(Clone, Encodable, Decodable, PartialEq)]
#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct Generics {
pub lifetimes: Vec<Lifetime>,
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 generics: Generics,
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 unsafety: ast::Unsafety,
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 {
SelfStatic,
SelfValue,
@ -832,7 +832,7 @@ impl Clean<SelfTy> for ast::ExplicitSelf_ {
}
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Function {
pub decl: FnDecl,
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 lifetimes: Vec<Lifetime>,
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 inputs: Arguments,
pub output: FunctionRetTy,
pub attrs: Vec<Attribute>,
}
#[deriving(Clone, Encodable, Decodable, PartialEq)]
#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct Arguments {
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 type_: Type,
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 {
Return(Type),
NoReturn
@ -970,7 +970,7 @@ impl Clean<FunctionRetTy> for ast::FunctionRetTy {
}
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Trait {
pub unsafety: ast::Unsafety,
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
/// TraitItem except that's already taken by an exported enum variant.
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum TraitMethod {
RequiredMethod(Item),
ProvidedMethod(Item),
@ -1059,7 +1059,7 @@ impl Clean<TraitMethod> for ast::TraitItem {
}
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum ImplMethod {
MethodImplItem(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
/// 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.
#[deriving(Clone, Encodable, Decodable, PartialEq)]
#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub enum Type {
/// structs/enums/traits (anything that'd be an ast::TyPath)
ResolvedPath {
@ -1180,7 +1180,7 @@ pub enum Type {
PolyTraitRef(Vec<TyParamBound>),
}
#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, Eq, Hash)]
#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Copy)]
pub enum PrimitiveType {
Int, I8, I16, I32, I64,
Uint, U8, U16, U32, U64,
@ -1192,7 +1192,7 @@ pub enum PrimitiveType {
PrimitiveTuple,
}
#[deriving(Clone, Copy, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable, Copy)]
pub enum TypeKind {
TypeEnum,
TypeFunction,
@ -1436,7 +1436,7 @@ impl Clean<Type> for ast::QPath {
}
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum StructField {
HiddenStructField, // inserted later by strip passes
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_type: doctree::StructType,
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
/// it lacks the things most items have (name, id, parameterization). Found
/// only as a variant in an enum.
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct VariantStruct {
pub struct_type: doctree::StructType,
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 variants: Vec<Item>,
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 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 {
CLikeVariant,
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 filename: String,
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 global: bool,
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 name: String,
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 type_: Type,
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 unsafety: ast::Unsafety,
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 type_: Type,
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 type_: Type,
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 {
Mutable,
Immutable,
@ -1876,7 +1876,7 @@ impl Clean<Mutability> for ast::Mutability {
}
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Impl {
pub generics: Generics,
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 inner: ViewItemInner,
}
@ -1980,7 +1980,7 @@ impl Clean<Vec<Item>> for ast::ViewItem {
}
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum ViewItemInner {
ExternCrate(String, Option<String>, ast::NodeId),
Import(ViewPath)
@ -2003,7 +2003,7 @@ impl Clean<ViewItemInner> for ast::ViewItem_ {
}
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub enum ViewPath {
// use source as str;
SimpleImport(String, ImportSource),
@ -2013,7 +2013,7 @@ pub enum ViewPath {
ImportList(ImportSource, Vec<ViewListIdent>),
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct ImportSource {
pub path: Path,
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 name: String,
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 source: String,
}
@ -2268,7 +2268,7 @@ impl Clean<Item> for doctree::Macro {
}
}
#[deriving(Clone, Encodable, Decodable)]
#[deriving(Clone, RustcEncodable, RustcDecodable)]
pub struct Stability {
pub level: attr::StabilityLevel,
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 {
/// A normal struct
Plain,

View file

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

View file

@ -25,7 +25,7 @@ use clean::{TypeTraitItem, ViewItemItem, PrimitiveItem, Stability};
use html::render::cache;
#[deriving(Zero, Encodable, Decodable, PartialEq, Eq)]
#[deriving(Zero, RustcEncodable, RustcDecodable, PartialEq, Eq)]
/// The counts for each stability level.
#[deriving(Copy)]
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
/// modules.
pub struct ModuleSummary {