blob: e75eb1b6eadd85ca225d830e3cb8ffe96bf584fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#![warn(clippy::panic_in_result_fn)]
#![allow(clippy::unnecessary_wraps)]
struct A;
impl A {
fn result_with_panic() -> Result<bool, String> // should emit lint
{
panic!("error");
}
fn result_with_unimplemented() -> Result<bool, String> // should emit lint
{
unimplemented!();
}
fn result_with_unreachable() -> Result<bool, String> // should emit lint
{
unreachable!();
}
fn result_with_todo() -> Result<bool, String> // should emit lint
{
todo!("Finish this");
}
fn other_with_panic() // should not emit lint
{
panic!("");
}
fn other_with_unreachable() // should not emit lint
{
unreachable!();
}
fn other_with_unimplemented() // should not emit lint
{
unimplemented!();
}
fn other_with_todo() // should not emit lint
{
todo!("finish this")
}
fn result_without_banned_functions() -> Result<bool, String> // should not emit lint
{
Ok(true)
}
}
fn function_result_with_panic() -> Result<bool, String> // should emit lint
{
panic!("error");
}
fn todo() {
println!("something");
}
fn function_result_with_custom_todo() -> Result<bool, String> // should not emit lint
{
todo();
Ok(true)
}
fn main() -> Result<(), String> {
todo!("finish main method");
Ok(())
}
|