Skip to content

Commit 759c3ad

Browse files
committed
chore: Optimize log display about -Zpublic-dependency
1 parent 2ff7cc3 commit 759c3ad

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ pub fn to_real_manifest(
779779
{
780780
d.public = None;
781781
manifest_ctx.warnings.push(format!(
782-
"Ignoring `public` on dependency {name}. Pass `-Zpublic-dependency` to enable support for it", name = &dep.name_in_toml()
782+
"ignoring `public` on dependency {name}, pass `-Zpublic-dependency` to enable support for it", name = &dep.name_in_toml()
783783
))
784784
}
785785
} else {
@@ -2062,11 +2062,14 @@ fn detailed_dep_to_dependency<P: ResolveToPath + Clone>(
20622062
}
20632063

20642064
if dep.kind() != DepKind::Normal {
2065+
let hint = format!(
2066+
"'public' specifier can only be used on regular dependencies, not {}",
2067+
dep.kind().kind_table(),
2068+
);
20652069
match (with_public_feature, with_z_public) {
2066-
(true, _) => bail!("'public' specifier can only be used on regular dependencies, not {:?} dependencies", dep.kind()),
2067-
(_, true) => bail!("'public' specifier can only be used on regular dependencies, not {:?} dependencies", dep.kind()),
2070+
(true, _) | (_, true) => bail!(hint),
20682071
// If public feature isn't enabled in nightly, we instead warn that.
2069-
(false, false) => manifest_ctx.warnings.push(format!("'public' specifier can only be used on regular dependencies, not {:?} dependencies", dep.kind())),
2072+
(false, false) => manifest_ctx.warnings.push(hint),
20702073
}
20712074
} else {
20722075
dep.set_public(p);

tests/testsuite/pub_priv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn requires_feature() {
141141
.masquerade_as_nightly_cargo(&["public-dependency"])
142142
.with_stderr(
143143
"\
144-
[WARNING] Ignoring `public` on dependency pub_dep. Pass `-Zpublic-dependency` to enable support for it
144+
[WARNING] ignoring `public` on dependency pub_dep, pass `-Zpublic-dependency` to enable support for it
145145
[UPDATING] `[..]` index
146146
[DOWNLOADING] crates ...
147147
[DOWNLOADED] pub_dep v0.1.0 ([..])
@@ -191,7 +191,7 @@ fn pub_dev_dependency() {
191191
error: failed to parse manifest at `[..]`
192192
193193
Caused by:
194-
'public' specifier can only be used on regular dependencies, not Development dependencies
194+
'public' specifier can only be used on regular dependencies, not dev-dependencies
195195
",
196196
)
197197
.run()
@@ -229,7 +229,7 @@ fn pub_dev_dependency_without_feature() {
229229
.masquerade_as_nightly_cargo(&["public-dependency"])
230230
.with_stderr(
231231
"\
232-
[WARNING] 'public' specifier can only be used on regular dependencies, not Development dependencies
232+
[WARNING] 'public' specifier can only be used on regular dependencies, not dev-dependencies
233233
[UPDATING] `[..]` index
234234
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
235235
",

0 commit comments

Comments
 (0)