Skip to content

Commit

Permalink
Add ignore_warnings flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyalesokhin-starkware committed Jan 14, 2025
1 parent ca1fe0c commit 6fecb3b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions crates/bin/cairo-execute/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
Expand Down Expand Up @@ -136,6 +139,7 @@ fn main() -> anyhow::Result<()> {
&args.path,
args.build.executable.as_deref(),
reporter,
args.build.ignore_warnings,
)?)
}
};
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-lang-compiler/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<'a> DiagnosticsReporter<'a> {
}

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

Expand Down Expand Up @@ -164,7 +164,7 @@ 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 = true;
let modules = db.crate_modules(*crate_id);
let mut processed_file_ids = UnorderedHashSet::<_>::default();
for module_id in modules.iter() {
Expand Down
6 changes: 5 additions & 1 deletion crates/cairo-lang-executable/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ impl std::fmt::Display for CompiledFunction {
pub fn compile_executable(
path: &Path,
executable_path: Option<&str>,
diagnostics_reporter: DiagnosticsReporter<'_>,
mut diagnostics_reporter: DiagnosticsReporter<'_>,
ignore_warnings: bool,
) -> Result<CompiledFunction> {
let mut db = RootDatabase::builder()
.skip_auto_withdraw_gas()
Expand All @@ -64,6 +65,9 @@ pub fn compile_executable(
.build()?;

let main_crate_ids = setup_project(&mut db, Path::new(&path))?;
if ignore_warnings {
diagnostics_reporter = diagnostics_reporter.with_ignore_warnings_crates(&main_crate_ids);
}

compile_executable_in_prepared_db(&db, executable_path, main_crate_ids, diagnostics_reporter)
}
Expand Down

0 comments on commit 6fecb3b

Please sign in to comment.