Skip to content

Commit 9311738

Browse files
committed
test(cargo-rustc): show the current precedence
1 parent d7bffc3 commit 9311738

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/testsuite/rustc.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,3 +795,37 @@ windows
795795
)
796796
.run();
797797
}
798+
799+
#[cargo_test]
800+
fn precedence() {
801+
// Ensure that the precedence of cargo-rustc is only lower than RUSTFLAGS,
802+
// but higher than most flags set by cargo.
803+
//
804+
// See rust-lang/cargo#14346
805+
let p = project()
806+
.file(
807+
"Cargo.toml",
808+
r#"
809+
[package]
810+
name = "foo"
811+
edition = "2021"
812+
813+
[lints.rust]
814+
unexpected_cfgs = "allow"
815+
"#,
816+
)
817+
.file("src/lib.rs", "")
818+
.build();
819+
820+
p.cargo("rustc --release -v -- --cfg cargo_rustc -C strip=symbols")
821+
.env("RUSTFLAGS", "--cfg from_rustflags")
822+
.with_stderr_data(
823+
str![[r#"
824+
[COMPILING] foo v0.0.0 ([ROOT]/foo)
825+
[RUNNING] `rustc [..]--cfg cargo_rustc -C strip=symbols [..]-C strip=debuginfo [..]--cfg from_rustflags`
826+
[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
827+
828+
"#]]
829+
)
830+
.run();
831+
}

0 commit comments

Comments
 (0)