-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix false positive type mismatch in const reference patterns #16131
Conversation
dd37f22
to
fa5a327
Compare
@bors r+ |
☀️ Test successful - checks-actions |
Pat::Or(pats) => pats.iter().all(|p| self.is_non_ref_pat(body, *p)), | ||
Pat::Path(p) => { | ||
let v = self.resolve_value_path_inner(p, pat.into()); | ||
v.is_some_and(|x| !matches!(x.0, hir_def::resolver::ValueNs::ConstId(_))) |
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.
I think we need to accomodate for enum unit variants and unit structs here as well no? (since we don't inherently treat their resolution as a const)
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 function should return true
for structs and enum variants, since we need to automatically dereference in those cases. That is, this code is valid:
match &&&&&&&e {
Enum::Variant => ()
}
But this is type error:
const ENUM_VARIANT_AS_CONST: Enum = Enum::Variant;
match &&&&&&&e {
ENUM_VARIANT_AS_CONST => ()
}
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.
👍
No description provided.