File tree 1 file changed +18
-5
lines changed
1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -7,21 +7,34 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
7
7
8
8
declare_clippy_lint ! {
9
9
/// ### 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.
12
11
///
13
12
/// ### 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
15
16
/// the main function.
16
17
///
17
18
/// ### Example
18
- /// ```ignore
19
+ /// ```
19
20
/// std::process::exit(0)
20
21
/// ```
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
+ /// ```
21
34
#[ clippy:: version = "1.41.0" ]
22
35
pub EXIT ,
23
36
restriction,
24
- "`std::process::exit` is called, terminating the program "
37
+ "detects `std::process::exit` calls "
25
38
}
26
39
27
40
declare_lint_pass ! ( Exit => [ EXIT ] ) ;
You can’t perform that action at this time.
0 commit comments