Skip to content

Don't suggest a binding rename for qualified path patterns#158055

Open
ChronoCoders wants to merge 1 commit into
rust-lang:mainfrom
ChronoCoders:diag-assoc-const-pattern-binding
Open

Don't suggest a binding rename for qualified path patterns#158055
ChronoCoders wants to merge 1 commit into
rust-lang:mainfrom
ChronoCoders:diag-assoc-const-pattern-binding

Conversation

@ChronoCoders

@ChronoCoders ChronoCoders commented Jun 17, 2026

Copy link
Copy Markdown

Fixes #153926.

When a pattern is a qualified path like Owner::K whose type doesn't match the scrutinee, rustc was labelling it "K is interpreted as an associated constant, not a new binding" and suggesting Owner::other_k. A multi-segment path can never be a binding, so the label is irrelevant and the suggestion is always wrong. This only emits that label and suggestion for a lone identifier now; qualified paths just get the type mismatch.

A multi-segment path like `Owner::K` can never be a pattern binding, so
the "interpreted as a constant, not a new binding" label and the
"introduce a new binding instead" suggestion are misleading there. Only
emit them for a lone identifier.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 17, 2026
@rustbot

rustbot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @tiif (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 19 candidates

@ChronoCoders

Copy link
Copy Markdown
Author

r? @fmease

@rustbot rustbot assigned fmease and unassigned tiif Jun 17, 2026
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading label & invalid suggestion on (multi-segment) assoc const of wrong type in pattern

4 participants