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

@LikeLakers2

Description

@LikeLakers2

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesP-Compile-FailureA failure to compile Bevy appsS-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions