-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Expand, rename and improve incorrect_fn_null_checks
lint
#113657
Expand, rename and improve incorrect_fn_null_checks
lint
#113657
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
71652f6
to
bbc85af
Compare
Very good work, in the future it would be also good to lint on these:
etc. Maybe it might make sense to introduce a That's more for follow up work though. When working on #113652 I was also briefly considering using |
Especially I'd like this to get merged sooner than later as it would be nice if the lint rename wasn't exposed to stable users. Beta has just branched, so we have weeks of time, but still. |
Approved this but won't r+ as I think it would be better for someone from the compiler team to approve it -- note that as per @scottmcm this doesn't need a lang team FCP. |
bbc85af
to
ae36b80
Compare
☔ The latest upstream changes (presumably #114310) made this pull request unmergeable. Please resolve the merge conflicts. |
ae36b80
to
de576e1
Compare
compiler/rustc_lint/src/lints.rs
Outdated
pub enum PtrNullChecksDiag<'a> { | ||
#[diag(lint_ptr_null_checks_fn_ptr)] | ||
#[help(lint_help)] | ||
FnPtr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the expression's span and type be added here too, for symmetry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know, but added anyway since it doesn't make the output any worse.
de576e1
to
ee51953
Compare
@bors r+ rollup |
…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`
…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``
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#113657 (Expand, rename and improve `incorrect_fn_null_checks` lint) - rust-lang#114237 (parser: more friendly hints for handling `async move` in the 2015 edition) - rust-lang#114300 (Suggests turbofish in patterns) - rust-lang#114372 (const validation: point at where we found a pointer but expected an integer) - rust-lang#114395 ([rustc_span][perf] Hoist lookup sorted by words out of the loop.) - rust-lang#114403 (fix the span in the suggestion of remove question mark) - rust-lang#114408 (Temporary remove myself from review rotation) - rust-lang#114415 (Skip checking of `rustc_codegen_gcc` with vendoring enabled) r? `@ghost` `@rustbot` modify labels: rollup
It was added by rust-lang#113657 for its purposes. Now it is not used any more, remove it, as we use the attr now.
…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```
…, r=jackh726 Make useless_ptr_null_checks smarter about some std functions This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc. This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`). Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null. Follow-up of PR rust-lang#113657 Fixes rust-lang#114442
This PR,
incorrect_fn_null_checks
->useless_ptr_null_checks
ptr::from_mut
,ptr::from_ref
, as well as<*mut _>::cast
and<*const _>::cast_mut
Fixes #113601
cc @est31