Skip to content

suspicious_double_ref_op: report unadjusted return type#157872

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
qaijuang:fix-suspicious-double-ref-op-type
Jun 15, 2026
Merged

suspicious_double_ref_op: report unadjusted return type#157872
rust-bors[bot] merged 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

@camelid camelid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@camelid

camelid commented Jun 15, 2026

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f86d694 has been approved by camelid

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 15, 2026
…=camelid

`suspicious_double_ref_op`: report unadjusted return type

`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
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job dist-x86_64-msvc failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 15, 2026
@rust-bors

rust-bors Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 92df1e4 failed: CI. Failed job:

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors retry

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 15, 2026
…-op-type, r=camelid

`suspicious_double_ref_op`: report unadjusted return type

`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 rust-lang#146227
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 15, 2026
…-op-type, r=camelid

`suspicious_double_ref_op`: report unadjusted return type

`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 rust-lang#146227
rust-bors Bot pushed a commit that referenced this pull request Jun 15, 2026
Rollup of 6 pull requests

Successful merges:

 - #157899 (Update LLVM to 22.1.7)
 - #157029 (stabilize feature `float_algebraic`)
 - #157872 (`suspicious_double_ref_op`: report unadjusted return type)
 - #157877 (Stabilize `nonzero_from_str_radix`)
 - #157900 (Update intrinsics wrapping documentation)
 - #157904 (Add Alice Ryhl to libs review rotation)
rust-bors Bot pushed a commit that referenced this pull request Jun 15, 2026
Rollup of 6 pull requests

Successful merges:

 - #157899 (Update LLVM to 22.1.7)
 - #157029 (stabilize feature `float_algebraic`)
 - #157872 (`suspicious_double_ref_op`: report unadjusted return type)
 - #157877 (Stabilize `nonzero_from_str_radix`)
 - #157900 (Update intrinsics wrapping documentation)
 - #157904 (Add Alice Ryhl to libs review rotation)
rust-bors Bot pushed a commit that referenced this pull request Jun 15, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #157029 (stabilize feature `float_algebraic`)
 - #157872 (`suspicious_double_ref_op`: report unadjusted return type)
 - #157877 (Stabilize `nonzero_from_str_radix`)
 - #157900 (Update intrinsics wrapping documentation)
 - #157904 (Add Alice Ryhl to libs review rotation)
 - #157911 (Rename `errors.rs` file to `diagnostics.rs` (10/N))
@rust-bors rust-bors Bot merged commit 22b4b28 into rust-lang:main Jun 15, 2026
13 of 14 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 15, 2026
rust-timer added a commit that referenced this pull request Jun 15, 2026
Rollup merge of #157872 - qaijuang:fix-suspicious-double-ref-op-type, r=camelid

`suspicious_double_ref_op`: report unadjusted return type

`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
@qaijuang qaijuang deleted the fix-suspicious-double-ref-op-type branch June 15, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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

5 participants