From a265bc22f161c7399c5a35835305d2dacf24753a Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 22:25:30 +0100 Subject: [PATCH] HashStable_Generic for libsyntax_pos. --- src/librustc/ich/impls_syntax.rs | 48 -------------------------------- src/libsyntax_pos/edition.rs | 5 +++- src/libsyntax_pos/hygiene.rs | 9 +++--- src/libsyntax_pos/lib.rs | 4 ++- 4 files changed, 12 insertions(+), 54 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index d86fd0f1dc36..42d6576ba6de 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -40,11 +40,6 @@ impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi { Unadjusted }); -impl_stable_hash_for!(enum ::syntax::edition::Edition { - Edition2015, - Edition2018, -}); - impl_stable_hash_for!(struct ::syntax::ast::Lit { kind, token, @@ -222,12 +217,6 @@ impl_stable_hash_for!(enum ::syntax::ast::MetaItemKind { NameValue(lit) }); -impl_stable_hash_for!(enum ::syntax_pos::hygiene::Transparency { - Transparent, - SemiTransparent, - Opaque, -}); - impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnData { kind, parent -> _, @@ -239,43 +228,6 @@ impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnData { edition }); -impl_stable_hash_for!(enum ::syntax_pos::hygiene::ExpnKind { - Root, - Macro(kind, descr), - AstPass(kind), - Desugaring(kind) -}); - -impl_stable_hash_for!(enum ::syntax_pos::hygiene::AstPass { - StdImports, - TestHarness, - ProcMacroHarness, - PluginMacroDefs, -}); - -impl_stable_hash_for!(enum ::syntax_pos::hygiene::DesugaringKind { - CondTemporary, - Async, - Await, - QuestionMark, - OpaqueTy, - ForLoop, - TryBlock -}); - -impl_stable_hash_for!(enum ::syntax_pos::FileName { - Real(pb), - Macros(s), - QuoteExpansion(s), - Anon(s), - MacroExpansion(s), - ProcMacroSourceCode(s), - CliCrateAttr(s), - CfgSpec(s), - Custom(s), - DocTest(pb, line), -}); - impl<'a> HashStable> for SourceFile { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { let SourceFile { diff --git a/src/libsyntax_pos/edition.rs b/src/libsyntax_pos/edition.rs index 00cd00f28378..727aad546f5f 100644 --- a/src/libsyntax_pos/edition.rs +++ b/src/libsyntax_pos/edition.rs @@ -2,8 +2,11 @@ use crate::symbol::{Symbol, sym}; use std::fmt; use std::str::FromStr; +use rustc_macros::HashStable_Generic; + /// The edition of the compiler (RFC 2052) -#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, RustcEncodable, RustcDecodable, Eq)] +#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, + RustcEncodable, RustcDecodable, Eq, HashStable_Generic)] pub enum Edition { // editions must be kept in order, oldest to newest diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index daabd0569dc0..eb420454f03d 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -59,7 +59,8 @@ pub struct ExpnId(u32); /// A property of a macro expansion that determines how identifiers /// produced by that expansion are resolved. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Hash, Debug, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Hash, Debug, + RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum Transparency { /// Identifier produced by a transparent expansion is always resolved at call-site. /// Call-site spans in procedural macros, hygiene opt-out in `macro` should use this. @@ -684,7 +685,7 @@ impl ExpnData { } /// Expansion kind. -#[derive(Clone, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum ExpnKind { /// No expansion, aka root expansion. Only `ExpnId::root()` has this kind. Root, @@ -744,7 +745,7 @@ impl MacroKind { } /// The kind of AST transform. -#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum AstPass { StdImports, TestHarness, @@ -764,7 +765,7 @@ impl AstPass { } /// The kind of compiler desugaring. -#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum DesugaringKind { /// We desugar `if c { i } else { e }` to `match $ExprKind::Use(c) { true => i, _ => e }`. /// However, we do not want to blame `c` for unreachability but rather say that `i` diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index b88d6dbc3f37..720ace90324b 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -15,6 +15,7 @@ #![feature(step_trait)] use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; +use rustc_macros::HashStable_Generic; pub mod source_map; @@ -66,7 +67,8 @@ impl Globals { scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals); /// Differentiates between real files and common virtual files. -#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)] +#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, + RustcDecodable, RustcEncodable, HashStable_Generic)] pub enum FileName { Real(PathBuf), /// A macro. This includes the full name of the macro, so that there are no clashes.