rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

New lint for `as *const _` and `as *mut _` pointer casts

Open Soveu opened this issue 1 year ago • 3 comments

changelog: New lint for as *const _ and as *mut _ pointer casts

EDIT: lets go with the simpler version

Soveu avatar Aug 10 '24 19:08 Soveu

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Jarcho (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

rustbot avatar Aug 10 '24 19:08 rustbot

Or maybe we should just make a lint for as *const/*mut _, like for as _?

Soveu avatar Aug 10 '24 21:08 Soveu

Should this lint be enabled by default like as_underscore? This would break some tests:

FAILURES:
    tests/ui/as_ptr_cast_mut.rs
    tests/ui/borrow_deref_ref.rs
    tests/ui/cast_slice_different_sizes.rs
    tests/ui/manual_c_str_literals.rs
    tests/ui/or_fun_call.rs
    tests/ui/ptr_eq.rs
    tests/ui/ptr_eq_no_std.rs
    tests/ui/ptr_as_ptr.rs
    tests/ui/ref_as_ptr.rs
    tests/ui/transmute_null_to_fn.rs
    tests/ui/transmuting_null.rs
    tests/ui/unnecessary_cast.rs
    tests/ui/zero_ptr_no_std.rs
    tests/ui/zero_ptr.rs
    tests/ui/author/issue_3849.rs

Soveu avatar Aug 24 '24 21:08 Soveu

Ping @Soveu. If you can just remove the fixme's in the test this can be merged.

Jarcho avatar Dec 04 '24 17:12 Jarcho

@Jarcho lets do it

Soveu avatar Dec 06 '24 19:12 Soveu