From d826a65fef9e66909064727e95390e25a59f0e23 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Mon, 22 Sep 2025 14:23:22 -0600 Subject: [PATCH] refactor: Move cargo-lints check into lint passes --- src/cargo/core/workspace.rs | 42 +++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 4e71f0e3e..b5a372234 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -1201,20 +1201,16 @@ impl<'gctx> Workspace<'gctx> { pub fn emit_warnings(&self) -> CargoResult<()> { let mut first_emitted_error = None; - if self.gctx.cli_unstable().cargo_lints { - if let Err(e) = self.emit_ws_lints() { - first_emitted_error = Some(e); - } + if let Err(e) = self.emit_ws_lints() { + first_emitted_error = Some(e); } for (path, maybe_pkg) in &self.packages.packages { if let MaybePackage::Package(pkg) = maybe_pkg { - if self.gctx.cli_unstable().cargo_lints { - if let Err(e) = self.emit_pkg_lints(pkg, &path) - && first_emitted_error.is_none() - { - first_emitted_error = Some(e); - } + if let Err(e) = self.emit_pkg_lints(pkg, &path) + && first_emitted_error.is_none() + { + first_emitted_error = Some(e); } } let warnings = match maybe_pkg { @@ -1267,16 +1263,18 @@ impl<'gctx> Workspace<'gctx> { let ws_document = self.root_maybe().document(); - analyze_cargo_lints_table( - pkg, - &path, - &cargo_lints, - ws_contents, - ws_document, - self.root_manifest(), - self.gctx, - )?; - check_im_a_teapot(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?; + if self.gctx.cli_unstable().cargo_lints { + analyze_cargo_lints_table( + pkg, + &path, + &cargo_lints, + ws_contents, + ws_document, + self.root_manifest(), + self.gctx, + )?; + check_im_a_teapot(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?; + } if error_count > 0 { Err(crate::util::errors::AlreadyPrintedError::new(anyhow!( @@ -1312,6 +1310,10 @@ impl<'gctx> Workspace<'gctx> { .cloned() .unwrap_or(manifest::TomlToolLints::default()); + if self.gctx.cli_unstable().cargo_lints { + // Calls to lint functions go in here + } + if error_count > 0 { Err(crate::util::errors::AlreadyPrintedError::new(anyhow!( "encountered {error_count} errors(s) while running lints"