Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upUse proc-macro to derive HashStable everywhere #66279
Conversation
This comment has been minimized.
This comment has been minimized.
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
3a293d9
to
031a359
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
There's some commits which only adds |
This comment has been minimized.
This comment has been minimized.
You can also create another PR where you introduce the |
This comment has been minimized.
This comment has been minimized.
|
Add a proc-macro to derive HashStable in librustc dependencies A second proc-macro is added to derive HashStable for crates librustc depends on. This proc-macro HashStable_Generic (to bikeshed) allows to decouple code and some librustc's boilerplate. Not everything is migrated, because `Span` and `TokenKind` require to be placed inside librustc. Types using them stay there too. Split out of #66279 r? @Zoxc
Just derive Hashstable in librustc Split out of rust-lang#66279 r? @Zoxc
Add a proc-macro to derive HashStable in librustc dependencies A second proc-macro is added to derive HashStable for crates librustc depends on. This proc-macro HashStable_Generic (to bikeshed) allows to decouple code and some librustc's boilerplate. Not everything is migrated, because `Span` and `TokenKind` require to be placed inside librustc. Types using them stay there too. Split out of rust-lang#66279 r? @Zoxc
Add a proc-macro to derive HashStable in librustc dependencies A second proc-macro is added to derive HashStable for crates librustc depends on. This proc-macro HashStable_Generic (to bikeshed) allows to decouple code and some librustc's boilerplate. Not everything is migrated, because `Span` and `TokenKind` require to be placed inside librustc. Types using them stay there too. Split out of #66279 r? @Zoxc
Add a proc-macro to derive HashStable in librustc dependencies A second proc-macro is added to derive HashStable for crates librustc depends on. This proc-macro HashStable_Generic (to bikeshed) allows to decouple code and some librustc's boilerplate. Not everything is migrated, because `Span` and `TokenKind` require to be placed inside librustc. Types using them stay there too. Split out of rust-lang#66279 r? @Zoxc
Add a proc-macro to derive HashStable in librustc dependencies A second proc-macro is added to derive HashStable for crates librustc depends on. This proc-macro HashStable_Generic (to bikeshed) allows to decouple code and some librustc's boilerplate. Not everything is migrated, because `Span` and `TokenKind` require to be placed inside librustc. Types using them stay there too. Split out of rust-lang#66279 r? @Zoxc
Add a proc-macro to derive HashStable in librustc dependencies A second proc-macro is added to derive HashStable for crates librustc depends on. This proc-macro HashStable_Generic (to bikeshed) allows to decouple code and some librustc's boilerplate. Not everything is migrated, because `Span` and `TokenKind` require to be placed inside librustc. Types using them stay there too. Split out of #66279 r? @Zoxc
Add a proc-macro to derive HashStable in librustc dependencies A second proc-macro is added to derive HashStable for crates librustc depends on. This proc-macro HashStable_Generic (to bikeshed) allows to decouple code and some librustc's boilerplate. Not everything is migrated, because `Span` and `TokenKind` require to be placed inside librustc. Types using them stay there too. Split out of #66279 r? @Zoxc
This comment has been minimized.
This comment has been minimized.
Rebased. |
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); |
This comment has been minimized.
This comment has been minimized.
Zoxc
Nov 23, 2019
Contributor
@michaelwoerister This skips all the other fields in PathSegment
and also the span field in Path
. Is this intentional?
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Nov 25, 2019
Contributor
It looks like the NodeId field was added later and the whole implementation was lifted to a more general context in 759bd01. It would be good to hash the generic arguments too.
This comment has been minimized.
This comment has been minimized.
I would like to get rid of the |
where CTX: crate::StableHashingContextLike | ||
{ | ||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { | ||
for sub_tt in self.trees() { |
This comment has been minimized.
This comment has been minimized.
Zoxc
Nov 23, 2019
Contributor
@nnethercote It seems like this iterator does a bunch of Lrc
clones. Is there some reason this can't just hash the Vec<TreeAndJoint>
? It also doesn't hash IsJoint
, which seems questionable.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I tried converting more |
031a359
to
782cc9f
@@ -18,7 +18,12 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; | |||
|
|||
impl<'ctx> rustc_target::StableHashingContextLike for StableHashingContext<'ctx> {} | |||
|
|||
impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident }); | |||
impl<'a> HashStable<StableHashingContext<'a>> for ast::Lifetime { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjgillot
Nov 25, 2019
Author
Contributor
It requires hashing the NodeId
. I have a commit with this change, I can add it to this PR.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I guess you'd have to change all the impls to be generic. That doesn't really seem like a win. I guess we can just keep |
This comment has been minimized.
This comment has been minimized.
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Use proc-macro to derive HashStable everywhere Hello, A second proc-macro is added to derive HashStable for crates librustc depends on. This proc-macro `HashStable_Generic` (to bikeshed) allows to decouple code and strip much of librustc's boilerplate. Still, two implementations `Span` and `TokenKind` require to be placed in librustc. The latter only depends on the `bug` macro. Advise welcome on how to sever that link. A trait `StableHasingContextLike` has been introduced at each crate root, in order to handle those implementations which require librustc's very `StableHashingContext`. This overall effort allowed to remove the `impl_stable_hash_for` macro. Each commit passes the `x.py check`. I still have to double check there was no change in the implementation.
This comment has been minimized.
This comment has been minimized.
|
cjgillot commentedNov 10, 2019
Hello,
A second proc-macro is added to derive HashStable for crates librustc depends on.
This proc-macro
HashStable_Generic
(to bikeshed) allows to decouple code and strip much of librustc's boilerplate.Still, two implementations
Span
andTokenKind
require to be placed in librustc.The latter only depends on the
bug
macro. Advise welcome on how to sever that link.A trait
StableHasingContextLike
has been introduced at each crate root,in order to handle those implementations which require librustc's very
StableHashingContext
.This overall effort allowed to remove the
impl_stable_hash_for
macro.Each commit passes the
x.py check
.I still have to double check there was no change in the implementation.