Skip to content

suspicious_double_ref_op: report unadjusted return type#157872

Open
qaijuang wants to merge 2 commits into
rust-lang:mainfrom
qaijuang:fix-suspicious-double-ref-op-type
Open

suspicious_double_ref_op: report unadjusted return type#157872
qaijuang wants to merge 2 commits into
rust-lang:mainfrom
qaijuang:fix-suspicious-double-ref-op-type

Conversation

@qaijuang

@qaijuang qaijuang commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

suspicious_double_ref_op uses the adjusted expression type to distinguish a no-op call from a double-reference operation. When the result is used as another method's receiver, that type can include the parent method's receiver adjustment.

For example, file.clone().write(&[]) reports that clone returns &mut &File, even though it returns &File.

This PR continues to use the adjusted type for lint classification, but now uses the method call's unadjusted type in the diagnostic. The same issue affects .deref(), so the regression test covers both operations.

Fixes #146227

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 13, 2026
@qaijuang qaijuang marked this pull request as ready for review June 13, 2026 20:26
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 13, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 13, 2026
@rustbot

rustbot commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

r? @camelid

rustbot has assigned @camelid.
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 22 candidates

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.

suspicious_double_ref_op names incorrect return type in method receiver

3 participants