Skip to content

Commit 030b4b7

Browse files
committed
Auto merge of rust-lang#9950 - xFrednet:0000-improve-exit-docs, r=llogiq
Improve `EXIT` lint docs Super simple change, hopefully fast and fun to review. Have a great start to the weekend! changelog: none
2 parents 6d0b4e3 + 459621d commit 030b4b7

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

Diff for: clippy_lints/src/exit.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,34 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
77

88
declare_clippy_lint! {
99
/// ### What it does
10-
/// `exit()` terminates the program and doesn't provide a
11-
/// stack trace.
10+
/// Detects calls to the `exit()` function which terminates the program.
1211
///
1312
/// ### Why is this bad?
14-
/// Ideally a program is terminated by finishing
13+
/// Exit terminates the program at the location it is called. For unrecoverable
14+
/// errors `panics` should be used to provide a stacktrace and potentualy other
15+
/// information. A normal termination or one with an error code should happen in
1516
/// the main function.
1617
///
1718
/// ### Example
18-
/// ```ignore
19+
/// ```
1920
/// std::process::exit(0)
2021
/// ```
22+
///
23+
/// Use instead:
24+
///
25+
/// ```ignore
26+
/// // To provide a stacktrace and additional information
27+
/// panic!("message");
28+
///
29+
/// // or a main method with a return
30+
/// fn main() -> Result<(), i32> {
31+
/// Ok(())
32+
/// }
33+
/// ```
2134
#[clippy::version = "1.41.0"]
2235
pub EXIT,
2336
restriction,
24-
"`std::process::exit` is called, terminating the program"
37+
"detects `std::process::exit` calls"
2538
}
2639

2740
declare_lint_pass!(Exit => [EXIT]);

0 commit comments

Comments
 (0)