rust-lang/cargo — pull request #239 by erickt (2014-07-22 04:39:11+00:00)
Title: `cargo test --bench` should compile with --opt-level=3`

I'm sure I did this wrong, but before this patch, `cargo test --bench` wouldn't use `--opt-level=3`, which forced end users to manually build things for benchmarks. This does a bit of a hack to catch when we're benchmarking and build an optimized version of whatever we're benchmarking. I consider it a bit of a stopgap until we get the environment support to work.

As an alternative to this PR, I can think of two alternatives. First, we could add a top level `cargo bench`, which just uses the `bench` profile instead of `test to get the right optimization level. Second, we could add support to run `cargo test --opt-level=3 ...` If we go this route, I suggest we use the unix standard of separating outer and inner arguments with `--`. For example, `cargo test --opt-level=3 -Zlto -- --nocapture`. Everything before `--` is passed to rustc, everything after is passed to the binary.