Skip to content
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

Merged
merged 2 commits into from
Dec 15, 2023

Conversation

HKalbasi
Copy link
Member

No description provided.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 15, 2023
@HKalbasi
Copy link
Member Author

@bors r+

@bors
Copy link
Contributor

bors commented Dec 15, 2023

📌 Commit fa5a327 has been approved by HKalbasi

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Dec 15, 2023

⌛ Testing commit fa5a327 with merge 21b06c1...

@bors
Copy link
Contributor

bors commented Dec 15, 2023

☀️ Test successful - checks-actions
Approved by: HKalbasi
Pushing 21b06c1 to master...

@bors bors merged commit 21b06c1 into rust-lang:master Dec 15, 2023
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(_)))
Copy link
Member

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)

Copy link
Member Author

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 => ()
}

Copy link
Member

@Veykril Veykril Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants