Skip to content
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

Extend incorrect_fn_null_checks lint to useless_ptr_null_checks #113601

Closed
est31 opened this issue Jul 12, 2023 · 0 comments · Fixed by #113657
Closed

Extend incorrect_fn_null_checks lint to useless_ptr_null_checks #113601

est31 opened this issue Jul 12, 2023 · 0 comments · Fixed by #113657
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@est31
Copy link
Member

est31 commented Jul 12, 2023

I'd suggest extending the newly added incorrect_fn_null_checks lint added in #111717 to cover cases of null comparison for other non-nullable types, like for instance in:

    let v: &u8 = &0;
    (v as *const u8).is_null();

This would involve a renaming of the lint to useless_ptr_null_checks or incorrect_ptr_null_checks. I don't think having multiple lints for different kinds of non-nullable types is useful (one for function pointers, one for references, etc).

See discussion starting from here.

cc @Urgau @scottmcm

@est31 est31 added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Jul 12, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 12, 2023
@Noratrieb Noratrieb added T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 12, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 3, 2023
…ck-lint, r=cjgillot

Expand, rename and improve `incorrect_fn_null_checks` lint

This PR,

 - firstly, expand the lint by now linting on references
 - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks`
 - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut`

Fixes rust-lang#113601
cc `@est31`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 3, 2023
…ck-lint, r=cjgillot

Expand, rename and improve `incorrect_fn_null_checks` lint

This PR,

 - firstly, expand the lint by now linting on references
 - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks`
 - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut`

Fixes rust-lang#113601
cc ``@est31``
@bors bors closed this as completed in 7518ae5 Aug 3, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Aug 4, 2023
…r=cjgillot

Expand, rename and improve `incorrect_fn_null_checks` lint

This PR,

 - firstly, expand the lint by now linting on references
 - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks`
 - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut`

Fixes rust-lang/rust#113601
cc ```@est31```
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Aug 10, 2023
…r=cjgillot

Expand, rename and improve `incorrect_fn_null_checks` lint

This PR,

 - firstly, expand the lint by now linting on references
 - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks`
 - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut`

Fixes rust-lang/rust#113601
cc ```@est31```
thomcc pushed a commit to tcdi/postgrestd that referenced this issue Oct 17, 2023
…r=cjgillot

Expand, rename and improve `incorrect_fn_null_checks` lint

This PR,

 - firstly, expand the lint by now linting on references
 - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks`
 - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut`

Fixes rust-lang/rust#113601
cc ```@est31```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
3 participants