-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use proc-macro to derive HashStable everywhere #66279
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
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 |
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 |
☔ The latest upstream changes (presumably #66252) made this pull request unmergeable. Please resolve the merge conflicts. |
3a293d9
to
031a359
Compare
☔ The latest upstream changes (presumably #60026) made this pull request unmergeable. Please resolve the merge conflicts. |
There's some commits which only adds |
You can also create another PR where you introduce the |
☔ The latest upstream changes (presumably #66453) made this pull request unmergeable. Please resolve the merge conflicts. |
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 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
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelwoerister This skips all the other fields in PathSegment
and also the span field in Path
. Is this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petrochenkov Do you know why this ignores IsJoint
?
I tried converting more |
031a359
to
782cc9f
Compare
@@ -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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use HashStable_Generic
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It requires hashing the NodeId
. I have a commit with this change, I can add it to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. You can leave that for a later PR.
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 |
@bors r+ |
📌 Commit 782cc9f has been approved by |
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.
☀️ Test successful - checks-azure |
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.