diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index 1677ef4b6079f..0222a3dde7ab9 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -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" diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index 057d878a0ab8d..f3edb5f862117 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -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; @@ -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 @@ -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. @@ -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 @@ -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 {} diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index e7b37d40b4b2f..3708a905a4b03 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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; @@ -92,7 +92,7 @@ impl HirId { } } -impl serialize::UseSpecializedEncodable for HirId { +impl rustc_serialize::UseSpecializedEncodable for HirId { fn default_encode(&self, s: &mut S) -> Result<(), S::Error> { let HirId { owner, @@ -104,7 +104,7 @@ impl serialize::UseSpecializedEncodable for HirId { } } -impl serialize::UseSpecializedDecodable for HirId { +impl rustc_serialize::UseSpecializedDecodable for HirId { fn default_decode(d: &mut D) -> Result { let owner = DefIndex::decode(d)?; let local_id = ItemLocalId::decode(d)?; diff --git a/src/librustc/hir/ptr.rs b/src/librustc/hir/ptr.rs index 3a87b36a1b434..1976b4c9e54ff 100644 --- a/src/librustc/hir/ptr.rs +++ b/src/librustc/hir/ptr.rs @@ -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}; diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index b508f91e01ebb..6840611d4be79 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -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; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 63e0107a4d882..c7d4fa3aec654 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -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 diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 2930f7690dd8e..859bc86d3a07d 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -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}; diff --git a/src/librustc/mir/cache.rs b/src/librustc/mir/cache.rs index d2cabb7e10bbf..3d33e249536c7 100644 --- a/src/librustc/mir/cache.rs +++ b/src/librustc/mir/cache.rs @@ -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>>> } -impl serialize::Encodable for Cache { - fn encode(&self, s: &mut S) -> Result<(), S::Error> { - serialize::Encodable::encode(&(), s) +impl rustc_serialize::Encodable for Cache { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { + Encodable::encode(&(), s) } } -impl serialize::Decodable for Cache { - fn decode(d: &mut D) -> Result { - serialize::Decodable::decode(d).map(|_v: ()| Self::new()) +impl rustc_serialize::Decodable for Cache { + fn decode(d: &mut D) -> Result { + Decodable::decode(d).map(|_v: ()| Self::new()) } } diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index c8bf250d02b36..51b2d0272a597 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -113,7 +113,7 @@ impl Allocation { } } -impl<'tcx> ::serialize::UseSpecializedDecodable for &'tcx Allocation {} +impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx Allocation {} /// Byte accessors impl<'tcx, Tag: Copy, Extra: AllocationExtra> Allocation { diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 5bec64d39fa62..121b6ac0ac88c 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -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; @@ -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 { diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index b3d92e8a604d1..50f16858c0486 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -9,7 +9,6 @@ use crate::hir::def_id::DefId; use crate::hir::{self, InlineAsm as HirInlineAsm}; use crate::mir::interpret::{ConstValue, PanicMessage, 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; @@ -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}; @@ -463,8 +463,8 @@ impl ClearCrossCrate { } } -impl serialize::UseSpecializedEncodable for ClearCrossCrate {} -impl serialize::UseSpecializedDecodable for ClearCrossCrate {} +impl rustc_serialize::UseSpecializedEncodable for ClearCrossCrate {} +impl rustc_serialize::UseSpecializedDecodable for ClearCrossCrate {} /// Grouped information about the source code origin of a MIR entity. /// Intended to be inspected by diagnostics and debuginfo. diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index 26e7cc9004d4e..e3c6eca02d554 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -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}; @@ -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),*> { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 538afa6054ff9..44897c8e90376 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -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; @@ -588,8 +588,8 @@ impl<'a, 'tcx> HashStable> 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>>; @@ -708,7 +708,7 @@ impl<'a, T> IntoIterator for &'a List { } } -impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List> {} +impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx List> {} impl List { #[inline(always)] @@ -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( @@ -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(&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> for AdtDef { diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index a25c1e34cf154..211a28fe9315f 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -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}; diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 5d17080a9b2bc..49a0fd827fbd8 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -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::*; @@ -640,7 +639,7 @@ impl<'tcx> Binder> { } } -impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List> {} +impl<'tcx> rustc_serialize::UseSpecializedDecodable for &'tcx List> {} impl<'tcx> List> { /// Returns the "principal def id" of this set of existential predicates. @@ -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 { @@ -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, diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 79dcd327f52d4..ea829da783e9b 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -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; @@ -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` diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml index e7ee06df7e12d..90d7320987c95 100644 --- a/src/librustc_codegen_ssa/Cargo.toml +++ b/src/librustc_codegen_ssa/Cargo.toml @@ -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" } diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index 32696d46cd577..882963f9174ec 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -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. diff --git a/src/librustc_codegen_ssa/back/wasm.rs b/src/librustc_codegen_ssa/back/wasm.rs index f90bb89fbe87d..2a9e81a788e52 100644 --- a/src/librustc_codegen_ssa/back/wasm.rs +++ b/src/librustc_codegen_ssa/back/wasm.rs @@ -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; diff --git a/src/librustc_data_structures/Cargo.toml b/src/librustc_data_structures/Cargo.toml index 79cbe26e73e83..288676ce3ff67 100644 --- a/src/librustc_data_structures/Cargo.toml +++ b/src/librustc_data_structures/Cargo.toml @@ -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"] } diff --git a/src/librustc_data_structures/fingerprint.rs b/src/librustc_data_structures/fingerprint.rs index 3bea965ef3041..c8012bb942461 100644 --- a/src/librustc_data_structures/fingerprint.rs +++ b/src/librustc_data_structures/fingerprint.rs @@ -1,7 +1,6 @@ use crate::stable_hasher; use std::mem; -use serialize; -use serialize::opaque::{EncodeResult, Encoder, Decoder}; +use rustc_serialize::opaque::{EncodeResult, Encoder, Decoder}; #[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy)] pub struct Fingerprint(u64, u64); @@ -85,17 +84,17 @@ impl stable_hasher::StableHasherResult for Fingerprint { impl_stable_hash_via_hash!(Fingerprint); -impl serialize::UseSpecializedEncodable for Fingerprint { } +impl rustc_serialize::UseSpecializedEncodable for Fingerprint { } -impl serialize::UseSpecializedDecodable for Fingerprint { } +impl rustc_serialize::UseSpecializedDecodable for Fingerprint { } -impl serialize::SpecializedEncoder for serialize::opaque::Encoder { +impl rustc_serialize::SpecializedEncoder for Encoder { fn specialized_encode(&mut self, f: &Fingerprint) -> Result<(), Self::Error> { f.encode_opaque(self) } } -impl<'a> serialize::SpecializedDecoder for serialize::opaque::Decoder<'a> { +impl<'a> rustc_serialize::SpecializedDecoder for Decoder<'a> { fn specialized_decode(&mut self) -> Result { Fingerprint::decode_opaque(self) } diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index c3c76e8160615..6f40d059be27f 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -1,3 +1,5 @@ +use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; + use std::fmt::Debug; use std::iter::{self, FromIterator}; use std::slice; @@ -8,8 +10,6 @@ use std::hash::Hash; use std::vec; use std::u32; -use rustc_serialize as serialize; - /// Represents some newtyped `usize` wrapper. /// /// Purpose: avoid mixing indexes for different bitvector domains. @@ -398,17 +398,9 @@ macro_rules! newtype_index { ); (@decodable $type:ident) => ( - impl $type { - fn __decodable__impl__hack() { - mod __more_hacks_because__self_doesnt_work_in_functions { - extern crate serialize; - use self::serialize::{Decodable, Decoder}; - impl Decodable for super::$type { - fn decode(d: &mut D) -> Result { - d.read_u32().map(Self::from) - } - } - } + impl ::rustc_serialize::Decodable for $type { + fn decode(d: &mut D) -> Result { + d.read_u32().map(Self::from) } } ); @@ -521,15 +513,15 @@ pub struct IndexVec { // not the phantom data. unsafe impl Send for IndexVec where T: Send {} -impl serialize::Encodable for IndexVec { - fn encode(&self, s: &mut S) -> Result<(), S::Error> { - serialize::Encodable::encode(&self.raw, s) +impl Encodable for IndexVec { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { + Encodable::encode(&self.raw, s) } } -impl serialize::Decodable for IndexVec { - fn decode(d: &mut D) -> Result { - serialize::Decodable::decode(d).map(|v| { +impl Decodable for IndexVec { + fn decode(d: &mut D) -> Result { + Decodable::decode(d).map(|v| { IndexVec { raw: v, _marker: PhantomData } }) } diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index a2407681e6d3f..3047119029abc 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -31,8 +31,6 @@ #[macro_use] extern crate log; -#[allow(unused_extern_crates)] -extern crate serialize as rustc_serialize; // used by deriving #[cfg(unix)] extern crate libc; #[macro_use] diff --git a/src/librustc_data_structures/svh.rs b/src/librustc_data_structures/svh.rs index df4f61768375e..3123c182b0f4c 100644 --- a/src/librustc_data_structures/svh.rs +++ b/src/librustc_data_structures/svh.rs @@ -7,7 +7,7 @@ use std::fmt; use std::hash::{Hash, Hasher}; -use serialize::{Encodable, Decodable, Encoder, Decoder}; +use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; use crate::stable_hasher; diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index d4c30dc6c4507..3162af5086d80 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -34,7 +34,7 @@ rustc_traits = { path = "../librustc_traits" } rustc_codegen_utils = { path = "../librustc_codegen_utils" } rustc_typeck = { path = "../librustc_typeck" } rustc_interface = { path = "../librustc_interface" } -serialize = { path = "../libserialize" } +rustc_serialize = { path = "../libserialize", package = "serialize" } syntax = { path = "../libsyntax" } smallvec = { version = "0.6.7", features = ["union", "may_dangle"] } syntax_ext = { path = "../libsyntax_ext" } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 2bc79e5080f3a..c139be07aa1d3 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -46,7 +46,7 @@ use rustc_interface::interface; use rustc_interface::util::get_codegen_sysroot; use rustc_data_structures::sync::SeqCst; -use serialize::json::ToJson; +use rustc_serialize::json::ToJson; use std::borrow::Cow; use std::cmp::max; diff --git a/src/librustc_errors/Cargo.toml b/src/librustc_errors/Cargo.toml index 4df9632cce26b..5a192e472aa85 100644 --- a/src/librustc_errors/Cargo.toml +++ b/src/librustc_errors/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] log = "0.4" -serialize = { path = "../libserialize" } +rustc_serialize = { path = "../libserialize", package = "serialize" } syntax_pos = { path = "../libsyntax_pos" } rustc_data_structures = { path = "../librustc_data_structures" } unicode-width = "0.1.4" diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 3269b85d0dd13..0a6c02c0ca68f 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -12,9 +12,6 @@ #![deny(rust_2018_idioms)] #![deny(unused_lifetimes)] -#[allow(unused_extern_crates)] -extern crate serialize as rustc_serialize; // used by deriving - pub use emitter::ColorConfig; use Level::*; diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml index 9678cb4f65545..a931ad3b66e21 100644 --- a/src/librustc_incremental/Cargo.toml +++ b/src/librustc_incremental/Cargo.toml @@ -15,7 +15,7 @@ log = "0.4" rand = "0.6" rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } -serialize = { path = "../libserialize" } +rustc_serialize = { path = "../libserialize", package = "serialize" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } rustc_fs_util = { path = "../librustc_fs_util" } diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index 569aa78c9d4b3..55aba7caa9d42 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -12,9 +12,6 @@ #![deny(unused_lifetimes)] #[macro_use] extern crate rustc; -#[allow(unused_extern_crates)] -extern crate serialize as rustc_serialize; // used by deriving - #[macro_use] extern crate log; mod assert_dep_graph; diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml index a0efec5ee7a7f..a90254e7e185f 100644 --- a/src/librustc_interface/Cargo.toml +++ b/src/librustc_interface/Cargo.toml @@ -16,7 +16,7 @@ smallvec = { version = "0.6.7", features = ["union", "may_dangle"] } syntax = { path = "../libsyntax" } syntax_ext = { path = "../libsyntax_ext" } syntax_pos = { path = "../libsyntax_pos" } -serialize = { path = "../libserialize" } +rustc_serialize = { path = "../libserialize", package = "serialize" } rustc = { path = "../librustc" } rustc_allocator = { path = "../librustc_allocator" } rustc_ast_borrowck = { path = "../librustc_ast_borrowck" } diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 772395bca2b37..b334971353ca3 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -52,7 +52,7 @@ use syntax::feature_gate::AttributeType; use syntax_pos::{FileName, edition::Edition, hygiene}; use syntax_ext; -use serialize::json; +use rustc_serialize::json; use tempfile::Builder as TempFileBuilder; use std::any::Any; diff --git a/src/librustc_interface/queries.rs b/src/librustc_interface/queries.rs index 570509ffb2b8c..9b79dc6350ca6 100644 --- a/src/librustc_interface/queries.rs +++ b/src/librustc_interface/queries.rs @@ -15,7 +15,7 @@ use rustc::ty::steal::Steal; use rustc::dep_graph::DepGraph; use rustc_passes::hir_stats; use rustc_plugin::registry::Registry; -use serialize::json; +use rustc_serialize::json; use std::cell::{Ref, RefMut, RefCell}; use std::ops::Deref; use std::rc::Rc; diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index e5c9f1bf2057b..a9f054d5e8be8 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -18,7 +18,7 @@ rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } errors = { path = "../librustc_errors", package = "rustc_errors" } rustc_target = { path = "../librustc_target" } -serialize = { path = "../libserialize" } +rustc_serialize = { path = "../libserialize", package = "serialize" } stable_deref_trait = "1.0.0" syntax = { path = "../libsyntax" } syntax_ext = { path = "../libsyntax_ext" } diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 826349362db25..b0fe06039f4e2 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -18,8 +18,6 @@ #![deny(unused_lifetimes)] extern crate libc; -#[allow(unused_extern_crates)] -extern crate serialize as rustc_serialize; // used by deriving extern crate proc_macro; #[macro_use] diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 8d1de4fd6c392..b7dd1d03e44ae 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -13,7 +13,6 @@ use rustc::ty::{self, Ty, ReprOptions}; use rustc_target::spec::{PanicStrategy, TargetTriple}; use rustc_data_structures::svh::Svh; -use rustc_serialize as serialize; use syntax::{ast, attr}; use syntax::edition::Edition; use syntax::symbol::Symbol; @@ -85,8 +84,8 @@ impl Clone for Lazy { } } -impl serialize::UseSpecializedEncodable for Lazy {} -impl serialize::UseSpecializedDecodable for Lazy {} +impl rustc_serialize::UseSpecializedEncodable for Lazy {} +impl rustc_serialize::UseSpecializedDecodable for Lazy {} /// A sequence of type T referred to by its absolute position /// in the metadata and length, and which can be decoded lazily. @@ -133,8 +132,8 @@ impl Clone for LazySeq { } } -impl serialize::UseSpecializedEncodable for LazySeq {} -impl serialize::UseSpecializedDecodable for LazySeq {} +impl rustc_serialize::UseSpecializedEncodable for LazySeq {} +impl rustc_serialize::UseSpecializedDecodable for LazySeq {} /// Encoding / decoding state for `Lazy` and `LazySeq`. #[derive(Copy, Clone, PartialEq, Eq, Debug)] diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index 2adbd03b24ff1..21008c737289f 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -20,7 +20,7 @@ rustc = { path = "../librustc" } rustc_target = { path = "../librustc_target" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } -serialize = { path = "../libserialize" } +rustc_serialize = { path = "../libserialize", package = "serialize" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } byteorder = { version = "1.1", features = ["i128"] } diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index f5e4661afa6b1..964f04d79b960 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -30,13 +30,9 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![deny(unused_lifetimes)] #[macro_use] extern crate log; -#[macro_use] -extern crate rustc; +#[macro_use] extern crate rustc; #[macro_use] extern crate rustc_data_structures; -#[allow(unused_extern_crates)] -extern crate serialize as rustc_serialize; // used by deriving -#[macro_use] -extern crate syntax; +#[macro_use] extern crate syntax; mod error_codes; diff --git a/src/librustc_target/Cargo.toml b/src/librustc_target/Cargo.toml index f1b21365e4bd4..cab1e0e01371d 100644 --- a/src/librustc_target/Cargo.toml +++ b/src/librustc_target/Cargo.toml @@ -12,5 +12,5 @@ path = "lib.rs" bitflags = "1.0" log = "0.4" rustc_data_structures = { path = "../librustc_data_structures" } -serialize = { path = "../libserialize" } +rustc_serialize = { path = "../libserialize", package = "serialize" } syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index dcd1eb5acdc85..a14bc66cc3833 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -18,8 +18,5 @@ #[macro_use] extern crate log; -#[allow(unused_extern_crates)] -extern crate serialize as rustc_serialize; // used by deriving - pub mod abi; pub mod spec; diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index ed62eb0dd20fc..34b580acbd5c0 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -34,7 +34,7 @@ //! the target's settings, though `target-feature` and `link-args` will *add* //! to the list specified by the target, rather than replace. -use serialize::json::{Json, ToJson}; +use rustc_serialize::json::{Json, ToJson}; use std::collections::BTreeMap; use std::default::Default; use std::{fmt, io}; @@ -306,7 +306,7 @@ macro_rules! supported_targets { #[cfg(test)] mod test_json_encode_decode { - use serialize::json::ToJson; + use rustc_serialize::json::ToJson; use super::Target; $(use super::$module;)+ @@ -1200,7 +1200,7 @@ impl Target { pub fn search(target_triple: &TargetTriple) -> Result { use std::env; use std::fs; - use serialize::json; + use rustc_serialize::json; fn load_file(path: &Path) -> Result { let contents = fs::read(path).map_err(|e| e.to_string())?; diff --git a/src/libserialize/tests/json.rs b/src/libserialize/tests/json.rs index 0fe3d4cfd6297..3fb6bda679bc1 100644 --- a/src/libserialize/tests/json.rs +++ b/src/libserialize/tests/json.rs @@ -1,4 +1,3 @@ -#[allow(unused_extern_crates)] extern crate serialize as rustc_serialize; use rustc_serialize::{Encodable, Decodable}; diff --git a/src/libserialize/tests/opaque.rs b/src/libserialize/tests/opaque.rs index 62a8f25124439..fff6fc69e7842 100644 --- a/src/libserialize/tests/opaque.rs +++ b/src/libserialize/tests/opaque.rs @@ -1,4 +1,3 @@ -#[allow(unused_extern_crates)] extern crate serialize as rustc_serialize; use rustc_serialize::{Encodable, Decodable}; diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml index 15c685b3b7b50..d4a9acc1569b4 100644 --- a/src/libsyntax/Cargo.toml +++ b/src/libsyntax/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] bitflags = "1.0" -serialize = { path = "../libserialize" } +rustc_serialize = { path = "../libserialize", package = "serialize" } log = "0.4" scoped-tls = "1.0" lazy_static = "1.0.0" diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b9b43c89346c7..dbfad3ef7f4de 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -22,7 +22,7 @@ use syntax_pos::{Span, DUMMY_SP}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lrc; -use serialize::{self, Decoder, Encoder}; +use rustc_serialize::{self, Decoder, Encoder}; use std::fmt; pub use rustc_target::abi::FloatTy; @@ -266,13 +266,13 @@ impl fmt::Display for NodeId { } } -impl serialize::UseSpecializedEncodable for NodeId { +impl rustc_serialize::UseSpecializedEncodable for NodeId { fn default_encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_u32(self.as_u32()) } } -impl serialize::UseSpecializedDecodable for NodeId { +impl rustc_serialize::UseSpecializedDecodable for NodeId { fn default_decode(d: &mut D) -> Result { d.read_u32().map(NodeId::from_u32) } @@ -2414,12 +2414,11 @@ impl ForeignItemKind { #[cfg(test)] mod tests { use super::*; - use serialize; // Are ASTs encodable? #[test] fn check_asts_encodable() { - fn assert_encodable() {} + fn assert_encodable() {} assert_encodable::(); } } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 3dea1977c4dac..0507a322a5fb2 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -24,9 +24,6 @@ #![recursion_limit="256"] -#[allow(unused_extern_crates)] -extern crate serialize as rustc_serialize; // used by deriving - pub use errors; use rustc_data_structures::sync::Lock; use rustc_data_structures::bit_set::GrowableBitSet; diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index be580dc2e6a7e..b5eb8ca94c07a 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -31,7 +31,7 @@ use std::iter::FromIterator; use std::ops::{Deref, DerefMut}; 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}; diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 88142344d79e0..34e68944926df 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -23,7 +23,7 @@ use syntax_pos::{BytePos, ExpnId, Span, DUMMY_SP}; #[cfg(target_arch = "x86_64")] use rustc_data_structures::static_assert_size; use rustc_data_structures::sync::Lrc; -use serialize::{Decoder, Decodable, Encoder, Encodable}; +use rustc_serialize::{Decoder, Decodable, Encoder, Encodable}; use smallvec::{SmallVec, smallvec}; use std::borrow::Cow; diff --git a/src/libsyntax_pos/Cargo.toml b/src/libsyntax_pos/Cargo.toml index eebd25d1fafd8..bc13d2a161132 100644 --- a/src/libsyntax_pos/Cargo.toml +++ b/src/libsyntax_pos/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" doctest = false [dependencies] -serialize = { path = "../libserialize" } +rustc_serialize = { path = "../libserialize", package = "serialize" } rustc_macros = { path = "../librustc_macros" } rustc_data_structures = { path = "../librustc_data_structures" } arena = { path = "../libarena" } diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 944b1da36d038..a96e5ef2323ee 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -30,7 +30,7 @@ use crate::{Span, DUMMY_SP}; use crate::edition::Edition; use crate::symbol::{kw, Symbol}; -use serialize::{Encodable, Decodable, Encoder, Decoder}; +use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; use std::fmt; diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index b9a062c0765f0..e5f0892b37be8 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -19,10 +19,7 @@ #![feature(specialization)] #![feature(step_trait)] -use serialize::{Encodable, Decodable, Encoder, Decoder}; - -#[allow(unused_extern_crates)] -extern crate serialize as rustc_serialize; // used by deriving +use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; pub mod edition; use edition::Edition; @@ -594,7 +591,7 @@ impl Default for Span { } } -impl serialize::UseSpecializedEncodable for Span { +impl rustc_serialize::UseSpecializedEncodable for Span { fn default_encode(&self, s: &mut S) -> Result<(), S::Error> { let span = self.data(); s.emit_struct("Span", 2, |s| { @@ -609,7 +606,7 @@ impl serialize::UseSpecializedEncodable for Span { } } -impl serialize::UseSpecializedDecodable for Span { +impl rustc_serialize::UseSpecializedDecodable for Span { fn default_decode(d: &mut D) -> Result { d.read_struct("Span", 2, |d| { let lo = d.read_struct_field("lo", 0, Decodable::decode)?; diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index f23ed7371c6dc..308f7d5d4e3fb 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::newtype_index; use rustc_macros::symbols; -use serialize::{Decodable, Decoder, Encodable, Encoder}; +use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use std::cmp::{PartialEq, Ordering, PartialOrd, Ord}; use std::fmt;