Skip to content

Fix deref field pattern suggestions and improve error messages#154543

Open
chenyukang wants to merge 1 commit intorust-lang:mainfrom
chenyukang:yukang-fix-146995-deref-field-suggestion
Open

Fix deref field pattern suggestions and improve error messages#154543
chenyukang wants to merge 1 commit intorust-lang:mainfrom
chenyukang:yukang-fix-146995-deref-field-suggestion

Conversation

@chenyukang
Copy link
Copy Markdown
Member

@chenyukang chenyukang commented Mar 29, 2026

Fixes #146995

@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 Mar 29, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 29, 2026

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

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

|
LL | match &arg.field {
| +
LL | Some(ref s) => s.push('a'),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it's perfect if we suggest ref mut here, but current diagnostic is better than &arg.field, because it's at least a right direction, since user will get this if apply ref fix here:

help: consider changing this to be a mutable reference
  |
7 |         Some(ref mut s) => s.push('a'), //~ ERROR cannot borrow `s` as mutable
  |                  +++

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.

Confusing suggestion when doing a conditional destructuring on a field of Deref struct

3 participants