diff --git a/crates/bin/cairo-execute/src/main.rs b/crates/bin/cairo-execute/src/main.rs index c3e6b34cef0..2b3e4b37539 100644 --- a/crates/bin/cairo-execute/src/main.rs +++ b/crates/bin/cairo-execute/src/main.rs @@ -48,6 +48,9 @@ struct BuildArgs { /// Allows the compilation to succeed with warnings. #[arg(long, conflicts_with = "prebuilt")] allow_warnings: bool, + /// Allow warnings and don't print them (implies allow_warnings). + #[arg(long, conflicts_with = "prebuilt")] + ignore_warnings: bool, /// Path to the executable function. #[arg(long, conflicts_with = "prebuilt")] executable: Option, @@ -132,6 +135,10 @@ fn main() -> anyhow::Result<()> { if args.build.allow_warnings { reporter = reporter.allow_warnings(); } + if args.build.ignore_warnings { + reporter = reporter.ignore_all_warnings(); + } + Executable::new(compile_executable( &args.path, args.build.executable.as_deref(), diff --git a/crates/cairo-lang-compiler/src/diagnostics.rs b/crates/cairo-lang-compiler/src/diagnostics.rs index b66d1c04866..45ed163e87f 100644 --- a/crates/cairo-lang-compiler/src/diagnostics.rs +++ b/crates/cairo-lang-compiler/src/diagnostics.rs @@ -38,7 +38,9 @@ impl DiagnosticCallback for Option> { /// Collects compilation diagnostics and presents them in preconfigured way. pub struct DiagnosticsReporter<'a> { callback: Option>, - /// Ignore warnings in these crates. This should be subset of `crate_ids`. + // Ignore all warnings, the `ignore_warnings_crate_ids` field is irrelevant in this case. + ignore_all_warnings: bool, + /// Ignore warnings in specific crates. This should be subset of `crate_ids`. /// Adding ids that are not in `crate_ids` have no effect. ignore_warnings_crate_ids: Vec, /// Check diagnostics for these crates only. @@ -56,6 +58,7 @@ impl DiagnosticsReporter<'static> { Self { callback: None, crate_ids: vec![], + ignore_all_warnings: false, ignore_warnings_crate_ids: vec![], allow_warnings: false, skip_lowering_diagnostics: false, @@ -100,6 +103,7 @@ impl<'a> DiagnosticsReporter<'a> { Self { callback: Some(Box::new(callback)), crate_ids: vec![], + ignore_all_warnings: false, ignore_warnings_crate_ids: vec![], allow_warnings: false, skip_lowering_diagnostics: false, @@ -127,6 +131,12 @@ impl<'a> DiagnosticsReporter<'a> { self } + /// Ignores warnings in all cargo crates. + pub fn ignore_all_warnings(mut self) -> Self { + self.ignore_all_warnings = true; + self + } + /// Returns the crate ids for which the diagnostics will be checked. fn crates_of_interest(&self, db: &dyn LoweringGroup) -> Vec { if self.crate_ids.is_empty() { db.crates() } else { self.crate_ids.clone() } @@ -164,7 +174,8 @@ impl<'a> DiagnosticsReporter<'a> { found_diagnostics = true; } - let ignore_warnings_in_crate = self.ignore_warnings_crate_ids.contains(crate_id); + let ignore_warnings_in_crate = + self.ignore_all_warnings || self.ignore_warnings_crate_ids.contains(crate_id); let modules = db.crate_modules(*crate_id); let mut processed_file_ids = UnorderedHashSet::<_>::default(); for module_id in modules.iter() {