Skip to content

Commit 19fb2c0

Browse files
committed
feat: Don't stop at first error when emitting lints and warnings
1 parent a6c58d4 commit 19fb2c0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/cargo/core/workspace.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,10 +1205,15 @@ impl<'gctx> Workspace<'gctx> {
12051205
}
12061206

12071207
pub fn emit_warnings(&self) -> CargoResult<()> {
1208+
let mut first_emitted_error = None;
12081209
for (path, maybe_pkg) in &self.packages.packages {
12091210
if let MaybePackage::Package(pkg) = maybe_pkg {
12101211
if self.gctx.cli_unstable().cargo_lints {
1211-
self.emit_lints(pkg, &path)?
1212+
if let Err(e) = self.emit_lints(pkg, &path)
1213+
&& first_emitted_error.is_none()
1214+
{
1215+
first_emitted_error = Some(e);
1216+
}
12121217
}
12131218
}
12141219
let warnings = match maybe_pkg {
@@ -1220,7 +1225,9 @@ impl<'gctx> Workspace<'gctx> {
12201225
let err = anyhow::format_err!("{}", warning.message);
12211226
let cx =
12221227
anyhow::format_err!("failed to parse manifest at `{}`", path.display());
1223-
return Err(err.context(cx));
1228+
if first_emitted_error.is_none() {
1229+
first_emitted_error = Some(err.context(cx));
1230+
}
12241231
} else {
12251232
let msg = if self.root_manifest.is_none() {
12261233
warning.message.to_string()
@@ -1233,7 +1240,12 @@ impl<'gctx> Workspace<'gctx> {
12331240
}
12341241
}
12351242
}
1236-
Ok(())
1243+
1244+
if let Some(error) = first_emitted_error {
1245+
Err(error)
1246+
} else {
1247+
Ok(())
1248+
}
12371249
}
12381250

12391251
pub fn emit_lints(&self, pkg: &Package, path: &Path) -> CargoResult<()> {

0 commit comments

Comments
 (0)