Skip to content

It's possible to compile bevy_image with feature = "dds", without also doing the same for bevy_core_pipeline or bevy_gltf, resulting in a compilation error #17290

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

Closed
LikeLakers2 opened this issue Jan 10, 2025 · 1 comment · Fixed by #17887
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples P-Compile-Failure A failure to compile Bevy apps S-Needs-Design This issue requires design work to think about how it would best be accomplished

Comments

@LikeLakers2
Copy link
Contributor

LikeLakers2 commented Jan 10, 2025

When running cargo clippy --tests --all-features --package bevy_image (--tests isn't technically required, but it prevents currently-existing errors with bevy_math from surfacing), bevy_core_pipeline will fail to compile due to not providing a required argument to bevy_image::Image::from_buffer().

Full compilation error log
error[E0061]: this function takes 7 arguments but 6 arguments were supplied
   --> crates\bevy_core_pipeline\src\tonemapping\mod.rs:447:5
    |
447 |     Image::from_buffer(
    |     ^^^^^^^^^^^^^^^^^^
...
450 |         bytes,
    |         ----- argument #1 of type `std::string::String` is missing
    |
note: associated function defined here
   --> crates\bevy_image\src\image.rs:873:12
    |
873 |     pub fn from_buffer(
    |            ^^^^^^^^^^^
help: provide the argument
    |
447 |     Image::from_buffer(/* std::string::String */, bytes, image_type, CompressedImageFormats::NONE, false, image_sampler, RenderAssetUsages::RENDER_WORLD)
    |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0061`.
error: could not compile `bevy_core_pipeline` (lib) due to 1 previous error

After some investigation, I found the issue: if debug assertions are enabled, and bevy_image is compiled with --features dds, then bevy_core_pipeline must also be compiled with --features dds, otherwise a compilation error will occur with bevy_core_pipeline. To explain:

  • Assume debug assertions are on
  • bevy_image::Image::from_buffer() takes a name parameter - but only if --features bevy_image/dds is specified [1]
  • bevy_core_pipeline will, under certain circumstances, call Image::from_buffer(). If --features bevy_core_pipeline/dds is specified, then bevy_core_pipeline will pass in the name parameter. [1] [2] [3]
  • The bevy_core_pipeline/dds feature will enable bevy_image/dds if it isn't already [1]
  • However, because bevy_image/dds does not enable bevy_core_pipeline/dds, it's possible to compile with bevy_image/dds but without bevy_core_pipeline/dds, leading to this compilation error.

I am unsure how to resolve this issue, hence I'm making this bug report.

@LikeLakers2 LikeLakers2 added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 10, 2025
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen S-Needs-Design This issue requires design work to think about how it would best be accomplished P-Compile-Failure A failure to compile Bevy apps D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Triage This issue needs to be labelled labels Jan 10, 2025
@LikeLakers2 LikeLakers2 changed the title If debug_assertions are on and bevy_image is compiled with feature = "dds", then bevy_core_pipeline will fail to compile if it isn't also compiled with feature = "dds" It's possible to compile bevy_image with feature = "dds", without also doing the same for bevy_core_pipeline or bevy_gltf, resulting in a compilation error Jan 10, 2025
@LikeLakers2
Copy link
Contributor Author

I just noticed that bevy_gltf is subject to the same issue, as it will also call Image::from_buffer().

github-merge-queue bot pushed a commit that referenced this issue Feb 17, 2025
…res. (#17887)

Fixes #17290.
<details>
  <summary>Compilation errors before fix</summary>

`cargo clippy --tests --all-features --package bevy_image`:
```rust
error[E0061]: this function takes 7 arguments but 6 arguments were supplied
   --> crates/bevy_core_pipeline/src/tonemapping/mod.rs:451:5
    |
451 |     Image::from_buffer(
    |     ^^^^^^^^^^^^^^^^^^
...
454 |         bytes,
    |         ----- argument #1 of type `std::string::String` is missing
    |
note: associated function defined here
   --> /Users/josiahnelson/Desktop/Programming/Rust/bevy/crates/bevy_image/src/image.rs:930:12
    |
930 |     pub fn from_buffer(
    |            ^^^^^^^^^^^
help: provide the argument
    |
451 |     Image::from_buffer(/* std::string::String */, bytes, image_type, CompressedImageFormats::NONE, false, image_sampler, RenderAssetUsages::RENDER_WORLD)
    |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
`cargo clippy --tests --all-features --package bevy_gltf`:
```rust
error[E0560]: struct `bevy_pbr::StandardMaterial` has no field named `specular_channel`
    --> crates/bevy_gltf/src/loader.rs:1343:13
     |
1343 |             specular_channel: specular.specular_channel,
     |             ^^^^^^^^^^^^^^^^ `bevy_pbr::StandardMaterial` does not have this field
     |
     = note: available fields are: `emissive_exposure_weight`, `diffuse_transmission`, `diffuse_transmission_channel`, `diffuse_transmission_texture`, `flip_normal_map_y` ... and 9 others

error[E0560]: struct `bevy_pbr::StandardMaterial` has no field named `specular_texture`
    --> crates/bevy_gltf/src/loader.rs:1345:13
     |
1345 |             specular_texture: specular.specular_texture,
     |             ^^^^^^^^^^^^^^^^ `bevy_pbr::StandardMaterial` does not have this field
     |
     = note: available fields are: `emissive_exposure_weight`, `diffuse_transmission`, `diffuse_transmission_channel`, `diffuse_transmission_texture`, `flip_normal_map_y` ... and 9 others

error[E0560]: struct `bevy_pbr::StandardMaterial` has no field named `specular_tint_channel`
    --> crates/bevy_gltf/src/loader.rs:1351:13
     |
1351 |             specular_tint_channel: specular.specular_color_channel,
     |             ^^^^^^^^^^^^^^^^^^^^^ `bevy_pbr::StandardMaterial` does not have this field
     |
     = note: available fields are: `emissive_exposure_weight`, `diffuse_transmission`, `diffuse_transmission_channel`, `diffuse_transmission_texture`, `flip_normal_map_y` ... and 9 others

error[E0560]: struct `bevy_pbr::StandardMaterial` has no field named `specular_tint_texture`
    --> crates/bevy_gltf/src/loader.rs:1353:13
     |
1353 |             specular_tint_texture: specular.specular_color_texture,
     |             ^^^^^^^^^^^^^^^^^^^^^ `bevy_pbr::StandardMaterial` does not have this field
     |
     = note: available fields are: `emissive_exposure_weight`, `diffuse_transmission`, `diffuse_transmission_channel`, `diffuse_transmission_texture`, `flip_normal_map_y` ... and 9 others
```
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples P-Compile-Failure A failure to compile Bevy apps S-Needs-Design This issue requires design work to think about how it would best be accomplished
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants