Skip to content

Commit 47a6c04

Browse files
authored
fix(lints): show lint error number (#16320)
### What does this PR try to resolve? This wasn't shown because `AlreadyPrintedError` was skipped. Also corrected the plural form.
2 parents 956137f + b3d07f7 commit 47a6c04

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/cargo/core/workspace.rs

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

13011301
if error_count > 0 {
1302-
Err(crate::util::errors::AlreadyPrintedError::new(anyhow!(
1303-
"encountered {error_count} errors(s) while running lints"
1304-
))
1305-
.into())
1302+
let plural = if error_count == 1 { "" } else { "s" };
1303+
bail!("encountered {error_count} error{plural} while running lints")
13061304
} else {
13071305
Ok(())
13081306
}

tests/testsuite/lints/error/stderr.term.svg

Lines changed: 5 additions & 3 deletions
Loading

tests/testsuite/lints/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ test_dummy_unstable = { level = "forbid", priority = -1 }
8383
| ^^^^^^^^^^^^^^^^^^
8484
|
8585
= [NOTE] `cargo::im_a_teapot` is set to `forbid` in `[lints]`
86+
[ERROR] encountered 1 error while running lints
8687
8788
"#]])
8889
.run();
@@ -125,6 +126,7 @@ workspace = true
125126
| ^^^^^^^^^^^^^^^^^^
126127
|
127128
= [NOTE] `cargo::im_a_teapot` is set to `forbid` in `[lints]`
129+
[ERROR] encountered 1 error while running lints
128130
129131
"#]])
130132
.run();

0 commit comments

Comments
 (0)