Skip to content
Unverified Commit 8a453134 authored by david-perez's avatar david-perez Committed by GitHub
Browse files

Rely on `.cargo/config.toml` instead of `RUSTFLAGS` in tests' generated crates (#3192)

This is PR is similar to #1422. When generating a crate (either via
`Project.compileAndTest` or `{client,server}IntegrationTest`), we're
setting `RUSTFLAGS`. When developing, a common thing to do after
generating a crate is to open its contents in an editor, make
modifications, and run `cargo` again.

- the editor will kick off `rust-analyzer`, which will build the code
  again without the `RUSTFLAGS`; and
- the developer is unlikely to use the same `RUSTFLAGS` when running
  manual `cargo` commands; in fact, they'll most likely use none.

Indeed, using `CARGO_LOG=cargo::core::compiler::fingerprint=trace` on
the generated crate reveals that `cargo` is claiming it has to rebuild
the entire dependency closure because a different set of flags was used.
This causes unnecessary crate rebuilds during which the developer has to
wait.

Instead of relying on `RUSTFLAGS` in the command line invocation, we can
leverage `.cargo/config.toml`'s `[build.rustflags]` to persist the
settings in a file, like we did in #1422. That way, any plain `cargo`
command that runs on the same project will reuse the previous
compilation artifacts.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent b3ca5bfd
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment