From 18e01cf31d4d73da76511d55658bcffd4af9e937 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Fri, 30 Aug 2024 09:28:47 -0400 Subject: [PATCH] feat(linter): return `ExitCode` from `driver::main()` --- bevy_lint/src/driver.rs | 13 ++++++++----- src/lint_driver.rs | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bevy_lint/src/driver.rs b/bevy_lint/src/driver.rs index e060cb11..e442a6c2 100644 --- a/bevy_lint/src/driver.rs +++ b/bevy_lint/src/driver.rs @@ -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 = 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, + } } diff --git a/src/lint_driver.rs b/src/lint_driver.rs index 4adec061..f6e5cd25 100644 --- a/src/lint_driver.rs +++ b/src/lint_driver.rs @@ -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() }