refactor: Move cargo-lints check into lint passes

This commit is contained in:
Scott Schafer 2025-09-22 14:23:22 -06:00
parent b234294ef9
commit d826a65fef
No known key found for this signature in database

View File

@ -1201,20 +1201,16 @@ impl<'gctx> Workspace<'gctx> {
pub fn emit_warnings(&self) -> CargoResult<()> { pub fn emit_warnings(&self) -> CargoResult<()> {
let mut first_emitted_error = None; let mut first_emitted_error = None;
if self.gctx.cli_unstable().cargo_lints { if let Err(e) = self.emit_ws_lints() {
if let Err(e) = self.emit_ws_lints() { first_emitted_error = Some(e);
first_emitted_error = Some(e);
}
} }
for (path, maybe_pkg) in &self.packages.packages { for (path, maybe_pkg) in &self.packages.packages {
if let MaybePackage::Package(pkg) = maybe_pkg { if let MaybePackage::Package(pkg) = maybe_pkg {
if self.gctx.cli_unstable().cargo_lints { if let Err(e) = self.emit_pkg_lints(pkg, &path)
if let Err(e) = self.emit_pkg_lints(pkg, &path) && first_emitted_error.is_none()
&& first_emitted_error.is_none() {
{ first_emitted_error = Some(e);
first_emitted_error = Some(e);
}
} }
} }
let warnings = match maybe_pkg { let warnings = match maybe_pkg {
@ -1267,16 +1263,18 @@ impl<'gctx> Workspace<'gctx> {
let ws_document = self.root_maybe().document(); let ws_document = self.root_maybe().document();
analyze_cargo_lints_table( if self.gctx.cli_unstable().cargo_lints {
pkg, analyze_cargo_lints_table(
&path, pkg,
&cargo_lints, &path,
ws_contents, &cargo_lints,
ws_document, ws_contents,
self.root_manifest(), ws_document,
self.gctx, self.root_manifest(),
)?; self.gctx,
check_im_a_teapot(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?; )?;
check_im_a_teapot(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?;
}
if error_count > 0 { if error_count > 0 {
Err(crate::util::errors::AlreadyPrintedError::new(anyhow!( Err(crate::util::errors::AlreadyPrintedError::new(anyhow!(
@ -1312,6 +1310,10 @@ impl<'gctx> Workspace<'gctx> {
.cloned() .cloned()
.unwrap_or(manifest::TomlToolLints::default()); .unwrap_or(manifest::TomlToolLints::default());
if self.gctx.cli_unstable().cargo_lints {
// Calls to lint functions go in here
}
if error_count > 0 { if error_count > 0 {
Err(crate::util::errors::AlreadyPrintedError::new(anyhow!( Err(crate::util::errors::AlreadyPrintedError::new(anyhow!(
"encountered {error_count} errors(s) while running lints" "encountered {error_count} errors(s) while running lints"