Restrict the cases where ptr_eq triggers#14526
Merged
Alexendoo merged 1 commit intorust-lang:masterfrom Apr 22, 2025
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ptr_eqwas recently enhanced to lint on more cases of raw pointers comparison:[core|std]::ptr::eq(lhs, rhs)instead oflhs == rhs;as usizeon each size if neededas *[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 involvedFixes #14525