Skip to content

Commit 1de5fdb

Browse files
committed
Add StableHashingContextLike to HashStable_Generic derive.
1 parent 3e969e0 commit 1de5fdb

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

src/librustc/ich/impls_syntax.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
1717
use smallvec::SmallVec;
1818
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1919

20+
impl<'ctx> syntax_pos::StableHashingContextLike for StableHashingContext<'ctx> {}
21+
impl<'ctx> syntax::StableHashingContextLike for StableHashingContext<'ctx> {}
22+
impl<'ctx> rustc_target::StableHashingContextLike for StableHashingContext<'ctx> {}
23+
2024
impl_stable_hash_for!(struct ::syntax::ast::Lit {
2125
kind,
2226
token,

src/librustc_macros/src/hash_stable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_ma
5151
let generic: syn::GenericParam = parse_quote!(__CTX);
5252
s.add_bounds(synstructure::AddBounds::Generics);
5353
s.add_impl_generic(generic);
54+
s.add_where_predicate(parse_quote!{ __CTX: crate::StableHashingContextLike });
5455
let body = s.each(|bi| {
5556
let attrs = parse_attributes(bi.ast());
5657
if attrs.ignore {

src/librustc_target/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@
1717

1818
pub mod abi;
1919
pub mod spec;
20+
21+
/// Requirements for a `StableHashingContext` to be used in this crate.
22+
/// This is a hack to allow using the `HashStable_Generic` derive macro
23+
/// instead of implementing everything in librustc.
24+
pub trait StableHashingContextLike {}

src/libsyntax/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,8 @@ pub mod print {
110110
}
111111

112112
pub mod early_buffered_lints;
113+
114+
/// Requirements for a `StableHashingContext` to be used in this crate.
115+
/// This is a hack to allow using the `HashStable_Generic` derive macro
116+
/// instead of implementing everything in librustc.
117+
pub trait StableHashingContextLike {}

src/libsyntax_pos/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,3 +1562,8 @@ fn lookup_line(lines: &[BytePos], pos: BytePos) -> isize {
15621562
Err(line) => line as isize - 1
15631563
}
15641564
}
1565+
1566+
/// Requirements for a `StableHashingContext` to be used in this crate.
1567+
/// This is a hack to allow using the `HashStable_Generic` derive macro
1568+
/// instead of implementing everything in librustc.
1569+
pub trait StableHashingContextLike {}

0 commit comments

Comments
 (0)