diff --git a/compiler/rustc_attr/src/lib.rs b/compiler/rustc_attr/src/lib.rs index 868c041225581..53e3eaaab3768 100644 --- a/compiler/rustc_attr/src/lib.rs +++ b/compiler/rustc_attr/src/lib.rs @@ -27,6 +27,6 @@ pub use StabilityLevel::*; pub use rustc_ast::attr::*; -pub(crate) use rustc_session::HashStableContext; +pub(crate) use rustc_ast::HashStableContext; fluent_messages! { "../messages.ftl" } diff --git a/compiler/rustc_session/src/version.rs b/compiler/rustc_session/src/version.rs index 1ad8620bfba55..86725fc6502b0 100644 --- a/compiler/rustc_session/src/version.rs +++ b/compiler/rustc_session/src/version.rs @@ -1,7 +1,8 @@ +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use std::fmt::{self, Display}; #[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[derive(HashStable_Generic)] +//#[derive(HashStable_Generic)] pub struct RustcVersion { pub major: u16, pub minor: u16, @@ -17,3 +18,16 @@ impl Display for RustcVersion { write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch) } } + +// Handwritten because #[derive(HashStable_Generic)] would generate a stricter +// `Ctx: rustc_session::HashStableContext` bound. +impl HashStable for RustcVersion +where + Ctx: rustc_ast::HashStableContext, +{ + fn hash_stable(&self, hcx: &mut Ctx, hasher: &mut StableHasher) { + self.major.hash_stable(hcx, hasher); + self.minor.hash_stable(hcx, hasher); + self.patch.hash_stable(hcx, hasher); + } +}