RS.CLIPPY.EXIT

Detects `std::process::exit` calls

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: exit. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Detects calls to the exit() function which terminates the program.

Why restrict this?

exit() immediately terminates the program with no information other than an exit code. This provides no means to troubleshoot a problem, and may be an unexpected side effect.

Codebases may use this lint to require that all exits are performed either by panicking (which produces a message, a code location, and optionally a backtrace) or by returning from main() (which is a single place to look).

Example

std::process::exit(0)

Use instead:

// To provide a stacktrace and additional information
panic!("message");

// or a main method with a return
fn main() -> Result<(), i32> {
    Ok(())
}