Skip to content

needless_borrow: do not contradict dangerous_implicit_autorefs #14810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented May 15, 2025

Rust 1.88 introduces the dangerous_implicit_autorefs lint which warns about using implicit autorefs on a place obtained from a raw pointer, as this may create aliasing issues.

Prevent clippy::needless_borrow from triggering in this case, by disabling the lint when taking a reference on a raw pointer dereference. There might be a better way for doing this in the long run with a finer way of distinguish the problematic cases, but this will prevent Clippy from contradicting the compiler in the meantime.

Fixes #14743

changelog: [needless_borrow]: do not contradict the compiler's dangerous_implicit_autorefs lint even though the refererences are not mandatory

@rustbot label +beta-nominated

Summary Notes

Generated by triagebot, see help for how to add more

@rustbot
Copy link
Collaborator

rustbot commented May 15, 2025

r? @blyxyas

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties beta-nominated Nominated for backporting to the compiler in the beta channel. labels May 15, 2025
@samueltardieu
Copy link
Contributor Author

samueltardieu commented May 15, 2025

@Urgau Any other cases you might be thinking about that would not be covered here? After our discussion, I switched to ignoring references on dereferences of raw pointers altogether.

Rust 1.88 introduces the `dangerous_implicit_autorefs` lint which warns
about using implicit autorefs on a place obtained from a raw pointer,
as this may create aliasing issues.

Prevent `clippy::needless_borrow` from triggering in this case,
by disabling the lint when taking a reference on a raw pointer
dereference. There might be a better way for doing this in the long run
with a finer way of distinguish the problematic cases, but this will
prevent Clippy from contradicting the compiler in the meantime.
@samueltardieu
Copy link
Contributor Author

samueltardieu commented May 15, 2025

@rustbot note Beta nomination for 1.88

The dangerous_implicit_autorefs compiler lint that we contradict has already entered beta 1.88. We should also target the same version to avoid lints going back and forth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-nominated Nominated for backporting to the compiler in the beta channel. 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.

dangerous_implicit_autorefs lint suggestion triggers clippy::needless_borrow
3 participants