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

clippy::debug-assert-with-mut-call in Entities::verify_flushed() #6474

Closed
targrub opened this issue Nov 5, 2022 · 3 comments
Closed

clippy::debug-assert-with-mut-call in Entities::verify_flushed() #6474

targrub opened this issue Nov 5, 2022 · 3 comments
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change

Comments

@targrub
Copy link
Contributor

targrub commented Nov 5, 2022

Bevy version

c019a60

What you did

Ran cargo clippy --workspace --all-targets --all-features -- -Aclippy::type_complexity -Wclippy::nursery -Aclippy::use_self -Aclippy::missing_const_for_fn -Aclippy::redundant_pub_crate -Aclippy::cognitive_complexity -Aclippy::branches_sharing_code -Aclippy::option_if_let_else -Aclippy::useless_let_if_seq -Aclippy::equatable_if_let -Aclippy::iter_with_drain -Aclippy::iter_on_single_items -Aclippy::iter_on_empty_collections -Aclippy::type_repetition_in_bounds -Aclippy::trait_duplication_in_bounds -Aclippy::fallible_impl_from -Aclippy::future_not_send -Aclippy::imprecise_flops -Aclippy::suboptimal_flops -Wclippy::doc_markdown -Wclippy::redundant_else -Wclippy::match_same_arms -Wclippy::semicolon_if_nothing_returned -Wclippy::explicit_iter_loop -Wclippy::map_flatten -Dwarnings

What went wrong

error: do not call a function with mutable arguments inside of `debug_assert!`
   --> crates\bevy_ecs\src\entity\mod.rs:388:14
    |
388 |             !self.needs_flush(),
    |              ^^^^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::debug-assert-with-mut-call` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#debug_assert_with_mut_call

was reported on this code:

    /// Check that we do not have pending work requiring `flush()` to be called.
    fn verify_flushed(&mut self) {
        debug_assert!(
            !self.needs_flush(),
            "flush() needs to be called before this operation is legal"
        );
    }
@targrub targrub added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 5, 2022
@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 and removed C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 5, 2022
@alice-i-cecile
Copy link
Member

Not worth fixing, see discussion in the linked PRs :)

@targrub
Copy link
Contributor Author

targrub commented Nov 5, 2022

From the lint description https://rust-lang.github.io/rust-clippy/master/index.html#debug_assert_with_mut_call (my emphasis):

Why is this bad?

In release builds debug_assert! macros are optimized out by the compiler. Therefore mutating something in a debug_assert! macro results in different behavior between a release and debug build.

@mockersf
Copy link
Member

mockersf commented Nov 5, 2022

on atomics, there is no get but a get_mut to have a mutable reference. not necessarily to mutate it but to guarantee there isn't another at the same time.
load would be the equivalent of this get but doesn't really have the same semantics

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
Projects
None yet
3 participants