Build failure when proc-macro dependency or build dependency uses mime-guess

22 views
Skip to first unread message

David Tolnay

unread,
Jun 10, 2026, 3:44:20 PM (4 days ago) Jun 10
to rust-embed-devs
The Embed macro generates a function call with a different number of arguments depending on whether the rust-embed-impl crate's "mime-guess" feature is enabled **in the host platform**, whereas the function being called takes a different number of arguments based on whether the rust-embed-utils crate's "mime-guess" feature is enabled **in the target platform**.

In general the host platform and target platform are going to resolve different features.

Correct behavior would be to arrange for the macro to expand based on the presence of "mime-guess" in the target platform only, without regard for what is enabled in the host platform. That means you must not use #[cfg(…)] anywhere in rust-embed-impl. It can still expand to different code by passing tokens to a macro_rules macro defined in rust-embed-utils, with different definitions controlled by #[cfg(…)] located in rust-embed-utils.

Cargo.toml:

    [package]
    name = "repro"
    edition = "2024"
    publish = false

    [dependencies]
    rust-embed = "8.11.0"

    [build-dependencies]
    rust-embed = { version = "8.11.0", features = ["mime-guess"] }

src/lib.rs:

    #[derive(rust_embed::Embed)]
    #[folder = "src/"]
    pub struct Asset;

build.rs:

    fn main() {}

`cargo check --release`:

    error[E0061]: this function takes 3 arguments but 4 arguments were supplied
      --> src/lib.rs:3:10
       |
     3 | #[derive(rust_embed::Embed)]
       |          ^^^^^^^^^^^^^^^^^ unexpected argument #4 of type `&'static str`
       |
    note: associated function defined here
      --> $CARGO_HOME/registry/src/index.crates.io-1949cf8c6b5b557f/rust-embed-utils-8.11.0/src/lib.rs:59:16
       |
    59 |   pub const fn __rust_embed_new(
       |                ^^^^^^^^^^^^^^^^
       = note: this error originates in the derive macro `rust_embed::Embed` (in Nightly builds, run with -Z macro-backtrace for more info)
Reply all
Reply to author
Forward
0 new messages