From 9759d860184937dd29ef3e6697c2fc52ee77f636 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 19 May 2023 15:11:42 -0500 Subject: [PATCH] fix: Put lints after profile.rustflags --- src/cargo/core/compiler/mod.rs | 7 +++---- tests/testsuite/lints.rs | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index dc7a4ba336ac..b1e7f79b3f21 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -1041,10 +1041,6 @@ fn build_base_args( cmd.arg("-C").arg(&format!("opt-level={}", opt_level)); } - if !rustflags.is_empty() { - cmd.args(&rustflags); - } - if *panic != PanicStrategy::Unwind { cmd.arg("-C").arg(format!("panic={}", panic)); } @@ -1080,6 +1076,9 @@ fn build_base_args( } cmd.args(unit.pkg.manifest().rustflags()); + if !rustflags.is_empty() { + cmd.args(&rustflags); + } if let Some(args) = cx.bcx.extra_args_for(unit) { cmd.args(args); } diff --git a/tests/testsuite/lints.rs b/tests/testsuite/lints.rs index a339f52d76c4..e957b0af29a7 100644 --- a/tests/testsuite/lints.rs +++ b/tests/testsuite/lints.rs @@ -440,7 +440,7 @@ pub fn foo(num: i32) -> u32 { } #[cargo_test] -fn profile_rustflags_doesnt_have_precedence() { +fn profile_rustflags_has_precedence() { let foo = project() .file( "Cargo.toml", @@ -452,10 +452,10 @@ fn profile_rustflags_doesnt_have_precedence() { version = "0.0.1" [lints.rust] - "unsafe_code" = "allow" + "unsafe_code" = "deny" [profile.dev] - rustflags = ["-D", "unsafe_code"] + rustflags = ["-A", "unsafe_code"] "#, ) .file(