Skip to content

Commit be76a55

Browse files
committed
test(lints): Verify precedence with build.rustflags
1 parent 3cba0c1 commit be76a55

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/testsuite/lints.rs

+39
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,45 @@ pub fn foo(num: i32) -> u32 {
516516
.run();
517517
}
518518

519+
#[cargo_test]
520+
fn build_rustflags_has_precedence() {
521+
let foo = project()
522+
.file(
523+
"Cargo.toml",
524+
r#"
525+
cargo-features = ["lints", "profile-rustflags"]
526+
527+
[package]
528+
name = "foo"
529+
version = "0.0.1"
530+
531+
[lints.rust]
532+
"unsafe_code" = "deny"
533+
"#,
534+
)
535+
.file(
536+
".cargo/config.toml",
537+
r#"
538+
[build]
539+
rustflags = ["-A", "unsafe_code"]
540+
"#,
541+
)
542+
.file(
543+
"src/lib.rs",
544+
"
545+
pub fn foo(num: i32) -> u32 {
546+
unsafe { std::mem::transmute(num) }
547+
}
548+
",
549+
)
550+
.build();
551+
552+
foo.cargo("check")
553+
.arg("-v") // Show order of rustflags on failure
554+
.masquerade_as_nightly_cargo(&["lints", "profile-rustflags"])
555+
.run();
556+
}
557+
519558
#[cargo_test]
520559
fn without_priority() {
521560
Package::new("reg-dep", "1.0.0").publish();

0 commit comments

Comments
 (0)