mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Don't give a hard error on RUSTC_BOOTSTRAP=crate_name
This commit is contained in:
parent
163097cdd9
commit
04fa2f2a3b
@ -589,7 +589,15 @@ impl BuildOutput {
|
||||
// to set RUSTC_BOOTSTRAP.
|
||||
// If this is a nightly build, setting RUSTC_BOOTSTRAP wouldn't affect the
|
||||
// behavior, so still only give a warning.
|
||||
if nightly_features_allowed {
|
||||
// NOTE: cargo only allows nightly features on RUSTC_BOOTSTRAP=1, but we
|
||||
// want setting any value of RUSTC_BOOTSTRAP to downgrade this to a warning
|
||||
// (so that `RUSTC_BOOTSTRAP=pkg_name` will work)
|
||||
let rustc_bootstrap_allows = |name: &str| {
|
||||
std::env::var("RUSTC_BOOTSTRAP").map_or(false, |var| {
|
||||
var.split(',').any(|s| s == name)
|
||||
})
|
||||
};
|
||||
if nightly_features_allowed || rustc_bootstrap_allows(&*pkg_name) {
|
||||
warnings.push(format!("Cannot set `RUSTC_BOOTSTRAP={}` from {}.\n\
|
||||
note: Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project.",
|
||||
val, whence
|
||||
|
@ -129,4 +129,16 @@ fn rustc_bootstrap() {
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_contains("warning: Cannot set `RUSTC_BOOTSTRAP=1` [..]")
|
||||
.run();
|
||||
// RUSTC_BOOTSTRAP set to the name of the crate
|
||||
p.cargo("build")
|
||||
.env("RUSTC_BOOTSTRAP", "foo")
|
||||
.with_stderr_contains("warning: Cannot set `RUSTC_BOOTSTRAP=1` [..]")
|
||||
.run();
|
||||
// RUSTC_BOOTSTRAP set to some random value
|
||||
p.cargo("build")
|
||||
.env("RUSTC_BOOTSTRAP", "bar")
|
||||
.with_stderr_contains("error: Cannot set `RUSTC_BOOTSTRAP=1` [..]")
|
||||
.with_stderr_contains("help: [..] set the environment variable `RUSTC_BOOTSTRAP=foo` [..]")
|
||||
.with_status(101)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user