'How to use .cargo/config.toml file with both stable and nightly rust toolchain?
I have installed both nightly and stable rust toolchains and make some -Z ...
compile flags for nightly, but the stable rust can't recognize it and stops compiling; is there a way or a cargo directive to conditionally switch between nightly/stable rust compiler.
In .cargo/config.toml file
[build]
rustflags = [
"-C...",
"-Z...",
]
For nightly rust read -Z and -C
flags, for stable rust only read -C
or ignore -Z
completely. So that, we can use cargo +stable/+nightly build
without modify config.toml file every time.
Thanks Ruster ~
Solution 1:[1]
I don't think it's possible to specify rustc unstable feature inside config.toml
but you can specify cargo unstable feature. It could be nice to have.
You could create a "nightly" directory:
cd my_rust_project
mkdir my_nightly_project
cd my_nightly_project
rustup override set nightly
Then using merge feature of config file of cargo you create you can override the global config using a my_nightly_project/.cargo/config.toml
file.
Consider using alias instead.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Stargateur |