incr.comp.: Remove default serialization implementations for things in rustc::hir::def_id so that we get an ICE instead of silently doing the wrong thing.
This commit is contained in:
parent
723028f308
commit
cb1ff24425
9 changed files with 81 additions and 62 deletions
|
|
@ -11,8 +11,7 @@
|
|||
use ty;
|
||||
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
use serialize::{self, Encoder, Decoder, Decodable, Encodable};
|
||||
|
||||
use serialize;
|
||||
use std::fmt;
|
||||
use std::u32;
|
||||
|
||||
|
|
@ -65,17 +64,8 @@ impl fmt::Display for CrateNum {
|
|||
}
|
||||
}
|
||||
|
||||
impl serialize::UseSpecializedEncodable for CrateNum {
|
||||
fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
s.emit_u32(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl serialize::UseSpecializedDecodable for CrateNum {
|
||||
fn default_decode<D: Decoder>(d: &mut D) -> Result<CrateNum, D::Error> {
|
||||
d.read_u32().map(CrateNum)
|
||||
}
|
||||
}
|
||||
impl serialize::UseSpecializedEncodable for CrateNum {}
|
||||
impl serialize::UseSpecializedDecodable for CrateNum {}
|
||||
|
||||
/// A DefIndex is an index into the hir-map for a crate, identifying a
|
||||
/// particular definition. It should really be considered an interned
|
||||
|
|
@ -151,19 +141,8 @@ impl DefIndex {
|
|||
}
|
||||
}
|
||||
|
||||
impl serialize::UseSpecializedEncodable for DefIndex {
|
||||
#[inline]
|
||||
fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
s.emit_u32(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl serialize::UseSpecializedDecodable for DefIndex {
|
||||
#[inline]
|
||||
fn default_decode<D: Decoder>(d: &mut D) -> Result<DefIndex, D::Error> {
|
||||
d.read_u32().map(DefIndex)
|
||||
}
|
||||
}
|
||||
impl serialize::UseSpecializedEncodable for DefIndex {}
|
||||
impl serialize::UseSpecializedDecodable for DefIndex {}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub enum DefIndexAddressSpace {
|
||||
|
|
@ -225,31 +204,8 @@ impl DefId {
|
|||
}
|
||||
}
|
||||
|
||||
impl serialize::UseSpecializedEncodable for DefId {
|
||||
#[inline]
|
||||
fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
let DefId {
|
||||
krate,
|
||||
index,
|
||||
} = *self;
|
||||
|
||||
krate.encode(s)?;
|
||||
index.encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl serialize::UseSpecializedDecodable for DefId {
|
||||
#[inline]
|
||||
fn default_decode<D: Decoder>(d: &mut D) -> Result<DefId, D::Error> {
|
||||
let krate = CrateNum::decode(d)?;
|
||||
let index = DefIndex::decode(d)?;
|
||||
|
||||
Ok(DefId {
|
||||
krate,
|
||||
index
|
||||
})
|
||||
}
|
||||
}
|
||||
impl serialize::UseSpecializedEncodable for DefId {}
|
||||
impl serialize::UseSpecializedDecodable for DefId {}
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
use hir;
|
||||
use hir::def;
|
||||
use hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE};
|
||||
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use hir::map as hir_map;
|
||||
use hir::map::definitions::{Definitions, DefKey, DefPathTable};
|
||||
use hir::svh::Svh;
|
||||
|
|
@ -180,7 +180,7 @@ impl EncodedMetadata {
|
|||
/// upstream crate.
|
||||
#[derive(Debug, RustcEncodable, RustcDecodable, Copy, Clone)]
|
||||
pub struct EncodedMetadataHash {
|
||||
pub def_index: DefIndex,
|
||||
pub def_index: u32,
|
||||
pub hash: ich::Fingerprint,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1042,7 +1042,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||
"enable incremental compilation (experimental)"),
|
||||
incremental_cc: bool = (false, parse_bool, [UNTRACKED],
|
||||
"enable cross-crate incremental compilation (even more experimental)"),
|
||||
incremental_queries: bool = (false, parse_bool, [UNTRACKED],
|
||||
incremental_queries: bool = (true, parse_bool, [UNTRACKED],
|
||||
"enable incremental compilation support for queries (experimental)"),
|
||||
incremental_info: bool = (false, parse_bool, [UNTRACKED],
|
||||
"print high-level information about incremental reuse (or the lack thereof)"),
|
||||
|
|
|
|||
|
|
@ -559,14 +559,25 @@ impl<'enc, 'a, 'tcx, E> CacheEncoder<'enc, 'a, 'tcx, E>
|
|||
impl<'enc, 'a, 'tcx, E> ty_codec::TyEncoder for CacheEncoder<'enc, 'a, 'tcx, E>
|
||||
where E: 'enc + ty_codec::TyEncoder
|
||||
{
|
||||
#[inline]
|
||||
fn position(&self) -> usize {
|
||||
self.encoder.position()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'enc, 'a, 'tcx, E> SpecializedEncoder<CrateNum> for CacheEncoder<'enc, 'a, 'tcx, E>
|
||||
where E: 'enc + ty_codec::TyEncoder
|
||||
{
|
||||
#[inline]
|
||||
fn specialized_encode(&mut self, cnum: &CrateNum) -> Result<(), Self::Error> {
|
||||
self.emit_u32(cnum.as_u32())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'enc, 'a, 'tcx, E> SpecializedEncoder<ty::Ty<'tcx>> for CacheEncoder<'enc, 'a, 'tcx, E>
|
||||
where E: 'enc + ty_codec::TyEncoder
|
||||
{
|
||||
#[inline]
|
||||
fn specialized_encode(&mut self, ty: &ty::Ty<'tcx>) -> Result<(), Self::Error> {
|
||||
ty_codec::encode_with_shorthand(self, ty,
|
||||
|encoder| &mut encoder.type_shorthands)
|
||||
|
|
@ -577,6 +588,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>>
|
|||
for CacheEncoder<'enc, 'a, 'tcx, E>
|
||||
where E: 'enc + ty_codec::TyEncoder
|
||||
{
|
||||
#[inline]
|
||||
fn specialized_encode(&mut self,
|
||||
predicates: &ty::GenericPredicates<'tcx>)
|
||||
-> Result<(), Self::Error> {
|
||||
|
|
@ -588,6 +600,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>>
|
|||
impl<'enc, 'a, 'tcx, E> SpecializedEncoder<hir::HirId> for CacheEncoder<'enc, 'a, 'tcx, E>
|
||||
where E: 'enc + ty_codec::TyEncoder
|
||||
{
|
||||
#[inline]
|
||||
fn specialized_encode(&mut self, id: &hir::HirId) -> Result<(), Self::Error> {
|
||||
let hir::HirId {
|
||||
owner,
|
||||
|
|
@ -605,6 +618,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<hir::HirId> for CacheEncoder<'enc, 'a
|
|||
impl<'enc, 'a, 'tcx, E> SpecializedEncoder<DefId> for CacheEncoder<'enc, 'a, 'tcx, E>
|
||||
where E: 'enc + ty_codec::TyEncoder
|
||||
{
|
||||
#[inline]
|
||||
fn specialized_encode(&mut self, id: &DefId) -> Result<(), Self::Error> {
|
||||
let def_path_hash = self.tcx.def_path_hash(*id);
|
||||
def_path_hash.encode(self)
|
||||
|
|
@ -614,6 +628,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<DefId> for CacheEncoder<'enc, 'a, 'tc
|
|||
impl<'enc, 'a, 'tcx, E> SpecializedEncoder<LocalDefId> for CacheEncoder<'enc, 'a, 'tcx, E>
|
||||
where E: 'enc + ty_codec::TyEncoder
|
||||
{
|
||||
#[inline]
|
||||
fn specialized_encode(&mut self, id: &LocalDefId) -> Result<(), Self::Error> {
|
||||
id.to_def_id().encode(self)
|
||||
}
|
||||
|
|
@ -632,6 +647,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<DefIndex> for CacheEncoder<'enc, 'a,
|
|||
impl<'enc, 'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'enc, 'a, 'tcx, E>
|
||||
where E: 'enc + ty_codec::TyEncoder
|
||||
{
|
||||
#[inline]
|
||||
fn specialized_encode(&mut self, node_id: &NodeId) -> Result<(), Self::Error> {
|
||||
let hir_id = self.tcx.hir.node_to_hir_id(*node_id);
|
||||
hir_id.encode(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue