Skip to content

Commit bc4a3b6

Browse files
committed
fix: Put lints after profile.rustflags
1 parent c2a8d8c commit bc4a3b6

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,10 +1041,6 @@ fn build_base_args(
10411041
cmd.arg("-C").arg(&format!("opt-level={}", opt_level));
10421042
}
10431043

1044-
if !rustflags.is_empty() {
1045-
cmd.args(&rustflags);
1046-
}
1047-
10481044
if *panic != PanicStrategy::Unwind {
10491045
cmd.arg("-C").arg(format!("panic={}", panic));
10501046
}
@@ -1080,6 +1076,9 @@ fn build_base_args(
10801076
}
10811077

10821078
cmd.args(unit.pkg.manifest().rustflags());
1079+
if !rustflags.is_empty() {
1080+
cmd.args(&rustflags);
1081+
}
10831082
if let Some(args) = cx.bcx.extra_args_for(unit) {
10841083
cmd.args(args);
10851084
}

tests/testsuite/lints.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ pub fn foo(num: i32) -> u32 {
435435
}
436436

437437
#[cargo_test]
438-
fn profile_rustflags_doesnt_have_precedence() {
438+
fn profile_rustflags_has_precedence() {
439439
let foo = project()
440440
.file(
441441
"Cargo.toml",
@@ -447,10 +447,10 @@ fn profile_rustflags_doesnt_have_precedence() {
447447
version = "0.0.1"
448448
449449
[lints.rust]
450-
"unsafe_code" = "allow"
450+
"unsafe_code" = "deny"
451451
452452
[profile.dev]
453-
rustflags = ["-D", "unsafe_code"]
453+
rustflags = ["-A", "unsafe_code"]
454454
"#,
455455
)
456456
.file(
@@ -466,7 +466,6 @@ pub fn foo(num: i32) -> u32 {
466466
foo.cargo("check")
467467
.arg("-v")
468468
.masquerade_as_nightly_cargo(&["lints", "profile-rustflags"])
469-
.with_status(0)
470469
.run();
471470
}
472471

0 commit comments

Comments
 (0)