Skip to content

Commit d826a65

Browse files
committed
refactor: Move cargo-lints check into lint passes
1 parent b234294 commit d826a65

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/cargo/core/workspace.rs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,20 +1201,16 @@ impl<'gctx> Workspace<'gctx> {
12011201
pub fn emit_warnings(&self) -> CargoResult<()> {
12021202
let mut first_emitted_error = None;
12031203

1204-
if self.gctx.cli_unstable().cargo_lints {
1205-
if let Err(e) = self.emit_ws_lints() {
1206-
first_emitted_error = Some(e);
1207-
}
1204+
if let Err(e) = self.emit_ws_lints() {
1205+
first_emitted_error = Some(e);
12081206
}
12091207

12101208
for (path, maybe_pkg) in &self.packages.packages {
12111209
if let MaybePackage::Package(pkg) = maybe_pkg {
1212-
if self.gctx.cli_unstable().cargo_lints {
1213-
if let Err(e) = self.emit_pkg_lints(pkg, &path)
1214-
&& first_emitted_error.is_none()
1215-
{
1216-
first_emitted_error = Some(e);
1217-
}
1210+
if let Err(e) = self.emit_pkg_lints(pkg, &path)
1211+
&& first_emitted_error.is_none()
1212+
{
1213+
first_emitted_error = Some(e);
12181214
}
12191215
}
12201216
let warnings = match maybe_pkg {
@@ -1267,16 +1263,18 @@ impl<'gctx> Workspace<'gctx> {
12671263

12681264
let ws_document = self.root_maybe().document();
12691265

1270-
analyze_cargo_lints_table(
1271-
pkg,
1272-
&path,
1273-
&cargo_lints,
1274-
ws_contents,
1275-
ws_document,
1276-
self.root_manifest(),
1277-
self.gctx,
1278-
)?;
1279-
check_im_a_teapot(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?;
1266+
if self.gctx.cli_unstable().cargo_lints {
1267+
analyze_cargo_lints_table(
1268+
pkg,
1269+
&path,
1270+
&cargo_lints,
1271+
ws_contents,
1272+
ws_document,
1273+
self.root_manifest(),
1274+
self.gctx,
1275+
)?;
1276+
check_im_a_teapot(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?;
1277+
}
12801278

12811279
if error_count > 0 {
12821280
Err(crate::util::errors::AlreadyPrintedError::new(anyhow!(
@@ -1312,6 +1310,10 @@ impl<'gctx> Workspace<'gctx> {
13121310
.cloned()
13131311
.unwrap_or(manifest::TomlToolLints::default());
13141312

1313+
if self.gctx.cli_unstable().cargo_lints {
1314+
// Calls to lint functions go in here
1315+
}
1316+
13151317
if error_count > 0 {
13161318
Err(crate::util::errors::AlreadyPrintedError::new(anyhow!(
13171319
"encountered {error_count} errors(s) while running lints"

0 commit comments

Comments
 (0)