1
Fork 0

Hash spans when interning.

This commit is contained in:
Camille GILLOT 2022-11-11 12:10:09 +00:00
parent c42a4245cc
commit d47424b833
3 changed files with 6 additions and 50 deletions

View file

@ -49,15 +49,13 @@ pub(super) enum BodyResolver<'tcx> {
impl<'a> StableHashingContext<'a> {
#[inline]
fn new_with_or_without_spans(
pub fn new(
sess: &'a Session,
definitions: &'a Definitions,
cstore: &'a dyn CrateStore,
source_span: &'a IndexVec<LocalDefId, Span>,
always_ignore_spans: bool,
) -> Self {
let hash_spans_initial =
!always_ignore_spans && !sess.opts.unstable_opts.incremental_ignore_spans;
let hash_spans_initial = !sess.opts.unstable_opts.incremental_ignore_spans;
StableHashingContext {
body_resolver: BodyResolver::Forbidden,
@ -71,33 +69,6 @@ impl<'a> StableHashingContext<'a> {
}
}
#[inline]
pub fn new(
sess: &'a Session,
definitions: &'a Definitions,
cstore: &'a dyn CrateStore,
source_span: &'a IndexVec<LocalDefId, Span>,
) -> Self {
Self::new_with_or_without_spans(
sess,
definitions,
cstore,
source_span,
/*always_ignore_spans=*/ false,
)
}
#[inline]
pub fn ignore_spans(
sess: &'a Session,
definitions: &'a Definitions,
cstore: &'a dyn CrateStore,
source_span: &'a IndexVec<LocalDefId, Span>,
) -> Self {
let always_ignore_spans = true;
Self::new_with_or_without_spans(sess, definitions, cstore, source_span, always_ignore_spans)
}
#[inline]
pub fn without_hir_bodies(&mut self, f: impl FnOnce(&mut StableHashingContext<'_>)) {
f(&mut StableHashingContext { body_resolver: BodyResolver::Ignore, ..self.clone() });
@ -202,10 +173,4 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
}
}
impl<'a> rustc_data_structures::intern::InternedHashingContext for StableHashingContext<'a> {
fn with_def_path_and_no_spans(&mut self, f: impl FnOnce(&mut Self)) {
self.while_hashing_spans(false, f);
}
}
impl<'a> rustc_session::HashStableContext for StableHashingContext<'a> {}