Skip to content

Commit

Permalink
Revert b983e42.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Jun 9, 2022
1 parent 15f5622 commit 7f51a1b
Show file tree
Hide file tree
Showing 23 changed files with 140 additions and 123 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_macros::HashStable_Generic;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_serialize::{self, Decoder, Encoder};
use rustc_span::source_map::{respan, Spanned};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
Expand Down Expand Up @@ -2488,11 +2488,11 @@ rustc_index::newtype_index! {
}
}

impl<S: Encoder> Encodable<S> for AttrId {
impl<S: Encoder> rustc_serialize::Encodable<S> for AttrId {
fn encode(&self, _s: &mut S) {}
}

impl<D: Decoder> Decodable<D> for AttrId {
impl<D: Decoder> rustc_serialize::Decodable<D> for AttrId {
fn decode(_: &mut D) -> AttrId {
crate::attr::mk_attr_id()
}
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::middle::dependency_format::Dependencies;
use rustc_middle::middle::exported_symbols::SymbolExportKind;
use rustc_middle::ty::query::{ExternProviders, Providers};
use rustc_serialize::opaque::{MemDecoder, MemEncoder};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_serialize::{opaque, Decodable, Decoder, Encodable, Encoder};
use rustc_session::config::{CrateType, OutputFilenames, OutputType, RUST_CGU_EXT};
use rustc_session::cstore::{self, CrateSource};
use rustc_session::utils::NativeLibKind;
Expand Down Expand Up @@ -204,7 +203,7 @@ const RUSTC_VERSION: Option<&str> = option_env!("CFG_VERSION");

impl CodegenResults {
pub fn serialize_rlink(codegen_results: &CodegenResults) -> Vec<u8> {
let mut encoder = MemEncoder::new();
let mut encoder = opaque::Encoder::new();
encoder.emit_raw_bytes(RLINK_MAGIC);
// `emit_raw_bytes` is used to make sure that the version representation does not depend on
// Encoder's inner representation of `u32`.
Expand All @@ -231,7 +230,7 @@ impl CodegenResults {
return Err(".rlink file was produced with encoding version {version_array}, but the current version is {RLINK_VERSION}".to_string());
}

let mut decoder = MemDecoder::new(&data[4..], 0);
let mut decoder = opaque::Decoder::new(&data[4..], 0);
let rustc_version = decoder.read_str();
let current_version = RUSTC_VERSION.unwrap();
if rustc_version != current_version {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_data_structures/src/fingerprint.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::stable_hasher;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_serialize::{Decodable, Encodable};
use std::convert::TryInto;
use std::hash::{Hash, Hasher};

Expand Down Expand Up @@ -142,14 +142,14 @@ impl stable_hasher::StableHasherResult for Fingerprint {

impl_stable_hash_via_hash!(Fingerprint);

impl<E: Encoder> Encodable<E> for Fingerprint {
impl<E: rustc_serialize::Encoder> Encodable<E> for Fingerprint {
#[inline]
fn encode(&self, s: &mut E) {
s.emit_raw_bytes(&self.to_le_bytes());
}
}

impl<D: Decoder> Decodable<D> for Fingerprint {
impl<D: rustc_serialize::Decoder> Decodable<D> for Fingerprint {
#[inline]
fn decode(d: &mut D) -> Self {
Fingerprint::from_le_bytes(d.read_raw_bytes(16).try_into().unwrap())
Expand Down Expand Up @@ -184,7 +184,7 @@ impl std::fmt::Display for PackedFingerprint {
}
}

impl<E: Encoder> Encodable<E> for PackedFingerprint {
impl<E: rustc_serialize::Encoder> Encodable<E> for PackedFingerprint {
#[inline]
fn encode(&self, s: &mut E) {
// Copy to avoid taking reference to packed field.
Expand All @@ -193,7 +193,7 @@ impl<E: Encoder> Encodable<E> for PackedFingerprint {
}
}

impl<D: Decoder> Decodable<D> for PackedFingerprint {
impl<D: rustc_serialize::Decoder> Decodable<D> for PackedFingerprint {
#[inline]
fn decode(d: &mut D) -> Self {
Self(Fingerprint::decode(d))
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_incremental/src/persist/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::memmap::Mmap;
use rustc_middle::dep_graph::{SerializedDepGraph, WorkProduct, WorkProductId};
use rustc_middle::ty::OnDiskCache;
use rustc_serialize::opaque::MemDecoder;
use rustc_serialize::opaque::Decoder;
use rustc_serialize::Decodable;
use rustc_session::config::IncrementalStateAssertion;
use rustc_session::Session;
Expand Down Expand Up @@ -156,7 +156,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {

if let LoadResult::Ok { data: (work_products_data, start_pos) } = load_result {
// Decode the list of work_products
let mut work_product_decoder = MemDecoder::new(&work_products_data[..], start_pos);
let mut work_product_decoder = Decoder::new(&work_products_data[..], start_pos);
let work_products: Vec<SerializedWorkProduct> =
Decodable::decode(&mut work_product_decoder);

Expand Down Expand Up @@ -193,7 +193,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
LoadResult::DataOutOfDate => LoadResult::DataOutOfDate,
LoadResult::Error { message } => LoadResult::Error { message },
LoadResult::Ok { data: (bytes, start_pos) } => {
let mut decoder = MemDecoder::new(&bytes, start_pos);
let mut decoder = Decoder::new(&bytes, start_pos);
let prev_commandline_args_hash = u64::decode(&mut decoder);

if prev_commandline_args_hash != expected_hash {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_incremental/src/persist/save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_data_structures::sync::join;
use rustc_middle::dep_graph::{DepGraph, SerializedDepGraph, WorkProduct, WorkProductId};
use rustc_middle::ty::TyCtxt;
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
use rustc_serialize::Encodable;
use rustc_serialize::Encodable as RustcEncodable;
use rustc_session::Session;
use std::fs;

Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ use rustc_middle::ty::codec::TyDecoder;
use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::GeneratorDiagnosticData;
use rustc_middle::ty::{self, ParameterizedOverTcx, Ty, TyCtxt, Visibility};
use rustc_serialize::opaque::MemDecoder;
use rustc_serialize::{Decodable, Decoder};
use rustc_serialize::{opaque, Decodable, Decoder};
use rustc_session::cstore::{
CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib,
};
Expand Down Expand Up @@ -155,7 +154,7 @@ struct ImportedSourceFile {
}

pub(super) struct DecodeContext<'a, 'tcx> {
opaque: MemDecoder<'a>,
opaque: opaque::Decoder<'a>,
cdata: Option<CrateMetadataRef<'a>>,
blob: &'a MetadataBlob,
sess: Option<&'tcx Session>,
Expand Down Expand Up @@ -187,7 +186,7 @@ pub(super) trait Metadata<'a, 'tcx>: Copy {
fn decoder(self, pos: usize) -> DecodeContext<'a, 'tcx> {
let tcx = self.tcx();
DecodeContext {
opaque: MemDecoder::new(self.blob(), pos),
opaque: opaque::Decoder::new(self.blob(), pos),
cdata: self.cdata(),
blob: self.blob(),
sess: self.sess().or(tcx.map(|tcx| tcx.sess)),
Expand Down Expand Up @@ -419,7 +418,7 @@ impl<'a, 'tcx> TyDecoder for DecodeContext<'a, 'tcx> {
where
F: FnOnce(&mut Self) -> R,
{
let new_opaque = MemDecoder::new(self.opaque.data, pos);
let new_opaque = opaque::Decoder::new(self.opaque.data, pos);
let old_opaque = mem::replace(&mut self.opaque, new_opaque);
let old_state = mem::replace(&mut self.lazy_state, LazyState::NoNode);
let r = f(self);
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ use rustc_middle::ty::codec::TyEncoder;
use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams};
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt};
use rustc_serialize::opaque::MemEncoder;
use rustc_serialize::{Encodable, Encoder};
use rustc_serialize::{opaque, Encodable, Encoder};
use rustc_session::config::CrateType;
use rustc_session::cstore::{ForeignModule, LinkagePreference, NativeLib};
use rustc_span::hygiene::{ExpnIndex, HygieneEncodeContext, MacroKind};
Expand All @@ -44,7 +43,7 @@ use std::num::NonZeroUsize;
use tracing::{debug, trace};

pub(super) struct EncodeContext<'a, 'tcx> {
opaque: MemEncoder,
opaque: opaque::Encoder,
tcx: TyCtxt<'tcx>,
feat: &'tcx rustc_feature::Features,

Expand Down Expand Up @@ -2182,7 +2181,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
}

fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
let mut encoder = MemEncoder::new();
let mut encoder = opaque::Encoder::new();
encoder.emit_raw_bytes(METADATA_HEADER);

// Will be filled with the root position after encoding everything.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, ReprOptions, Ty};
use rustc_middle::ty::{GeneratorDiagnosticData, ParameterizedOverTcx, TyCtxt};
use rustc_serialize::opaque::MemEncoder;
use rustc_serialize::opaque::Encoder;
use rustc_session::config::SymbolManglingVersion;
use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
use rustc_span::edition::Edition;
Expand Down Expand Up @@ -323,7 +323,7 @@ macro_rules! define_tables {
}

impl TableBuilders {
fn encode(&self, buf: &mut MemEncoder) -> LazyTables {
fn encode(&self, buf: &mut Encoder) -> LazyTables {
LazyTables {
$($name: self.$name.encode(buf)),+
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_metadata/src/rmeta/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use rustc_data_structures::fingerprint::Fingerprint;
use rustc_hir::def::{CtorKind, CtorOf};
use rustc_index::vec::Idx;
use rustc_middle::ty::ParameterizedOverTcx;
use rustc_serialize::opaque::MemEncoder;
use rustc_serialize::Encoder;
use rustc_serialize::opaque::Encoder;
use rustc_serialize::Encoder as _;
use rustc_span::hygiene::MacroKind;
use std::convert::TryInto;
use std::marker::PhantomData;
Expand Down Expand Up @@ -281,7 +281,7 @@ where
Some(value).write_to_bytes(&mut self.blocks[i]);
}

pub(crate) fn encode<const N: usize>(&self, buf: &mut MemEncoder) -> LazyTable<I, T>
pub(crate) fn encode<const N: usize>(&self, buf: &mut Encoder) -> LazyTable<I, T>
where
Option<T>: FixedSizeEncoding<ByteArray = [u8; N]>,
{
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_middle/src/mir/graph_cyclic_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_data_structures::graph::{
};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::OnceCell;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_serialize as serialize;

/// Helper type to cache the result of `graph::is_cyclic`.
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -36,17 +36,17 @@ impl GraphIsCyclicCache {
}
}

impl<S: Encoder> Encodable<S> for GraphIsCyclicCache {
impl<S: serialize::Encoder> serialize::Encodable<S> for GraphIsCyclicCache {
#[inline]
fn encode(&self, s: &mut S) {
Encodable::encode(&(), s);
serialize::Encodable::encode(&(), s);
}
}

impl<D: Decoder> Decodable<D> for GraphIsCyclicCache {
impl<D: serialize::Decoder> serialize::Decodable<D> for GraphIsCyclicCache {
#[inline]
fn decode(d: &mut D) -> Self {
let () = Decodable::decode(d);
let () = serialize::Decodable::decode(d);
Self::new()
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/mir/predecessors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::OnceCell;
use rustc_index::vec::IndexVec;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_serialize as serialize;
use smallvec::SmallVec;

use crate::mir::{BasicBlock, BasicBlockData};
Expand Down Expand Up @@ -54,12 +54,12 @@ impl PredecessorCache {
}
}

impl<S: Encoder> Encodable<S> for PredecessorCache {
impl<S: serialize::Encoder> serialize::Encodable<S> for PredecessorCache {
#[inline]
fn encode(&self, _s: &mut S) {}
}

impl<D: Decoder> Decodable<D> for PredecessorCache {
impl<D: serialize::Decoder> serialize::Decodable<D> for PredecessorCache {
#[inline]
fn decode(_: &mut D) -> Self {
Self::new()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/mir/switch_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::stable_map::FxHashMap;
use rustc_data_structures::sync::OnceCell;
use rustc_index::vec::IndexVec;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_serialize as serialize;
use smallvec::SmallVec;

use crate::mir::{BasicBlock, BasicBlockData, Terminator, TerminatorKind};
Expand Down Expand Up @@ -54,12 +54,12 @@ impl SwitchSourceCache {
}
}

impl<S: Encoder> Encodable<S> for SwitchSourceCache {
impl<S: serialize::Encoder> serialize::Encodable<S> for SwitchSourceCache {
#[inline]
fn encode(&self, _s: &mut S) {}
}

impl<D: Decoder> Decodable<D> for SwitchSourceCache {
impl<D: serialize::Decoder> serialize::Decodable<D> for SwitchSourceCache {
#[inline]
fn decode(_: &mut D) -> Self {
Self::new()
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/mir/traversal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::OnceCell;
use rustc_index::bit_set::BitSet;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_serialize as serialize;

use super::*;

Expand Down Expand Up @@ -365,12 +365,12 @@ impl PostorderCache {
}
}

impl<S: Encoder> Encodable<S> for PostorderCache {
impl<S: serialize::Encoder> serialize::Encodable<S> for PostorderCache {
#[inline]
fn encode(&self, _s: &mut S) {}
}

impl<D: Decoder> Decodable<D> for PostorderCache {
impl<D: serialize::Decoder> serialize::Decodable<D> for PostorderCache {
#[inline]
fn decode(_: &mut D) -> Self {
Self::new()
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_query_impl/src/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_query_system::dep_graph::DepContext;
use rustc_query_system::query::{QueryCache, QueryContext, QuerySideEffects};
use rustc_serialize::{
opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder},
opaque::{self, FileEncodeResult, FileEncoder, IntEncodedWithFixedSize},
Decodable, Decoder, Encodable, Encoder,
};
use rustc_session::Session;
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {

// Wrap in a scope so we can borrow `data`.
let footer: Footer = {
let mut decoder = MemDecoder::new(&data, start_pos);
let mut decoder = opaque::Decoder::new(&data, start_pos);

// Decode the *position* of the footer, which can be found in the
// last 8 bytes of the file.
Expand Down Expand Up @@ -438,7 +438,7 @@ impl<'sess> OnDiskCache<'sess> {
let serialized_data = self.serialized_data.read();
let mut decoder = CacheDecoder {
tcx,
opaque: MemDecoder::new(serialized_data.as_deref().unwrap_or(&[]), pos.to_usize()),
opaque: opaque::Decoder::new(serialized_data.as_deref().unwrap_or(&[]), pos.to_usize()),
source_map: self.source_map,
file_index_to_file: &self.file_index_to_file,
file_index_to_stable_id: &self.file_index_to_stable_id,
Expand All @@ -459,7 +459,7 @@ impl<'sess> OnDiskCache<'sess> {
/// will also handle things that contain `Ty` instances.
pub struct CacheDecoder<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
opaque: MemDecoder<'a>,
opaque: opaque::Decoder<'a>,
source_map: &'a SourceMap,
file_index_to_file: &'a Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
file_index_to_stable_id: &'a FxHashMap<SourceFileIndex, EncodedSourceFileId>,
Expand Down Expand Up @@ -511,7 +511,7 @@ trait DecoderWithPosition: Decoder {
fn position(&self) -> usize;
}

impl<'a> DecoderWithPosition for MemDecoder<'a> {
impl<'a> DecoderWithPosition for opaque::Decoder<'a> {
fn position(&self) -> usize {
self.position()
}
Expand Down Expand Up @@ -587,7 +587,7 @@ impl<'a, 'tcx> TyDecoder for CacheDecoder<'a, 'tcx> {
{
debug_assert!(pos < self.opaque.data.len());

let new_opaque = MemDecoder::new(self.opaque.data, pos);
let new_opaque = opaque::Decoder::new(self.opaque.data, pos);
let old_opaque = mem::replace(&mut self.opaque, new_opaque);
let r = f(self);
self.opaque = old_opaque;
Expand Down
Loading

0 comments on commit 7f51a1b

Please sign in to comment.