If I want to disable a particular code block/function defn/etc from source, I can do something like this:
#[cfg(feature = "")]
{
...
}
Is there a way of disabling code from rustc itself? For example, something like rustc --disable foo.rs:32 (to disable the item starting at foo.rs line 32).
For context: I have a very large number of benchmarks in my crate, and as a result, doing a release build that includes tests (e.g., cargo bench) takes forever - about 4 minutes on my MacBook. I'm toying around with adding a flag to cargo test and cargo bench which only compiles the tests that are passed as an argument, and in order to do that, I need a way to not selectively disable certain pieces of code.
Sorry, I was just using #[cfg(feature = "foo")] as an example. I want to be able to run this on code that I didn't write and haven't edited, so it's not an option for me.
Fork, and do whatever changes you want in a project. Then put a reference to your git repository in Cargo.toml (perhaps behind a feature). You can later track updates by pulling from original repository if needed.