Skip to content

Conversation

villor
Copy link
Contributor

@villor villor commented Mar 22, 2025

Objective

  • bevy_gizmos has lint errors on some feature combinations.
  • The use-declarations are a bit of a mess

Solution

  • Fixed the lint errors by ensuring correct gated imports for the different features
  • Hardened gating for some internal structs/fields only used with bevy_pbr/bevy_sprite features.
  • Re-organized use-declarations in lib.rs into more reasonable blocks (still a bit of a mess, but now less of a mess)

Testing

  • Local
# Ran lints for the following feature combos - all passing
$ cargo clippy -p bevy_gizmos --no-deps -- --D warnings
$ cargo clippy -p bevy_gizmos --no-default-features --no-deps -- --D warnings
$ cargo clippy -p bevy_gizmos --features=webgl --no-deps -- --D warnings
$ cargo clippy -p bevy_gizmos --features=webgpu --no-deps -- --D warnings
$ cargo clippy -p bevy_gizmos --features=bevy_render,webgl --no-deps -- --D warnings
$ cargo clippy -p bevy_gizmos --features=bevy_render,webgpu --no-deps -- --D warnings
$ cargo clippy -p bevy_gizmos --features=bevy_render,bevy_pbr --no-deps -- --D warnings
$ cargo clippy -p bevy_gizmos --features=bevy_render,bevy_pbr,bevy_sprite --no-deps -- --D warnings
$ cargo clippy -p bevy_gizmos --features=bevy_render,bevy_sprite --no-deps -- --D warnings
$ cargo clippy -p bevy_gizmos --all-features --no-deps -- --D warnings

# Ran (doc) tests - all passing
$ cargo test -p bevy_gizmos

# Ran the gizmo examples - all of them work (MacOS)
$ cargo run --example=2d_gizmos
$ cargo run --example=3d_gizmos
$ cargo run --example=axes
$ cargo run --example=light_gizmos
  • CI

@hukasu
Copy link
Contributor

hukasu commented Mar 22, 2025

cargo test -p bevy_gizmos does not run the doc test IIRC, you need cargo test -p bevy_gizmos --doc

@villor
Copy link
Contributor Author

villor commented Mar 22, 2025

cargo test -p bevy_gizmos does not run the doc test IIRC, you need cargo test -p bevy_gizmos --doc

It does actually! If you don't specify anything it will "Execute all unit and integration tests and build examples of a local package"

So unless you specify targets with something like --all-targets or --tests, it will run the doc tests too:

$ cargo test -p bevy_gizmos              
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.29s
     Running unittests src/lib.rs (target/debug/deps/bevy_gizmos-ae878401ca04cf3e)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests bevy_gizmos

running 46 tests
test crates/bevy_gizmos/src/arrows.rs - arrows::GizmoBuffer<Config,Clear>::arrow (line 114) ... ok
test crates/bevy_gizmos/src/arcs.rs - arcs::GizmoBuffer<Config,Clear>::short_arc_2d_between (line 337) ... ok
# ...
test crates/bevy_gizmos/src/lib.rs - (line 10) ... ok
test crates/bevy_gizmos/src/rounded_box.rs - rounded_box::GizmoBuffer<Config,Clear>::rounded_rect_2d (line 307) ... ok

test result: ok. 46 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

@hukasu
Copy link
Contributor

hukasu commented Mar 22, 2025

Ah, cool

@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Mar 23, 2025
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior C-Code-Quality A section of code that is hard to understand or change A-Gizmos Visual editor and debug gizmos labels Mar 23, 2025
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good cleanup and fixes, but I find using _ variable names confusing for cfg-gated fields and values. I'd prefer feature-gated expects for dead code.

@alice-i-cecile alice-i-cecile added the S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged label Mar 23, 2025
@alice-i-cecile alice-i-cecile removed this from the 0.16 milestone Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Gizmos Visual editor and debug gizmos C-Bug An unexpected or incorrect behavior C-Code-Quality A section of code that is hard to understand or change S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants