5

I have a workspace with many crates. I end up having to add the same #![feature(...)] flags to each crate. Is there any way to write them down in just one place, possibly by having cargo pass them as CLI flags to rustc?

(note: this is pretty hard to search for because feature is such a heavily overloaded term in the context of rust compilation).

5
  • 2
    Using include! would be about the only thing I think. Cargo can't do it itself so a workspace doesn't help and I haven't seen an option for it via RUSTFLAGS.
    – kmdreko
    Commented Apr 27 at 17:57
  • 4
    @kmdreko Even with include!() that doesn't work... which surprised me. Commented Apr 27 at 17:59
  • If those crates have only non-library targets, you could use required-features in their Cargo.toml, to disable this targets when given feature is not present. Commented Apr 28 at 11:31
  • 2
    @AleksanderKrauze This is about Cargo features, not Rust features. Commented Apr 30 at 1:17
  • Ah, you are right. I feel silly now. Commented May 1 at 6:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.