Skip to content

Conversation

relaxcn
Copy link
Contributor

@relaxcn relaxcn commented Sep 16, 2025

Fixes: #15392

changelog: [explicit_deref_methods]: Allow explicit deref or deref_mut method calls in implementation of the the Deref or DerefMut trait.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 16, 2025

r? @y21

rustbot has assigned @y21.
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

@github-actions
Copy link

github-actions bot commented Sep 16, 2025

Lintcheck changes for 6129b52

Lint Added Removed Changed
clippy::explicit_deref_methods 0 1 0

This comment will be updated if you push new changes

@rustbot

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Oct 8, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@relaxcn
Copy link
Contributor Author

relaxcn commented Oct 8, 2025

r? clippy

@rustbot rustbot assigned Alexendoo and unassigned y21 Oct 8, 2025
@relaxcn relaxcn changed the title allow explicit deref method call in deref or deref_mut impl of `D… allow explicit deref method call in deref impl of Deref trait Oct 12, 2025
@relaxcn relaxcn changed the title allow explicit deref method call in deref impl of Deref trait allow explicit deref or deref_mut method calls in impl of Deref or DerefMut trait Oct 13, 2025
@relaxcn
Copy link
Contributor Author

relaxcn commented Oct 13, 2025

@rustbot ready

@relaxcn relaxcn requested a review from ada4a October 23, 2025 03:08
Copy link
Contributor

@ada4a ada4a left a comment

Choose a reason for hiding this comment

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

Sorry for the possible confusion @relaxcn – I'm not actually a member of the Clippy Team and so I unfortunately can't merge this PR. But I think it's in a pretty good shape now, and we'll just need to wait for the actual reviewer to take a final look and approve – the reviewers are usually quite busy, so it can take a bit 😅

View changes since this review

mutbl,
} => {
// Skip when inside implementation of the `Deref` or `DerefMut` trait.
if in_deref_or_deref_mut_impl {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will end up allowing deref in DerefMut and vice versa, which could technically be solved by having a separate bool for each.. but honestly it might just be okay

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had created a PR to rustc, but it seems that they don't want to add a new diag item refer rust-lang/rust#147643.

Copy link
Contributor

@ada4a ada4a Oct 23, 2025

Choose a reason for hiding this comment

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

Honestly the suggestion to look-up both diagnostic and language items in the same call makes a lot of sense. I'll open a Zulip thread to discuss it with the team, if I don't forget. Thank you for giving it a go though:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks

/// let _ = <Foo as Deref>::deref(&foo);
/// ```
///
/// This lint also excludes explicit `deref` or `deref_mut` method calls inside implementations of the `Deref` or `DerefMut` traits.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think such additional information should go into the "What it does" section

@ada4a
Copy link
Contributor

ada4a commented Oct 23, 2025

@y21 friendly ping

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow explicit_deref_methods in Deref impls

5 participants