Skip to content

Improve &pin reference-pattern suggestions#156087

Open
P8L1 wants to merge 6 commits intorust-lang:mainfrom
P8L1:improve-pin-pattern-suggestions
Open

Improve &pin reference-pattern suggestions#156087
P8L1 wants to merge 6 commits intorust-lang:mainfrom
P8L1:improve-pin-pattern-suggestions

Conversation

@P8L1
Copy link
Copy Markdown

@P8L1 P8L1 commented May 2, 2026

This fills in the pin_ergonomics FIXME in borrow_pat_suggestion by making the diagnostic prefix account for both Pinnedness and Mutability.

Previously, the type-position suggestion path used ordinary reference spelling, which can spell & and &mut but cannot correctly spell pinned reference-pattern suggestions such as &pin const and &pin mut.

This is a diagnostic-only change. It adds focused UI coverage for both pinned const and pinned mut reference-pattern suggestions.

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

rustbot commented May 2, 2026

r? @mu001999

rustbot has assigned @mu001999.
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 73 candidates
  • Random selection from 21 candidates

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_hir_typeck/src/pat.rs Outdated
@mu001999
Copy link
Copy Markdown
Member

mu001999 commented May 2, 2026

r? Kivooeo

@rustbot rustbot assigned Kivooeo and unassigned mu001999 May 2, 2026
@P8L1 P8L1 force-pushed the improve-pin-pattern-suggestions branch from 1b1b070 to 61cf5f2 Compare May 2, 2026 14:00
@Kivooeo
Copy link
Copy Markdown
Member

Kivooeo commented May 2, 2026

two things i think should be improved

  1. currently it make suggestion to a code, that requires pin_ergonomics feature to work, so imo this suggestion should only emits when this feature is enabled (i don't know if there is a way to check so)
  2. i don't sure if this code only works on nightly or not? this suggestion have zero meaning on stable

so, if we can't check 1 point then i'd say to wait on stabilization of this feature, and then fix that fixme

@Kivooeo
Copy link
Copy Markdown
Member

Kivooeo commented May 2, 2026

@rustbot authot

@P8L1
Copy link
Copy Markdown
Author

P8L1 commented May 3, 2026

two things i think should be improved

  1. currently it make suggestion to a code, that requires pin_ergonomics feature to work, so imo this suggestion should only emits when this feature is enabled (i don't know if there is a way to check so)
  2. i don't sure if this code only works on nightly or not? this suggestion have zero meaning on stable

so, if we can't check 1 point then i'd say to wait on stabilization of this feature, and then fix that fixme

Thanks for the suggestion. I gated the type-position &pin suggestion on pin_ergonomics, so crates without the feature fall back to the existing non-pin reference suggestion instead.

Comment thread tests/ui/pin-ergonomics/ref-pat-suggestions.rs
Co-authored-by: Redddy <midzy0228@gmail.com>
@rust-log-analyzer

This comment has been minimized.

UI tests already allow incomplete_features by default, so the explicit allow is unnecessary.
@rust-log-analyzer

This comment has been minimized.

Bless line-number changes after removing the redundant incomplete_features allow.
@P8L1 P8L1 requested a review from Kivooeo May 3, 2026 15:28
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.

6 participants