type-mismatch
incorrectly emitted when a struct/emum with a field named state
derives Hash
#15043
Labels
C-bug
Category: bug
rust-analyzer version:
rust-analyzer version: 0.3.1549-standalone (d567091 2023-06-11)
rustc version:
rustc 1.70.0 (90c541806 2023-05-31)
relevant settings:
None that I can think of (though I would be happy to share the settings I've set, if need be!)
Hi there! I was writing up some code for a custom collection type, when rust-analyzer started emitting a
type-mismatch
error on me. I found this odd, because rust was itself was still compiling the code just fine -cargo check
,cargo build
, andcargo clippy
all ran without error, even after saving the file with the supposedtype-mismatch
error.Upon further investigation, I've found that I'm able to reliably reproduce the issue when all of the following are true:
state
#[derive(Hash)]
attribute.Upon meeting these conditions, rust-analyzer will start incorrectly emitting a
type-mismatch
error until either 1) the Hash derive is removed, or 2) thestate
field is renamed. (To be clear, I am unsure if this issue is specific to the Hash derive. It's possible it may affect other derives as well.)Here is a minimal reproduction of the issue - both a struct and enum are provided.
Either of those will produce a
type-mismatch
error from rust-analyzer, that saysexpected &mut {unknown}, found &()
.P.S. Thanks in advance for making rust-analyzer a little less buggy. :)
The text was updated successfully, but these errors were encountered: