From be76a553589e41cb1a0e7d29e3a290d150cd5108 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 22 May 2023 10:06:57 -0500 Subject: [PATCH] test(lints): Verify precedence with build.rustflags --- tests/testsuite/lints.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/testsuite/lints.rs b/tests/testsuite/lints.rs index a7775b053..d2fdf6def 100644 --- a/tests/testsuite/lints.rs +++ b/tests/testsuite/lints.rs @@ -516,6 +516,45 @@ pub fn foo(num: i32) -> u32 { .run(); } +#[cargo_test] +fn build_rustflags_has_precedence() { + let foo = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["lints", "profile-rustflags"] + + [package] + name = "foo" + version = "0.0.1" + + [lints.rust] + "unsafe_code" = "deny" + "#, + ) + .file( + ".cargo/config.toml", + r#" + [build] + rustflags = ["-A", "unsafe_code"] +"#, + ) + .file( + "src/lib.rs", + " +pub fn foo(num: i32) -> u32 { + unsafe { std::mem::transmute(num) } +} +", + ) + .build(); + + foo.cargo("check") + .arg("-v") // Show order of rustflags on failure + .masquerade_as_nightly_cargo(&["lints", "profile-rustflags"]) + .run(); +} + #[cargo_test] fn without_priority() { Package::new("reg-dep", "1.0.0").publish();