Skip to content

Commit

Permalink
Auto merge of #15040 - lnicola:hash-state-name, r=Veykril
Browse files Browse the repository at this point in the history
fix: Use a more obscure hasher name in derive expansion

Closes #15039
  • Loading branch information
bors committed Jun 13, 2023
2 parents 1f1fe81 + 0b441ca commit 07bc6cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions crates/hir-def/src/macro_expansion_tests/builtin_derive_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,18 @@ enum Command {
}
impl < > core::hash::Hash for Command< > where {
fn hash<H: core::hash::Hasher>(&self , state: &mut H) {
core::mem::discriminant(self ).hash(state);
fn hash<H: core::hash::Hasher>(&self , ra_expand_state: &mut H) {
core::mem::discriminant(self ).hash(ra_expand_state);
match self {
Command::Move {
x: x, y: y,
}
=> {
x.hash(state);
y.hash(state);
x.hash(ra_expand_state);
y.hash(ra_expand_state);
}
, Command::Do(f0, )=> {
f0.hash(state);
f0.hash(ra_expand_state);
}
, Command::Jump=> {}
,
Expand Down
8 changes: 4 additions & 4 deletions crates/hir-expand/src/builtin_derive_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,15 +613,15 @@ fn hash_expand(
span: tt::TokenId::unspecified(),
};
return quote! {
fn hash<H: #krate::hash::Hasher>(&self, state: &mut H) {
fn hash<H: #krate::hash::Hasher>(&self, ra_expand_state: &mut H) {
match #star self {}
}
};
}
let arms = adt.shape.as_pattern(&adt.name).into_iter().zip(adt.shape.field_names()).map(
|(pat, names)| {
let expr = {
let it = names.iter().map(|x| quote! { #x . hash(state); });
let it = names.iter().map(|x| quote! { #x . hash(ra_expand_state); });
quote! { {
##it
} }
Expand All @@ -633,8 +633,8 @@ fn hash_expand(
},
);
quote! {
fn hash<H: #krate::hash::Hasher>(&self, state: &mut H) {
#krate::mem::discriminant(self).hash(state);
fn hash<H: #krate::hash::Hasher>(&self, ra_expand_state: &mut H) {
#krate::mem::discriminant(self).hash(ra_expand_state);
match self {
##arms
}
Expand Down

0 comments on commit 07bc6cb

Please sign in to comment.