Skip to content

Commit 116dff9

Browse files
committed
Auto merge of #68997 - Zoxc:pure-node-id, r=petrochenkov
Panic if NodeIds are used for incremental compilation r? @michaelwoerister
2 parents 8040bc9 + 8a37811 commit 116dff9

File tree

2 files changed

+3
-45
lines changed

2 files changed

+3
-45
lines changed

src/librustc/ich/hcx.rs

+2-21
Original file line numberDiff line numberDiff line change
@@ -220,27 +220,8 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::HirId {
220220
}
221221

222222
impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
223-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
224-
match hcx.node_id_hashing_mode {
225-
NodeIdHashingMode::Ignore => {
226-
// Don't do anything.
227-
}
228-
NodeIdHashingMode::HashDefPath => {
229-
hcx.definitions.node_to_hir_id(*self).hash_stable(hcx, hasher);
230-
}
231-
}
232-
}
233-
}
234-
235-
impl<'a> ToStableHashKey<StableHashingContext<'a>> for ast::NodeId {
236-
type KeyType = (DefPathHash, hir::ItemLocalId);
237-
238-
#[inline]
239-
fn to_stable_hash_key(
240-
&self,
241-
hcx: &StableHashingContext<'a>,
242-
) -> (DefPathHash, hir::ItemLocalId) {
243-
hcx.definitions.node_to_hir_id(*self).to_stable_hash_key(hcx)
223+
fn hash_stable(&self, _: &mut StableHashingContext<'a>, _: &mut StableHasher) {
224+
panic!("Node IDs should not appear in incremental state");
244225
}
245226
}
246227

src/librustc/ty/query/on_disk_cache.rs

+1-24
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_span::hygiene::{ExpnId, SyntaxContext};
2222
use rustc_span::source_map::{SourceMap, StableSourceFileId};
2323
use rustc_span::{BytePos, SourceFile, Span, DUMMY_SP};
2424
use std::mem;
25-
use syntax::ast::{Ident, NodeId};
25+
use syntax::ast::Ident;
2626

2727
const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE;
2828

@@ -680,16 +680,6 @@ impl<'a, 'tcx> SpecializedDecoder<hir::HirId> for CacheDecoder<'a, 'tcx> {
680680
}
681681
}
682682

683-
// `NodeId`s are not stable across compilation sessions, so we store them in their
684-
// `HirId` representation. This allows use to map them to the current `NodeId`.
685-
impl<'a, 'tcx> SpecializedDecoder<NodeId> for CacheDecoder<'a, 'tcx> {
686-
#[inline]
687-
fn specialized_decode(&mut self) -> Result<NodeId, Self::Error> {
688-
let hir_id = hir::HirId::decode(self)?;
689-
Ok(self.tcx().hir().hir_to_node_id(hir_id))
690-
}
691-
}
692-
693683
impl<'a, 'tcx> SpecializedDecoder<Fingerprint> for CacheDecoder<'a, 'tcx> {
694684
fn specialized_decode(&mut self) -> Result<Fingerprint, Self::Error> {
695685
Fingerprint::decode_opaque(&mut self.opaque)
@@ -928,19 +918,6 @@ where
928918
}
929919
}
930920

931-
// `NodeId`s are not stable across compilation sessions, so we store them in their
932-
// `HirId` representation. This allows use to map them to the current `NodeId`.
933-
impl<'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'a, 'tcx, E>
934-
where
935-
E: 'a + TyEncoder,
936-
{
937-
#[inline]
938-
fn specialized_encode(&mut self, node_id: &NodeId) -> Result<(), Self::Error> {
939-
let hir_id = self.tcx.hir().node_to_hir_id(*node_id);
940-
hir_id.encode(self)
941-
}
942-
}
943-
944921
impl<'a, 'tcx> SpecializedEncoder<Fingerprint> for CacheEncoder<'a, 'tcx, opaque::Encoder> {
945922
fn specialized_encode(&mut self, f: &Fingerprint) -> Result<(), Self::Error> {
946923
f.encode_opaque(&mut self.encoder)

0 commit comments

Comments
 (0)