Skip to content

Commit

Permalink
cleanup: Remove extern crate serialize as rustc_serializes
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jul 23, 2019
1 parent 3ebca72 commit 6140371
Show file tree
Hide file tree
Showing 52 changed files with 99 additions and 147 deletions.
2 changes: 1 addition & 1 deletion src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rustc_target = { path = "../librustc_target" }
rustc_macros = { path = "../librustc_macros" }
rustc_data_structures = { path = "../librustc_data_structures" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
serialize = { path = "../libserialize" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
backtrace = "0.3.3"
Expand Down
17 changes: 8 additions & 9 deletions src/librustc/hir/def_id.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::ty::{self, TyCtxt};
use crate::hir::map::definitions::FIRST_FREE_DEF_INDEX;
use rustc_data_structures::indexed_vec::Idx;
use serialize;
use std::fmt;
use std::u32;

Expand Down Expand Up @@ -93,8 +92,8 @@ impl fmt::Display for CrateNum {
}
}

impl serialize::UseSpecializedEncodable for CrateNum {}
impl serialize::UseSpecializedDecodable for CrateNum {}
impl rustc_serialize::UseSpecializedEncodable for CrateNum {}
impl rustc_serialize::UseSpecializedDecodable for CrateNum {}

newtype_index! {
/// A DefIndex is an index into the hir-map for a crate, identifying a
Expand Down Expand Up @@ -134,8 +133,8 @@ impl DefIndex {
}
}

impl serialize::UseSpecializedEncodable for DefIndex {}
impl serialize::UseSpecializedDecodable for DefIndex {}
impl rustc_serialize::UseSpecializedEncodable for DefIndex {}
impl rustc_serialize::UseSpecializedDecodable for DefIndex {}

/// A `DefId` identifies a particular *definition*, by combining a crate
/// index and a def index.
Expand Down Expand Up @@ -186,8 +185,8 @@ impl DefId {
}
}

impl serialize::UseSpecializedEncodable for DefId {}
impl serialize::UseSpecializedDecodable for DefId {}
impl rustc_serialize::UseSpecializedEncodable for DefId {}
impl rustc_serialize::UseSpecializedDecodable for DefId {}

/// A LocalDefId is equivalent to a DefId with `krate == LOCAL_CRATE`. Since
/// we encode this information in the type, we can ensure at compile time that
Expand Down Expand Up @@ -220,5 +219,5 @@ impl fmt::Debug for LocalDefId {
}
}

impl serialize::UseSpecializedEncodable for LocalDefId {}
impl serialize::UseSpecializedDecodable for LocalDefId {}
impl rustc_serialize::UseSpecializedEncodable for LocalDefId {}
impl rustc_serialize::UseSpecializedDecodable for LocalDefId {}
6 changes: 3 additions & 3 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_macros::HashStable;

use serialize::{self, Encoder, Encodable, Decoder, Decodable};
use rustc_serialize::{self, Encoder, Encodable, Decoder, Decodable};
use std::collections::{BTreeSet, BTreeMap};
use std::fmt;
use smallvec::SmallVec;
Expand Down Expand Up @@ -92,7 +92,7 @@ impl HirId {
}
}

impl serialize::UseSpecializedEncodable for HirId {
impl rustc_serialize::UseSpecializedEncodable for HirId {
fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
let HirId {
owner,
Expand All @@ -104,7 +104,7 @@ impl serialize::UseSpecializedEncodable for HirId {
}
}

impl serialize::UseSpecializedDecodable for HirId {
impl rustc_serialize::UseSpecializedDecodable for HirId {
fn default_decode<D: Decoder>(d: &mut D) -> Result<HirId, D::Error> {
let owner = DefIndex::decode(d)?;
let local_id = ItemLocalId::decode(d)?;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::iter::FromIterator;
use std::ops::Deref;
use std::{slice, vec};

use serialize::{Encodable, Decodable, Encoder, Decoder};
use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};

use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult,
HashStable};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::infer::region_constraints::MemberConstraint;
use crate::mir::interpret::ConstValue;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_macros::HashStable;
use serialize::UseSpecializedDecodable;
use rustc_serialize::UseSpecializedDecodable;
use smallvec::SmallVec;
use std::ops::Index;
use syntax::source_map::Span;
Expand Down
8 changes: 0 additions & 8 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,8 @@ extern crate getopts;
extern crate libc;
#[macro_use] extern crate rustc_macros;
#[macro_use] extern crate rustc_data_structures;

#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

// FIXME: This import is used by deriving `RustcDecodable` and `RustcEncodable`. Removing this
// results in a bunch of "failed to resolve" errors. Hopefully, the compiler moves to serde or
// something, and we can get rid of this.
#[allow(rust_2018_idioms)]
extern crate serialize as rustc_serialize;

#[macro_use] extern crate smallvec;

// Use the test crate here so we depend on getopts through it. This allow tools to link to both
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::lint::{LintArray, Level, Lint, LintId, LintPass, LintBuffer};
use crate::lint::builtin::BuiltinLintDiagnostics;
use crate::lint::levels::{LintLevelSets, LintLevelsBuilder};
use crate::middle::privacy::AccessLevels;
use crate::rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
use rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
use crate::session::{config, early_error, Session};
use crate::ty::{self, print::Printer, subst::Kind, TyCtxt, Ty};
use crate::ty::layout::{LayoutError, LayoutOf, TyLayout};
Expand Down
18 changes: 8 additions & 10 deletions src/librustc/mir/cache.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::sync::{RwLock, MappedReadGuard, ReadGuard};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
StableHasherResult};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult};
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
use crate::ich::StableHashingContext;
use crate::mir::{Body, BasicBlock};

use crate::rustc_serialize as serialize;

#[derive(Clone, Debug)]
pub struct Cache {
predecessors: RwLock<Option<IndexVec<BasicBlock, Vec<BasicBlock>>>>
}


impl serialize::Encodable for Cache {
fn encode<S: serialize::Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
serialize::Encodable::encode(&(), s)
impl rustc_serialize::Encodable for Cache {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
Encodable::encode(&(), s)
}
}

impl serialize::Decodable for Cache {
fn decode<D: serialize::Decoder>(d: &mut D) -> Result<Self, D::Error> {
serialize::Decodable::decode(d).map(|_v: ()| Self::new())
impl rustc_serialize::Decodable for Cache {
fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error> {
Decodable::decode(d).map(|_v: ()| Self::new())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<Tag> Allocation<Tag> {
}
}

impl<'tcx> ::serialize::UseSpecializedDecodable for &'tcx Allocation {}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx Allocation {}

/// Byte accessors
impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::hir::def_id::DefId;
use crate::ty::{self, TyCtxt, Instance, subst::UnpackedKind};
use crate::ty::layout::{self, Size};
use std::io;
use crate::rustc_serialize::{Encoder, Decodable, Encodable};
use rustc_serialize::{Encoder, Decodable, Encodable};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::{Lock as Mutex, HashMapExt};
use rustc_data_structures::tiny_list::TinyList;
Expand All @@ -51,8 +51,8 @@ pub struct GlobalId<'tcx> {
#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd, Debug)]
pub struct AllocId(pub u64);

impl crate::rustc_serialize::UseSpecializedEncodable for AllocId {}
impl crate::rustc_serialize::UseSpecializedDecodable for AllocId {}
impl rustc_serialize::UseSpecializedEncodable for AllocId {}
impl rustc_serialize::UseSpecializedDecodable for AllocId {}

#[derive(RustcDecodable, RustcEncodable)]
enum AllocDiscriminant {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::hir::def_id::DefId;
use crate::hir::{self, InlineAsm as HirInlineAsm};
use crate::mir::interpret::{ConstValue, InterpError, Scalar};
use crate::mir::visit::MirVisitable;
use crate::rustc_serialize as serialize;
use crate::ty::adjustment::PointerCast;
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use crate::ty::layout::VariantIdx;
Expand All @@ -28,6 +27,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::sync::MappedReadGuard;
use rustc_macros::HashStable;
use rustc_serialize::{Encodable, Decodable};
use smallvec::SmallVec;
use std::borrow::Cow;
use std::fmt::{self, Debug, Display, Formatter, Write};
Expand Down Expand Up @@ -463,8 +463,8 @@ impl<T> ClearCrossCrate<T> {
}
}

impl<T: serialize::Encodable> serialize::UseSpecializedEncodable for ClearCrossCrate<T> {}
impl<T: serialize::Decodable> serialize::UseSpecializedDecodable for ClearCrossCrate<T> {}
impl<T: Encodable> rustc_serialize::UseSpecializedEncodable for ClearCrossCrate<T> {}
impl<T: Decodable> rustc_serialize::UseSpecializedDecodable for ClearCrossCrate<T> {}

/// Grouped information about the source code origin of a MIR entity.
/// Intended to be inspected by diagnostics and debuginfo.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::arena::ArenaAllocatable;
use crate::hir::def_id::{DefId, CrateNum};
use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos};
use rustc_data_structures::fx::FxHashMap;
use crate::rustc_serialize::{Decodable, Decoder, Encoder, Encodable, opaque};
use rustc_serialize::{Decodable, Decoder, Encoder, Encodable, opaque};
use std::hash::Hash;
use std::intrinsics;
use crate::ty::{self, Ty, TyCtxt};
Expand Down Expand Up @@ -333,7 +333,7 @@ macro_rules! implement_ty_decoder {
use $crate::ty::codec::*;
use $crate::ty::subst::SubstsRef;
use $crate::hir::def_id::{CrateNum};
use crate::rustc_serialize::{Decoder, SpecializedDecoder};
use rustc_serialize::{Decoder, SpecializedDecoder};
use std::borrow::Cow;

impl<$($typaram ),*> Decoder for $DecoderName<$($typaram),*> {
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::util::nodemap::{NodeSet, DefIdMap, FxHashMap};
use arena::SyncDroplessArena;
use crate::session::DataTypeKind;

use serialize::{self, Encodable, Encoder};
use rustc_serialize::{self, Encodable, Encoder};
use std::cell::RefCell;
use std::cmp::{self, Ordering};
use std::fmt;
Expand Down Expand Up @@ -588,8 +588,8 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::TyS<'tcx> {

pub type Ty<'tcx> = &'tcx TyS<'tcx>;

impl<'tcx> serialize::UseSpecializedEncodable for Ty<'tcx> {}
impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {}
impl<'tcx> rustc_serialize::UseSpecializedEncodable for Ty<'tcx> {}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for Ty<'tcx> {}

pub type CanonicalTy<'tcx> = Canonical<'tcx, Ty<'tcx>>;

Expand Down Expand Up @@ -708,7 +708,7 @@ impl<'a, T> IntoIterator for &'a List<T> {
}
}

impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List<Ty<'tcx>> {}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx List<Ty<'tcx>> {}

impl<T> List<T> {
#[inline(always)]
Expand Down Expand Up @@ -1009,8 +1009,8 @@ pub struct GenericPredicates<'tcx> {
pub predicates: Vec<(Predicate<'tcx>, Span)>,
}

impl<'tcx> serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {}
impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}
impl<'tcx> rustc_serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}

impl<'tcx> GenericPredicates<'tcx> {
pub fn instantiate(
Expand Down Expand Up @@ -1985,13 +1985,13 @@ impl Hash for AdtDef {
}
}

impl<'tcx> serialize::UseSpecializedEncodable for &'tcx AdtDef {
impl<'tcx> rustc_serialize::UseSpecializedEncodable for &'tcx AdtDef {
fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
self.did.encode(s)
}
}

impl<'tcx> serialize::UseSpecializedDecodable for &'tcx AdtDef {}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx AdtDef {}


impl<'a> HashStable<StableHashingContext<'a>> for AdtDef {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::hir::map::definitions::DefPathHash;
use crate::ich::{CachingSourceMapView, Fingerprint};
use crate::mir::{self, interpret};
use crate::mir::interpret::{AllocDecodingSession, AllocDecodingState};
use crate::rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque,
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque,
SpecializedDecoder, SpecializedEncoder,
UseSpecializedDecodable, UseSpecializedEncodable};
use crate::session::{CrateDisambiguator, Session};
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use rustc_target::spec::abi;
use syntax::ast::{self, Ident};
use syntax::symbol::{kw, InternedString};

use serialize;
use self::InferTy::*;
use self::TyKind::*;

Expand Down Expand Up @@ -640,7 +639,7 @@ impl<'tcx> Binder<ExistentialPredicate<'tcx>> {
}
}

impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List<ExistentialPredicate<'tcx>> {}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx List<ExistentialPredicate<'tcx>> {}

impl<'tcx> List<ExistentialPredicate<'tcx>> {
/// Returns the "principal def id" of this set of existential predicates.
Expand Down Expand Up @@ -1324,7 +1323,7 @@ pub enum RegionKind {
ReClosureBound(RegionVid),
}

impl<'tcx> serialize::UseSpecializedDecodable for Region<'tcx> {}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for Region<'tcx> {}

#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug, PartialOrd, Ord)]
pub struct EarlyBoundRegion {
Expand Down Expand Up @@ -2333,7 +2332,7 @@ impl<'tcx> Const<'tcx> {
}
}

impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Const<'tcx> {}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx Const<'tcx> {}

/// An inference variable for a const, for use in const generics.
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::ty::{self, Lift, List, Ty, TyCtxt, InferConst, ParamConst};
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use crate::mir::interpret::ConstValue;

use serialize::{self, Encodable, Encoder, Decodable, Decoder};
use rustc_serialize::{self, Encodable, Encoder, Decodable, Decoder};
use syntax_pos::{Span, DUMMY_SP};
use smallvec::SmallVec;
use rustc_macros::HashStable;
Expand Down Expand Up @@ -399,7 +399,7 @@ impl<'tcx> TypeFoldable<'tcx> for SubstsRef<'tcx> {
}
}

impl<'tcx> serialize::UseSpecializedDecodable for SubstsRef<'tcx> {}
impl<'tcx> rustc_serialize::UseSpecializedDecodable for SubstsRef<'tcx> {}

///////////////////////////////////////////////////////////////////////////
// Public trait `Subst`
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobserver = "0.1.11"
parking_lot = "0.7"
tempfile = "3.0.5"

serialize = { path = "../libserialize" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
rustc = { path = "../librustc" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
LinkerPluginLto, Lto};
use rustc::ty::TyCtxt;
use rustc_target::spec::{LinkerFlavor, LldFlavor};
use serialize::{json, Encoder};
use rustc_serialize::{json, Encoder};

/// For all the linkers we support, and information they might
/// need out of the shared crate context before we get rid of it.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs;
use std::path::Path;
use std::str;

use serialize::leb128;
use rustc_serialize::leb128;

// https://webassembly.github.io/spec/core/binary/modules.html#binary-importsec
const WASM_CUSTOM_SECTION_ID: u8 = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ indexmap = "1"
log = "0.4"
jobserver_crate = { version = "0.1.13", package = "jobserver" }
lazy_static = "1"
serialize = { path = "../libserialize" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
graphviz = { path = "../libgraphviz" }
cfg-if = "0.1.2"
crossbeam-utils = { version = "0.6.5", features = ["nightly"] }
Expand Down
Loading

0 comments on commit 6140371

Please sign in to comment.