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 | |
| parent | 3c5ddfdd57812bec0446e791d8e8bd74ff3949b3 (diff) | |
| download | rust-0073d3be97707b34f747c2633ac02e8c9ea89452.tar.gz rust-0073d3be97707b34f747c2633ac02e8c9ea89452.zip | |
Export HashStable for DelimSpan, Lit and Path.
| -rw-r--r-- | src/librustc/ich/hcx.rs | 8 | ||||
| -rw-r--r-- | src/librustc/ich/impls_syntax.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/tokenstream.rs | 2 |
5 files changed, 13 insertions, 26 deletions
diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index da45f93b40c..c67e1a7da7b 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -14,7 +14,6 @@ use std::cell::RefCell; use syntax::ast; use syntax::source_map::SourceMap; use syntax::symbol::Symbol; -use syntax::tokenstream::DelimSpan; use syntax_pos::{Span, DUMMY_SP}; use syntax_pos::hygiene::{self, SyntaxContext}; @@ -364,13 +363,6 @@ impl<'a> syntax_pos::StableHashingContextLike for StableHashingContext<'a> { } } -impl<'a> HashStable<StableHashingContext<'a>> for DelimSpan { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - self.open.hash_stable(hcx, hasher); - self.close.hash_stable(hcx, hasher); - } -} - pub fn hash_stable_trait_impls<'a>( hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher, diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 83852bbbfc4..e1281d67703 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -20,12 +20,6 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; impl<'ctx> syntax::StableHashingContextLike for StableHashingContext<'ctx> {} impl<'ctx> rustc_target::StableHashingContextLike for StableHashingContext<'ctx> {} -impl_stable_hash_for!(struct ::syntax::ast::Lit { - kind, - token, - span -}); - impl_stable_hash_for_spanned!(::syntax::ast::LitKind); impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident }); @@ -53,15 +47,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] { } } -impl<'a> HashStable<StableHashingContext<'a>> for ast::Path { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - self.segments.len().hash_stable(hcx, hasher); - for segment in &self.segments { - segment.ident.name.hash_stable(hcx, hasher); - } - } -} - impl_stable_hash_for!(struct ::syntax::ast::AttrItem { path, tokens, 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, |
