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

Enable clippy::check-private-items so that missing_safety_doc will apply to private functions as well #15161

Merged
merged 9 commits into from
Sep 18, 2024

Conversation

13ros27
Copy link
Contributor

@13ros27 13ros27 commented Sep 11, 2024

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 to separate these options.

…e unsafe is due to the function signature of `RawWakerVTable::new` as it requires `unsafe fn`
 - `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
…etadata like `components`, `removed_components`, `bundles` etc.
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change D-Unsafe Touches with unsafe code in some way M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 11, 2024
Copy link
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

@13ros27
Copy link
Contributor Author

13ros27 commented Sep 11, 2024

I don't believe this is a breaking change? The only signature change was UnsafeWorldCell::observers which is currently pub(crate)

crates/bevy_utils/src/futures.rs Outdated Show resolved Hide resolved
@janhohenheim janhohenheim removed the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Sep 14, 2024
@alice-i-cecile
Copy link
Member

@13ros27 Sorry for the delay on reviewing this; please ping me once merge conflicts are resolved and I'll merge this in.

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 17, 2024
@13ros27
Copy link
Contributor Author

13ros27 commented Sep 18, 2024

No worries, merge conflicts resolved and I've added safety comments to EntityRefExcept and EntityMutExcept @alice-i-cecile

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 18, 2024
Merged via the queue into bevyengine:main with commit b1273d4 Sep 18, 2024
26 checks passed
@13ros27 13ros27 deleted the check_private_items branch September 18, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change D-Unsafe Touches with unsafe code in some way S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants