Skip to content

Restrict the cases where ptr_eq triggers#14526

Merged
Alexendoo merged 1 commit intorust-lang:masterfrom
samueltardieu:push-rzovtxwoovyn
Apr 22, 2025
Merged

Restrict the cases where ptr_eq triggers#14526
Alexendoo merged 1 commit intorust-lang:masterfrom
samueltardieu:push-rzovtxwoovyn

Conversation

@samueltardieu
Copy link
Copy Markdown
Member

@samueltardieu samueltardieu commented Apr 2, 2025

ptr_eq was recently enhanced to lint on more cases of raw pointers comparison:

  • lint on all raw pointer comparison, by proposing to use [core|std]::ptr::eq(lhs, rhs) instead of lhs == rhs;
  • removing one symetric as usize on each size if needed
  • peeling any level of as *[const|mut] _ if the remaining expression can still be coerced into the original one (i.e., is a ref or raw pointer to the same type as before)

The current change restricts the lint to the cases where at least one level of symetric as usize, or any conversion to a raw pointer, could be removed. For example, a direct comparaison of two raw pointers will not trigger the lint anymore.

changelog: [ptr_eq]: do not lint when comparing two raw pointers directly with no casts involved

Fixes #14525

Loading
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.

clippy beta 1.87 lints all pointer comparisons, possibly too much?

8 participants