Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wawel37 committed Oct 1, 2024
1 parent 41c3e9f commit 5b3a124
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
20 changes: 16 additions & 4 deletions crates/cairo-lang-compiler/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ impl<'a> DiagnosticsReporter<'a> {

/// Returns the crate ids for which the diagnostics will be checked.
fn crates_of_interest(&self, db: &dyn FilesGroup) -> Vec<CrateId> {
if self.crate_ids.is_empty() { db.crates() } else { self.crate_ids.clone() }
if self.crate_ids.is_empty() {
db.crates()
} else {
self.crate_ids.clone()
}
}

/// Checks if there are diagnostics.
Expand Down Expand Up @@ -207,7 +211,7 @@ impl<'a> DiagnosticsReporter<'a> {
let ignore_warnings_in_crate = self.ignore_warnings_crate_ids.contains(crate_id);
let modules = db.crate_modules(*crate_id);
for module_id in modules.iter() {
if let Ok(group) = db.module_semantic_diagnostics(*module_id) {
if let Ok(group) = db.module_lowering_diagnostics(*module_id) {
found_diagnostics |=
self.check_diag_group(db.upcast(), group, ignore_warnings_in_crate);
}
Expand Down Expand Up @@ -240,7 +244,11 @@ impl<'a> DiagnosticsReporter<'a> {
/// Checks if there are diagnostics and reports them to the provided callback as strings.
/// Returns `Err` if diagnostics were found.
pub fn ensure(&mut self, db: &dyn LoweringGroup) -> Result<(), DiagnosticsError> {
if self.check(db) { Err(DiagnosticsError) } else { Ok(()) }
if self.check(db) {
Err(DiagnosticsError)
} else {
Ok(())
}
}

/// Checks if there are diagnostics and reports them to the provided callback as strings.
Expand All @@ -250,7 +258,11 @@ impl<'a> DiagnosticsReporter<'a> {
&mut self,
db: &dyn SemanticGroup,
) -> Result<(), DiagnosticsError> {
if self.check_common(db) { Err(DiagnosticsError) } else { Ok(()) }
if self.check_common(db) {
Err(DiagnosticsError)
} else {
Ok(())
}
}

/// Spawns threads to compute the diagnostics queries, making sure later calls for these queries
Expand Down
6 changes: 5 additions & 1 deletion crates/cairo-lang-diagnostics/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,11 @@ impl<TEntry: DiagnosticEntry> Diagnostics<TEntry> {

/// Returns Ok if there are no errors, or DiagnosticAdded if there are.
pub fn check_error_free(&self) -> Maybe<()> {
if self.0.error_count == 0 { Ok(()) } else { Err(DiagnosticAdded) }
if self.0.error_count == 0 {
Ok(())
} else {
Err(DiagnosticAdded)
}
}

/// Checks if there are no entries inside `Diagnostics`
Expand Down

0 comments on commit 5b3a124

Please sign in to comment.