Skip to content

Commit 2661616

Browse files
authored
fix(lints): use plural form correctly (#16324)
### What does this PR try to resolve? Like #16320 but for workspace lints.
2 parents 127597f + a594f32 commit 2661616

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

src/cargo/core/workspace.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,10 +1348,8 @@ impl<'gctx> Workspace<'gctx> {
13481348
}
13491349

13501350
if error_count > 0 {
1351-
Err(crate::util::errors::AlreadyPrintedError::new(anyhow!(
1352-
"encountered {error_count} errors(s) while running lints"
1353-
))
1354-
.into())
1351+
let plural = if error_count == 1 { "" } else { "s" };
1352+
bail!("encountered {error_count} error{plural} while running lints")
13551353
} else {
13561354
Ok(())
13571355
}

tests/testsuite/lints/blanket_hint_mostly_unused.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,46 @@ authors = []
165165
"#]])
166166
.run();
167167
}
168+
169+
#[cargo_test(nightly, reason = "-Zhint-mostly-unused is unstable")]
170+
fn deny() {
171+
let p = project()
172+
.file(
173+
"Cargo.toml",
174+
r#"
175+
[package]
176+
name = "foo"
177+
version = "0.0.1"
178+
edition = "2015"
179+
180+
[profile.dev]
181+
hint-mostly-unused = true
182+
183+
[lints.cargo]
184+
blanket_hint_mostly_unused = "deny"
185+
"#,
186+
)
187+
.file("src/main.rs", "fn main() {}")
188+
.build();
189+
p.cargo("check -Zprofile-hint-mostly-unused -v -Zcargo-lints")
190+
.masquerade_as_nightly_cargo(&["profile-hint-mostly-unused", "cargo-lints"])
191+
.with_status(101)
192+
.with_stderr_data(str![[r#"
193+
[ERROR] `hint-mostly-unused` is being blanket applied to all dependencies
194+
--> Cargo.toml:7:10
195+
|
196+
7 | [profile.dev]
197+
| ^^^
198+
8 | hint-mostly-unused = true
199+
| -------------------------
200+
|
201+
= [NOTE] `cargo::blanket_hint_mostly_unused` is set to `deny` in `[lints]`
202+
[HELP] scope `hint-mostly-unused` to specific packages with a lot of unused object code
203+
|
204+
7 | [profile.dev.package.<pkg_name>]
205+
| +++++++++++++++++++
206+
[ERROR] encountered 1 error while running lints
207+
208+
"#]])
209+
.run();
210+
}

0 commit comments

Comments
 (0)