Skip to content

Commit e44bde5

Browse files
committed
Respect capped lints for dependencies
1 parent 78b4afb commit e44bde5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,13 @@ fn build_base_args(
11481148
unit.pkg.package_id().version()
11491149
))
11501150
};
1151+
let unit_capped_warn = |msg: &str| {
1152+
if unit.show_warnings(bcx.gctx) {
1153+
warn(msg)
1154+
} else {
1155+
Ok(())
1156+
}
1157+
};
11511158

11521159
cmd.arg("--crate-name").arg(&unit.target.crate_name());
11531160

@@ -1339,7 +1346,7 @@ fn build_base_args(
13391346
None => None,
13401347
Some(toml::Value::Boolean(b)) => Some(b),
13411348
Some(v) => {
1342-
warn(&format!(
1349+
unit_capped_warn(&format!(
13431350
"ignoring unsupported value type ({}) for 'hints.mostly-unused', which expects a boolean",
13441351
v.type_str()
13451352
))?;
@@ -1354,11 +1361,12 @@ fn build_base_args(
13541361
cmd.arg("-Zhint-mostly-unused");
13551362
} else {
13561363
if profile_hint_mostly_unused.is_some() {
1364+
// Profiles come from the top-level unit, so we don't use `unit_capped_warn` here.
13571365
warn(
13581366
"ignoring 'hint-mostly-unused' profile option, pass `-Zprofile-hint-mostly-unused` to enable it",
13591367
)?;
13601368
} else if pkg_hint_mostly_unused.is_some() {
1361-
warn(
1369+
unit_capped_warn(
13621370
"ignoring 'hints.mostly-unused', pass `-Zprofile-hint-mostly-unused` to enable it",
13631371
)?;
13641372
}

tests/testsuite/hints.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ fn hint_unknown_type_warn() {
124124
[DOWNLOADING] crates ...
125125
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
126126
[WARNING] foo@0.0.1: ignoring unsupported value type (string) for 'hints.mostly-unused', which expects a boolean
127-
[WARNING] bar@1.0.0: ignoring unsupported value type (integer) for 'hints.mostly-unused', which expects a boolean
128127
[CHECKING] bar v1.0.0
129128
[RUNNING] `rustc --crate-name bar [..]`
130129
[CHECKING] foo v0.0.1 ([ROOT]/foo)
@@ -178,7 +177,6 @@ fn hints_mostly_unused_warn_without_gate() {
178177
[DOWNLOADING] crates ...
179178
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
180179
[WARNING] foo@0.0.1: ignoring 'hints.mostly-unused', pass `-Zprofile-hint-mostly-unused` to enable it
181-
[WARNING] bar@1.0.0: ignoring 'hints.mostly-unused', pass `-Zprofile-hint-mostly-unused` to enable it
182180
[CHECKING] bar v1.0.0
183181
[RUNNING] `rustc --crate-name bar [..]`
184182
[CHECKING] foo v0.0.1 ([ROOT]/foo)

0 commit comments

Comments
 (0)