Skip to content

Commit

Permalink
Return ExitCode from driver::main() (#23)
Browse files Browse the repository at this point in the history
Closes #17!
  • Loading branch information
BD103 authored Aug 30, 2024
1 parent 330a523 commit 46d0555
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 8 additions & 5 deletions bevy_lint/src/driver.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
//! Contains code related to writing `bevy_lint_driver`.
use crate::callback::BevyLintCallback;
use std::process::ExitCode;

/// This is the main entrypoint into the driver, exported so that `bevy_cli` may call it.
#[allow(clippy::result_unit_err)]
pub fn main() -> Result<(), ()> {
pub fn main() -> ExitCode {
let args: Vec<String> = dbg!(std::env::args().skip(1).collect());

// Call the compiler with our custom callback.
rustc_driver::RunCompiler::new(&args, &mut BevyLintCallback)
.run()
.map_err(|_| ())
let result = rustc_driver::RunCompiler::new(&args, &mut BevyLintCallback).run();

match result {
Ok(_) => ExitCode::SUCCESS,
Err(_) => ExitCode::FAILURE,
}
}
4 changes: 3 additions & 1 deletion src/lint_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// opt-in to `rustc_private`.
#![feature(rustc_private)]

fn main() -> Result<(), ()> {
use std::process::ExitCode;

fn main() -> ExitCode {
bevy_lint::driver::main()
}

0 comments on commit 46d0555

Please sign in to comment.