Skip to content

Commit 0073d3b

Browse files
committed
Export HashStable for DelimSpan, Lit and Path.
1 parent 3c5ddfd commit 0073d3b

File tree

5 files changed

+13
-26
lines changed

5 files changed

+13
-26
lines changed

src/librustc/ich/hcx.rs

-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use std::cell::RefCell;
1414
use syntax::ast;
1515
use syntax::source_map::SourceMap;
1616
use syntax::symbol::Symbol;
17-
use syntax::tokenstream::DelimSpan;
1817
use syntax_pos::{Span, DUMMY_SP};
1918
use syntax_pos::hygiene::{self, SyntaxContext};
2019

@@ -364,13 +363,6 @@ impl<'a> syntax_pos::StableHashingContextLike for StableHashingContext<'a> {
364363
}
365364
}
366365

367-
impl<'a> HashStable<StableHashingContext<'a>> for DelimSpan {
368-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
369-
self.open.hash_stable(hcx, hasher);
370-
self.close.hash_stable(hcx, hasher);
371-
}
372-
}
373-
374366
pub fn hash_stable_trait_impls<'a>(
375367
hcx: &mut StableHashingContext<'a>,
376368
hasher: &mut StableHasher,

src/librustc/ich/impls_syntax.rs

-15
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2020
impl<'ctx> syntax::StableHashingContextLike for StableHashingContext<'ctx> {}
2121
impl<'ctx> rustc_target::StableHashingContextLike for StableHashingContext<'ctx> {}
2222

23-
impl_stable_hash_for!(struct ::syntax::ast::Lit {
24-
kind,
25-
token,
26-
span
27-
});
28-
2923
impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
3024

3125
impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident });
@@ -53,15 +47,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
5347
}
5448
}
5549

56-
impl<'a> HashStable<StableHashingContext<'a>> for ast::Path {
57-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
58-
self.segments.len().hash_stable(hcx, hasher);
59-
for segment in &self.segments {
60-
segment.ident.name.hash_stable(hcx, hasher);
61-
}
62-
}
63-
}
64-
6550
impl_stable_hash_for!(struct ::syntax::ast::AttrItem {
6651
path,
6752
tokens,

src/libsyntax/ast.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use syntax_pos::symbol::{kw, sym, Symbol};
3333
use syntax_pos::{Span, DUMMY_SP, ExpnId};
3434

3535
use rustc_data_structures::fx::FxHashSet;
36+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3637
use rustc_data_structures::sync::Lrc;
3738
use rustc_data_structures::thin_vec::ThinVec;
3839
use rustc_index::vec::Idx;
@@ -112,6 +113,15 @@ impl PartialEq<Symbol> for Path {
112113
}
113114
}
114115

116+
impl<CTX> HashStable<CTX> for Path {
117+
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
118+
self.segments.len().hash_stable(hcx, hasher);
119+
for segment in &self.segments {
120+
segment.ident.name.hash_stable(hcx, hasher);
121+
}
122+
}
123+
}
124+
115125
impl Path {
116126
// Convert a span and an identifier to the corresponding
117127
// one-segment path.
@@ -1411,7 +1421,7 @@ pub enum StrStyle {
14111421
}
14121422

14131423
/// An AST literal.
1414-
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
1424+
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
14151425
pub struct Lit {
14161426
/// The original literal token as written in source code.
14171427
pub token: token::Lit,

src/libsyntax/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@ pub mod early_buffered_lints;
114114
/// Requirements for a `StableHashingContext` to be used in this crate.
115115
/// This is a hack to allow using the `HashStable_Generic` derive macro
116116
/// instead of implementing everything in librustc.
117-
pub trait StableHashingContextLike {}
117+
pub trait StableHashingContextLike: syntax_pos::StableHashingContextLike {}

src/libsyntax/tokenstream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl Cursor {
444444
}
445445
}
446446

447-
#[derive(Debug, Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
447+
#[derive(Debug, Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable_Generic)]
448448
pub struct DelimSpan {
449449
pub open: Span,
450450
pub close: Span,

0 commit comments

Comments
 (0)