Auto merge of #114494 - est31:extend_useless_ptr_null_checks, 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 #113657 Fixes #114442
This commit is contained in:
commit
635c4a5e61
18 changed files with 94 additions and 46 deletions
|
@ -1178,7 +1178,6 @@ symbols! {
|
|||
ptr_cast_const,
|
||||
ptr_cast_mut,
|
||||
ptr_const_is_null,
|
||||
ptr_from_mut,
|
||||
ptr_from_ref,
|
||||
ptr_guaranteed_cmp,
|
||||
ptr_is_null,
|
||||
|
@ -1337,6 +1336,7 @@ symbols! {
|
|||
rustc_main,
|
||||
rustc_mir,
|
||||
rustc_must_implement_one_of,
|
||||
rustc_never_returns_null_ptr,
|
||||
rustc_nonnull_optimization_guaranteed,
|
||||
rustc_nounwind,
|
||||
rustc_object_lifetime_default,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue