1 #![warn(clippy::needless_question_mark)]
3 clippy::needless_return,
4 clippy::unnecessary_unwrap,
5 clippy::upper_case_acronyms,
15 magic: Result<usize, bool>,
18 fn simple_option_bad1(to: TO) -> Option<usize> {
19 // return as a statement
23 // formatting will add a semi-colon, which would make
24 // this identical to the test case above
26 fn simple_option_bad2(to: TO) -> Option<usize> {
27 // return as an expression
31 fn simple_option_bad3(to: TO) -> Option<usize> {
32 // block value "return"
36 fn simple_option_bad4(to: Option<TO>) -> Option<usize> {
37 // single line closure
38 to.and_then(|t| t.magic)
41 // formatting this will remove the block brackets, making
42 // this test identical to the one above
44 fn simple_option_bad5(to: Option<TO>) -> Option<usize> {
51 fn simple_result_bad1(tr: TR) -> Result<usize, bool> {
55 // formatting will add a semi-colon, which would make
56 // this identical to the test case above
58 fn simple_result_bad2(tr: TR) -> Result<usize, bool> {
62 fn simple_result_bad3(tr: TR) -> Result<usize, bool> {
66 fn simple_result_bad4(tr: Result<TR, bool>) -> Result<usize, bool> {
67 tr.and_then(|t| t.magic)
70 // formatting this will remove the block brackets, making
71 // this test identical to the one above
73 fn simple_result_bad5(tr: Result<TR, bool>) -> Result<usize, bool> {
79 fn also_bad(tr: Result<TR, bool>) -> Result<usize, bool> {
87 fn false_positive_test<U, T>(x: Result<(), U>) -> Result<(), T>
95 fn deref_ref(s: Option<&String>) -> Option<&str> {
101 // #6921 if a macro wraps an expr in Some( ) and the ? is in the macro use,
102 // the suggestion fails to apply; do not lint
103 macro_rules! some_in_macro {
105 || -> _ { Some($expr) }()
111 let _x = some_in_macro!(x?);
114 // this one is ok because both the ? and the Some are both inside the macro def
115 macro_rules! some_and_qmark_in_macro {
117 || -> Option<_> { Some($expr) }()
123 let _x = some_and_qmark_in_macro!(x?);
126 async fn async_option_bad(to: TO) -> Option<usize> {
131 async fn async_deref_ref(s: Option<&String>) -> Option<&str> {
135 async fn async_result_bad(s: TR) -> Result<usize, bool> {