mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
refactor: Move cargo-lints check into lint passes
This commit is contained in:
parent
b234294ef9
commit
d826a65fef
@ -1201,22 +1201,18 @@ 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 {
|
||||||
MaybePackage::Package(pkg) => pkg.manifest().warnings().warnings(),
|
MaybePackage::Package(pkg) => pkg.manifest().warnings().warnings(),
|
||||||
MaybePackage::Virtual(vm) => vm.warnings().warnings(),
|
MaybePackage::Virtual(vm) => vm.warnings().warnings(),
|
||||||
@ -1267,6 +1263,7 @@ impl<'gctx> Workspace<'gctx> {
|
|||||||
|
|
||||||
let ws_document = self.root_maybe().document();
|
let ws_document = self.root_maybe().document();
|
||||||
|
|
||||||
|
if self.gctx.cli_unstable().cargo_lints {
|
||||||
analyze_cargo_lints_table(
|
analyze_cargo_lints_table(
|
||||||
pkg,
|
pkg,
|
||||||
&path,
|
&path,
|
||||||
@ -1277,6 +1274,7 @@ impl<'gctx> Workspace<'gctx> {
|
|||||||
self.gctx,
|
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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user