Skip to content

Commit

Permalink
fix: Put lints after profile.rustflags
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed May 19, 2023
1 parent e29eaef commit 9759d86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/testsuite/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand Down

0 comments on commit 9759d86

Please sign in to comment.