diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2019-11-10 18:10:15 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2019-11-22 20:01:43 +0100 |
| commit | 0073d3be97707b34f747c2633ac02e8c9ea89452 (patch) | |
| tree | f78b93810d96a47653dd4563ccce26f7e8544fef /src/libsyntax | |
| parent | 3c5ddfdd57812bec0446e791d8e8bd74ff3949b3 (diff) | |
Export HashStable for DelimSpan, Lit and Path.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/tokenstream.rs | 2 |
3 files changed, 13 insertions, 3 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a9f03e4af5b..01abd09aa91 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -33,6 +33,7 @@ use syntax_pos::symbol::{kw, sym, Symbol}; use syntax_pos::{Span, DUMMY_SP, ExpnId}; use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::thin_vec::ThinVec; use rustc_index::vec::Idx; @@ -112,6 +113,15 @@ impl PartialEq<Symbol> for Path { } } +impl<CTX> HashStable<CTX> for Path { + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + self.segments.len().hash_stable(hcx, hasher); + for segment in &self.segments { + segment.ident.name.hash_stable(hcx, hasher); + } + } +} + impl Path { // Convert a span and an identifier to the corresponding // one-segment path. @@ -1411,7 +1421,7 @@ pub enum StrStyle { } /// An AST literal. -#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub struct Lit { /// The original literal token as written in source code. pub token: token::Lit, diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 8f091c06b4b..7865323f842 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -114,4 +114,4 @@ pub mod early_buffered_lints; /// Requirements for a `StableHashingContext` to be used in this crate. /// This is a hack to allow using the `HashStable_Generic` derive macro /// instead of implementing everything in librustc. -pub trait StableHashingContextLike {} +pub trait StableHashingContextLike: syntax_pos::StableHashingContextLike {} diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 2201f1ed6ca..40f00aaa5d8 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -444,7 +444,7 @@ impl Cursor { } } -#[derive(Debug, Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] +#[derive(Debug, Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable_Generic)] pub struct DelimSpan { pub open: Span, pub close: Span, |
