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: goto-definition for constants inside range pattern #16759

Merged

Conversation

roife
Copy link
Contributor

@roife roife commented Mar 5, 2024

Fix #15653.

This PR addresses the issue where it was not possible to navigate to constants in range patterns, specifically including two major changes:

  1. Previously, both the start and end fields in Pat::Range were of type LiteralOrConst. When performing goto-definition on constants inside range patterns, r-a would use resolve_bind_pat_to_const to find their definitions. However, because the content of a Const is not Pat but Path, it was not stored in the source_map, so resolve_bind_pat_to_const would returns None. This PR changes them to Const(PatId), so that during the lowering process, they are considered as a pat, allowing their definitions to be found later through resolve_bind_pat_to_const.

  2. The process related to range patterns in MIR-lowering has been modified to correctly handle the above changes.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 5, 2024
@Veykril
Copy link
Member

Veykril commented Mar 5, 2024

Thanks
@bors r+

@bors
Copy link
Collaborator

bors commented Mar 5, 2024

📌 Commit 9cc3a9c has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Mar 5, 2024

⌛ Testing commit 9cc3a9c with merge 223238d...

@bors
Copy link
Collaborator

bors commented Mar 5, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 223238d to master...

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.

No definition found for const when referenced from match pattern by range
4 participants