1
Fork 0

Auto merge of #83064 - cjgillot:fhash, r=jackh726

Tweaks to stable hashing
This commit is contained in:
bors 2021-03-13 20:21:40 +00:00
commit acca818928
6 changed files with 18 additions and 20 deletions

View file

@ -35,6 +35,7 @@ impl StableHasher {
StableHasher { state: SipHasher128::new_with_keys(0, 0) }
}
#[inline]
pub fn finish<W: StableHasherResult>(self) -> W {
W::finish(self)
}

View file

@ -74,6 +74,7 @@ pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_ma
s.bound_impl(
quote!(::rustc_data_structures::stable_hasher::HashStable<__CTX>),
quote! {
#[inline]
fn hash_stable(
&self,
__hcx: &mut __CTX,
@ -119,6 +120,7 @@ pub fn hash_stable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::To
>
),
quote! {
#[inline]
fn hash_stable(
&self,
__hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,

View file

@ -250,13 +250,6 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
&CACHE
}
fn byte_pos_to_line_and_col(
&mut self,
byte: BytePos,
) -> Option<(Lrc<SourceFile>, usize, BytePos)> {
self.source_map().byte_pos_to_line_and_col(byte)
}
fn span_data_to_lines_and_cols(
&mut self,
span: &SpanData,

View file

@ -1362,12 +1362,6 @@ fn update_disambiguator(expn_id: ExpnId) {
fn hash_spans(&self) -> bool {
true
}
fn byte_pos_to_line_and_col(
&mut self,
byte: BytePos,
) -> Option<(Lrc<SourceFile>, usize, BytePos)> {
self.caching_source_map.byte_pos_to_line_and_col(byte)
}
fn span_data_to_lines_and_cols(
&mut self,
span: &crate::SpanData,

View file

@ -1874,10 +1874,6 @@ pub trait HashStableContext {
fn expn_id_cache() -> &'static LocalKey<ExpnIdCache>;
fn hash_crate_num(&mut self, _: CrateNum, hasher: &mut StableHasher);
fn hash_spans(&self) -> bool;
fn byte_pos_to_line_and_col(
&mut self,
byte: BytePos,
) -> Option<(Lrc<SourceFile>, usize, BytePos)>;
fn span_data_to_lines_and_cols(
&mut self,
span: &SpanData,
@ -1906,9 +1902,10 @@ where
return;
}
self.ctxt().hash_stable(ctx, hasher);
if self.is_dummy() {
Hash::hash(&TAG_INVALID_SPAN, hasher);
self.ctxt().hash_stable(ctx, hasher);
return;
}
@ -1921,7 +1918,6 @@ where
Some(pos) => pos,
None => {
Hash::hash(&TAG_INVALID_SPAN, hasher);
span.ctxt.hash_stable(ctx, hasher);
return;
}
};
@ -1948,7 +1944,6 @@ where
let len = (span.hi - span.lo).0;
Hash::hash(&col_line, hasher);
Hash::hash(&len, hasher);
span.ctxt.hash_stable(ctx, hasher);
}
}