Why doesn't `cargo clean` have a way to specify feature flags?

⚓ Rust    📅 2026-04-03    👤 surdeus    👁️ 2      

surdeus

As far as I know, most artifacts are specific to the feature-set for which they were built; when building the same project twice with different features, very few, if any, of the original build artifacts can be used for incremental compilation.

So, why doesn't cargo clean provide a way to restrict which artifacts are cleaned by feature-flags, the same way it permits specifying a specific profile to clean?

(Note: I think, ideally, I'd want to be able to specify feature-flag configurations not to clean, i.e. which artifacts to keep.)

I'm surprised I can't find any existing discussion of this here or elsewhere, so possibly I've done a poor job searching, or possibly there's some obvious reason that I haven't thought of.

2 posts - 2 participants

Read full topic

🏷️ Rust_feed