Add StableHashingContextLike to HashStable_Generic derive.
This commit is contained in:
parent
3e969e070f
commit
1de5fdb5ba
5 changed files with 20 additions and 0 deletions
|
|
@ -17,6 +17,10 @@ use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
|
|||
use smallvec::SmallVec;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
|
||||
impl<'ctx> syntax_pos::StableHashingContextLike for StableHashingContext<'ctx> {}
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_ma
|
|||
let generic: syn::GenericParam = parse_quote!(__CTX);
|
||||
s.add_bounds(synstructure::AddBounds::Generics);
|
||||
s.add_impl_generic(generic);
|
||||
s.add_where_predicate(parse_quote!{ __CTX: crate::StableHashingContextLike });
|
||||
let body = s.each(|bi| {
|
||||
let attrs = parse_attributes(bi.ast());
|
||||
if attrs.ignore {
|
||||
|
|
|
|||
|
|
@ -17,3 +17,8 @@
|
|||
|
||||
pub mod abi;
|
||||
pub mod spec;
|
||||
|
||||
/// 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 {}
|
||||
|
|
|
|||
|
|
@ -110,3 +110,8 @@ pub mod print {
|
|||
}
|
||||
|
||||
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 {}
|
||||
|
|
|
|||
|
|
@ -1562,3 +1562,8 @@ fn lookup_line(lines: &[BytePos], pos: BytePos) -> isize {
|
|||
Err(line) => line as isize - 1
|
||||
}
|
||||
}
|
||||
|
||||
/// 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 {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue