Skip to content

Commit

Permalink
revise: emit_diagnostics now takes a generic Iter
Browse files Browse the repository at this point in the history
  • Loading branch information
a-frantz committed Jan 23, 2025
1 parent 427001e commit d525a64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
24 changes: 3 additions & 21 deletions src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,29 +160,11 @@ pub async fn check(args: CheckArgs) -> anyhow::Result<()> {
None => result.document().diagnostics(),
};

// If any errors occurred but this document is meant to be suppressed, only
// display the errors.
if suppress {
let errors = diagnostics
.iter()
.filter(|d| d.severity() == Severity::Error)
.cloned()
.collect::<Vec<_>>();
if !errors.is_empty() {
emit_diagnostics(
&errors,
&uri,
&result.document().node().syntax().text().to_string(),
args.common.report_mode,
args.common.no_color,
);
}
continue;
}

if !diagnostics.is_empty() {
emit_diagnostics(
diagnostics,
diagnostics
.iter()
.filter(|d| !suppress || d.severity() == Severity::Error),
&uri,
&result.document().node().syntax().text().to_string(),
args.common.report_mode,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ fn get_display_config(report_mode: Mode, no_color: bool) -> (Config, StandardStr
}

/// Emits the given diagnostics to the terminal.
fn emit_diagnostics(
diagnostics: &[Diagnostic],
fn emit_diagnostics<'a>(
diagnostics: impl IntoIterator<Item = &'a Diagnostic>,
file_name: &str,
source: &str,
report_mode: Mode,
Expand Down

0 comments on commit d525a64

Please sign in to comment.