Skip to content

Lint more cases with ptr_eq #14339

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

Merged
merged 2 commits into from
Mar 4, 2025
Merged

Conversation

samueltardieu
Copy link
Contributor

This PR:

  • lints more case of raw pointer comparisons
  • do not omit the named function to raw pointer conversion before suggesting
  • trigger the ptr_eq lint only if cmp_null doesn't trigger first, as this is a more specialized version
  • lints against != in addition to ==

The ptr_eq code has been moved from under operators to ptr.rs, in order to benefit from factorization.

Fix #14337

changelog: [ptr_eq]: handle more cases

Also, do not strip conversions of a function pointer to a `*const`, as
no implicit conversion will take place.
The `cmp_null` lint is more specialized than `ptr_eq`. The former should
take precedence, unless the user allows it.
@rustbot
Copy link
Collaborator

rustbot commented Mar 2, 2025

r? @Manishearth

rustbot has assigned @Manishearth.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 2, 2025
@Manishearth Manishearth added this pull request to the merge queue Mar 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 3, 2025
@samueltardieu
Copy link
Contributor Author

The merge error seems unrelated:

Running linkchecker on "linkcheck/clippy"...
error: toolchain 'nightly-2025-02-27-x86_64-unknown-linux-gnu' is not installed
help: run `rustup toolchain install nightly-2025-02-27-x86_64-unknown-linux-gnu` to install it

@Manishearth Could you retry it?

@smoelius
Copy link
Contributor

smoelius commented Mar 3, 2025

@samueltardieu Do you have reason to believe it will succeed?

That error seems to have popped up in a few places, e.g.:

EDIT: I haven't figured out what wants that particular nightly toolchain or why.

@lapla-cogito
Copy link
Contributor

I don't think simply retrying will work, because this job has been consistently failing with the same error lately.
https://github.com/rust-lang/rust-clippy/actions/workflows/remark.yml

I'm taking a closer look, but I'm still trying to figure out the cause.

@samueltardieu
Copy link
Contributor Author

Thanks @lapla-cogito, I am on my phone and did not see that other job failed as well.

@flip1995 flip1995 added this pull request to the merge queue Mar 4, 2025
Merged via the queue into rust-lang:master with commit cdc1d9d Mar 4, 2025
11 checks passed
@samueltardieu samueltardieu deleted the push-rrquumnsylny branch March 5, 2025 08:12
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.

Fix fail, named function cast to raw ptr, == it
6 participants