Auto merge of #68997 - Zoxc:pure-node-id, r=petrochenkov
Panic if NodeIds are used for incremental compilation r? @michaelwoerister
This commit is contained in:
commit
116dff95a3
2 changed files with 3 additions and 45 deletions
|
|
@ -220,27 +220,8 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::HirId {
|
|||
}
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
match hcx.node_id_hashing_mode {
|
||||
NodeIdHashingMode::Ignore => {
|
||||
// Don't do anything.
|
||||
}
|
||||
NodeIdHashingMode::HashDefPath => {
|
||||
hcx.definitions.node_to_hir_id(*self).hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToStableHashKey<StableHashingContext<'a>> for ast::NodeId {
|
||||
type KeyType = (DefPathHash, hir::ItemLocalId);
|
||||
|
||||
#[inline]
|
||||
fn to_stable_hash_key(
|
||||
&self,
|
||||
hcx: &StableHashingContext<'a>,
|
||||
) -> (DefPathHash, hir::ItemLocalId) {
|
||||
hcx.definitions.node_to_hir_id(*self).to_stable_hash_key(hcx)
|
||||
fn hash_stable(&self, _: &mut StableHashingContext<'a>, _: &mut StableHasher) {
|
||||
panic!("Node IDs should not appear in incremental state");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use rustc_span::hygiene::{ExpnId, SyntaxContext};
|
|||
use rustc_span::source_map::{SourceMap, StableSourceFileId};
|
||||
use rustc_span::{BytePos, SourceFile, Span, DUMMY_SP};
|
||||
use std::mem;
|
||||
use syntax::ast::{Ident, NodeId};
|
||||
use syntax::ast::Ident;
|
||||
|
||||
const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE;
|
||||
|
||||
|
|
@ -680,16 +680,6 @@ impl<'a, 'tcx> SpecializedDecoder<hir::HirId> for CacheDecoder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
// `NodeId`s are not stable across compilation sessions, so we store them in their
|
||||
// `HirId` representation. This allows use to map them to the current `NodeId`.
|
||||
impl<'a, 'tcx> SpecializedDecoder<NodeId> for CacheDecoder<'a, 'tcx> {
|
||||
#[inline]
|
||||
fn specialized_decode(&mut self) -> Result<NodeId, Self::Error> {
|
||||
let hir_id = hir::HirId::decode(self)?;
|
||||
Ok(self.tcx().hir().hir_to_node_id(hir_id))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> SpecializedDecoder<Fingerprint> for CacheDecoder<'a, 'tcx> {
|
||||
fn specialized_decode(&mut self) -> Result<Fingerprint, Self::Error> {
|
||||
Fingerprint::decode_opaque(&mut self.opaque)
|
||||
|
|
@ -928,19 +918,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
// `NodeId`s are not stable across compilation sessions, so we store them in their
|
||||
// `HirId` representation. This allows use to map them to the current `NodeId`.
|
||||
impl<'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'a, 'tcx, E>
|
||||
where
|
||||
E: 'a + 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)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> SpecializedEncoder<Fingerprint> for CacheEncoder<'a, 'tcx, opaque::Encoder> {
|
||||
fn specialized_encode(&mut self, f: &Fingerprint) -> Result<(), Self::Error> {
|
||||
f.encode_opaque(&mut self.encoder)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue