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

Separate check-private-items configuration for different lints #13074

Open
mladedav opened this issue Jul 8, 2024 · 0 comments
Open

Separate check-private-items configuration for different lints #13074

mladedav opened this issue Jul 8, 2024 · 0 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@mladedav
Copy link
Contributor

mladedav commented Jul 8, 2024

Description

Issue

check-private-items currently controls behavior of multiple lints, e.g. missing_panics_doc and missing_safety_doc.

However, I would like to check even private items for safety docs but I don't care as much about panics. Especially since we also lint tests where I often use panics.

Proposal

Add more fine-grained options which can override check-private-items:

  • check-private-items-missing-panics-doc
  • check-private-items-missing-safety-doc
  • ... possibly more

Then clippy.toml such as

check-private-items = false
check-private-items-missing-safety-doc = true

would work like this:

#![warn(missing_panics_doc)]
#![warn(missing_safety_doc)]

// This would be warned against because of `missing_safety_doc`
unsafe fn private_unsafe_fun() {}

// This would be warned against because of `missing_panics_doc`
pub fn public_panicking_fun() { panic!(); }

// This would not be warned against because it's a panic inside a private function
fn private_panicking_fun() { panic!(); }

Version

No response

Additional Labels

@rustbot label +C-enhancement

@rustbot rustbot added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Jul 8, 2024
github-merge-queue bot pushed a commit to bevyengine/bevy that referenced this issue Sep 18, 2024
…l apply to private functions as well (#15161)

Enabled `check-private-items` in `clippy.toml` and then fixed the
resulting errors. Most of these were simply misformatted and of the
remaining:
- ~Added `#[allow(clippy::missing_safety_doc)]` to~ Removed unsafe from
a pair of functions in `bevy_utils/futures` which are only unsafe so
that they can be passed to a function which requires `unsafe fn`
- Removed `unsafe` from `UnsafeWorldCell::observers` as from what I can
tell it is always safe like `components`, `bundles` etc. (this should be
checked)
- Added safety docs to:
- `Bundles::get_storage_unchecked`: Based on the function that writes to
`dynamic_component_storages`
- `Bundles::get_storages_unchecked`: Based on the function that writes
to `dynamic_bundle_storages`
   - `QueryIterationCursor::init_empty`: Duplicated from `init`
- `QueryIterationCursor::peek_last`: Thanks Giooschi (also added
internal unsafe blocks)
   - `tests::drop_ptr`: Moved safety comment out to the doc string
 
This lint would also apply to `missing_errors_doc`, `missing_panics_doc`
and `unnecessary_safety_doc` if we chose to enable any of those at some
point, although there is an open
[issue](rust-lang/rust-clippy#13074) to
separate these options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

No branches or pull requests

2 participants