Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,10 +1348,8 @@ impl<'gctx> Workspace<'gctx> {
}

if error_count > 0 {
Err(crate::util::errors::AlreadyPrintedError::new(anyhow!(
"encountered {error_count} errors(s) while running lints"
))
.into())
let plural = if error_count == 1 { "" } else { "s" };
bail!("encountered {error_count} error{plural} while running lints")
} else {
Ok(())
}
Expand Down
43 changes: 43 additions & 0 deletions tests/testsuite/lints/blanket_hint_mostly_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,46 @@ authors = []
"#]])
.run();
}

#[cargo_test(nightly, reason = "-Zhint-mostly-unused is unstable")]
fn deny() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
edition = "2015"

[profile.dev]
hint-mostly-unused = true

[lints.cargo]
blanket_hint_mostly_unused = "deny"
"#,
)
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("check -Zprofile-hint-mostly-unused -v -Zcargo-lints")
.masquerade_as_nightly_cargo(&["profile-hint-mostly-unused", "cargo-lints"])
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] `hint-mostly-unused` is being blanket applied to all dependencies
--> Cargo.toml:7:10
|
7 | [profile.dev]
| ^^^
8 | hint-mostly-unused = true
| -------------------------
|
= [NOTE] `cargo::blanket_hint_mostly_unused` is set to `deny` in `[lints]`
[HELP] scope `hint-mostly-unused` to specific packages with a lot of unused object code
|
7 | [profile.dev.package.<pkg_name>]
| +++++++++++++++++++
[ERROR] encountered 1 error while running lints

"#]])
.run();
}