Skip to content

Commit a5926fb

Browse files
committed
Include package ID in warnings to identify affected crate
1 parent 866095b commit a5926fb

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,14 @@ fn build_base_args(
11411141
let hints = unit.pkg.hints().cloned().unwrap_or_default();
11421142
let test = unit.mode.is_any_test();
11431143

1144+
let warn = |msg: &str| {
1145+
bcx.gctx.shell().warn(format!(
1146+
"{}@{}: {msg}",
1147+
unit.pkg.package_id().name(),
1148+
unit.pkg.package_id().version()
1149+
))
1150+
};
1151+
11441152
cmd.arg("--crate-name").arg(&unit.target.crate_name());
11451153

11461154
let edition = unit.target.edition();
@@ -1331,7 +1339,7 @@ fn build_base_args(
13311339
None => None,
13321340
Some(toml::Value::Boolean(b)) => Some(b),
13331341
Some(v) => {
1334-
bcx.gctx.shell().warn(format!(
1342+
warn(&format!(
13351343
"ignoring unsupported value type ({}) for 'hints.mostly-unused', which expects a boolean",
13361344
v.type_str()
13371345
))?;
@@ -1346,13 +1354,13 @@ fn build_base_args(
13461354
cmd.arg("-Zhint-mostly-unused");
13471355
} else {
13481356
if profile_hint_mostly_unused.is_some() {
1349-
bcx.gctx
1350-
.shell()
1351-
.warn("ignoring 'hint-mostly-unused' profile option, pass `-Zprofile-hint-mostly-unused` to enable it")?;
1357+
warn(
1358+
"ignoring 'hint-mostly-unused' profile option, pass `-Zprofile-hint-mostly-unused` to enable it",
1359+
)?;
13521360
} else if pkg_hint_mostly_unused.is_some() {
1353-
bcx.gctx
1354-
.shell()
1355-
.warn("ignoring 'hints.mostly-unused', pass `-Zprofile-hint-mostly-unused` to enable it")?;
1361+
warn(
1362+
"ignoring 'hints.mostly-unused', pass `-Zprofile-hint-mostly-unused` to enable it",
1363+
)?;
13561364
}
13571365
}
13581366
}

tests/testsuite/hints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn hint_unknown_type_warn() {
9696
[LOCKING] 1 package to latest compatible version
9797
[DOWNLOADING] crates ...
9898
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
99-
[WARNING] ignoring unsupported value type (integer) for 'hints.mostly-unused', which expects a boolean
99+
[WARNING] bar@1.0.0: ignoring unsupported value type (integer) for 'hints.mostly-unused', which expects a boolean
100100
[CHECKING] bar v1.0.0
101101
[RUNNING] `rustc --crate-name bar [..]`
102102
[CHECKING] foo v0.0.1 ([ROOT]/foo)
@@ -146,7 +146,7 @@ fn hints_mostly_unused_warn_without_gate() {
146146
[LOCKING] 1 package to latest compatible version
147147
[DOWNLOADING] crates ...
148148
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
149-
[WARNING] ignoring 'hints.mostly-unused', pass `-Zprofile-hint-mostly-unused` to enable it
149+
[WARNING] bar@1.0.0: ignoring 'hints.mostly-unused', pass `-Zprofile-hint-mostly-unused` to enable it
150150
[CHECKING] bar v1.0.0
151151
[RUNNING] `rustc --crate-name bar [..]`
152152
[CHECKING] foo v0.0.1 ([ROOT]/foo)

tests/testsuite/profiles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ fn profile_hint_mostly_unused_warn_without_gate() {
904904
[LOCKING] 1 package to latest compatible version
905905
[DOWNLOADING] crates ...
906906
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
907-
[WARNING] ignoring 'hint-mostly-unused' profile option, pass `-Zprofile-hint-mostly-unused` to enable it
907+
[WARNING] bar@1.0.0: ignoring 'hint-mostly-unused' profile option, pass `-Zprofile-hint-mostly-unused` to enable it
908908
[CHECKING] bar v1.0.0
909909
[RUNNING] `rustc --crate-name bar [..]`
910910
[CHECKING] foo v0.0.1 ([ROOT]/foo)

0 commit comments

Comments
 (0)