Skip to content

Commit 6dcfe51

Browse files
committed
Test that setting -Zhost-config without -Ztarget-applies-to-host fails.
1 parent 62e2fd4 commit 6dcfe51

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/testsuite/build_script.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,48 @@ fn custom_build_env_var_rustc_linker_host_target_env() {
280280
}
281281
}
282282

283+
#[cargo_test]
284+
fn custom_build_invalid_host_config_feature_flag() {
285+
let target = rustc_host();
286+
let p = project()
287+
.file(
288+
".cargo/config",
289+
&format!(
290+
r#"
291+
[target.{}]
292+
linker = "/path/to/linker"
293+
"#,
294+
target
295+
),
296+
)
297+
.file(
298+
"build.rs",
299+
r#"
300+
use std::env;
301+
302+
fn main() {
303+
assert!(env::var("RUSTC_LINKER").unwrap().ends_with("/path/to/linker"));
304+
}
305+
"#,
306+
)
307+
.file("src/lib.rs", "")
308+
.build();
309+
310+
// build.rs should fail due to -Zhost-config being set without -Ztarget-applies-to-host
311+
if cargo_test_support::is_nightly() {
312+
p.cargo("build -Z host-config --target")
313+
.arg(&target)
314+
.masquerade_as_nightly_cargo()
315+
.with_status(101)
316+
.with_stderr_contains(
317+
"\
318+
error: the -Zhost-config flag requires the -Ztarget-applies-to-host flag to be set
319+
",
320+
)
321+
.run();
322+
}
323+
}
324+
283325
#[cargo_test]
284326
fn custom_build_env_var_rustc_linker_host_target_with_bad_host_config() {
285327
let target = rustc_host();

0 commit comments

Comments
 (0)