Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ignore_warnings flag. #7079

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading