Skip to content

Commit

Permalink
Create api for diagnostics ensure with no need for lowering group (#6440
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wawel37 authored Oct 3, 2024
1 parent a74ebfd commit d7813fb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions crates/cairo-lang-compiler/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub struct DiagnosticsReporter<'a> {
crate_ids: Vec<CrateId>,
/// If true, compilation will not fail due to warnings.
allow_warnings: bool,
/// If true, will ignore diagnostics from LoweringGroup during the ensure function.
skip_lowering_diagnostics: bool,
}

impl DiagnosticsReporter<'static> {
Expand All @@ -54,6 +56,7 @@ impl DiagnosticsReporter<'static> {
crate_ids: vec![],
ignore_warnings_crate_ids: vec![],
allow_warnings: false,
skip_lowering_diagnostics: false,
}
}

Expand Down Expand Up @@ -97,6 +100,7 @@ impl<'a> DiagnosticsReporter<'a> {
crate_ids: vec![],
ignore_warnings_crate_ids: vec![],
allow_warnings: false,
skip_lowering_diagnostics: false,
}
}

Expand Down Expand Up @@ -179,6 +183,10 @@ impl<'a> DiagnosticsReporter<'a> {
self.check_diag_group(db.upcast(), group, ignore_warnings_in_crate);
}

if self.skip_lowering_diagnostics {
continue;
}

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 @@ -243,6 +251,11 @@ impl<'a> DiagnosticsReporter<'a> {
});
}
}

pub fn skip_lowering_diagnostics(mut self) -> Self {
self.skip_lowering_diagnostics = true;
self
}
}

impl Default for DiagnosticsReporter<'static> {
Expand Down

0 comments on commit d7813fb

Please sign in to comment.