Skip to content

New zero_ptr lint. #1561

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
Feb 22, 2017
Merged

New zero_ptr lint. #1561

merged 2 commits into from
Feb 22, 2017

Conversation

llogiq
Copy link
Contributor

@llogiq llogiq commented Feb 21, 2017

This fixes #1047. I did not bother to add a full suggestion, because replacing with std::ptr::null() may still lead to inference failures.

This fixes #1047. I did not bother to add a full suggestion,
because replacing with `std::ptr::null()` may still lead to
inference failures.
/// **Example:**
///
/// ```rust
/// ß as *const u32
Copy link
Contributor

Choose a reason for hiding this comment

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

german keyboard failure.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 21, 2017

It could suggest ptr::null_mut<T>() and it could lint things like (1 - 1) as *const T if a LateLintPass were used. But I'm fine with this, as it catches the important case.

@oli-obk oli-obk merged commit 1992979 into master Feb 22, 2017
@oli-obk oli-obk deleted the zero_ptr branch February 22, 2017 12:34
@Arnavion
Copy link
Contributor

https://github.com/Manishearth/rust-clippy/wiki needs to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest ptr::null, ptr::null_mut over casting.
3 participants