3 #![warn(clippy::needless_question_mark)]
5 clippy::needless_return,
6 clippy::unnecessary_unwrap,
7 clippy::upper_case_acronyms,
17 magic: Result<usize, bool>,
20 fn simple_option_bad1(to: TO) -> Option<usize> {
21 // return as a statement
25 // formatting will add a semi-colon, which would make
26 // this identical to the test case above
28 fn simple_option_bad2(to: TO) -> Option<usize> {
29 // return as an expression
33 fn simple_option_bad3(to: TO) -> Option<usize> {
34 // block value "return"
38 fn simple_option_bad4(to: Option<TO>) -> Option<usize> {
39 // single line closure
40 to.and_then(|t| t.magic)
43 // formatting this will remove the block brackets, making
44 // this test identical to the one above
46 fn simple_option_bad5(to: Option<TO>) -> Option<usize> {
53 fn simple_result_bad1(tr: TR) -> Result<usize, bool> {
57 // formatting will add a semi-colon, which would make
58 // this identical to the test case above
60 fn simple_result_bad2(tr: TR) -> Result<usize, bool> {
64 fn simple_result_bad3(tr: TR) -> Result<usize, bool> {
68 fn simple_result_bad4(tr: Result<TR, bool>) -> Result<usize, bool> {
69 tr.and_then(|t| t.magic)
72 // formatting this will remove the block brackets, making
73 // this test identical to the one above
75 fn simple_result_bad5(tr: Result<TR, bool>) -> Result<usize, bool> {
81 fn also_bad(tr: Result<TR, bool>) -> Result<usize, bool> {
89 fn false_positive_test<U, T>(x: Result<(), U>) -> Result<(), T>
97 fn deref_ref(s: Option<&String>) -> Option<&str> {
103 // #6921 if a macro wraps an expr in Some( ) and the ? is in the macro use,
104 // the suggestion fails to apply; do not lint
105 macro_rules! some_in_macro {
107 || -> _ { Some($expr) }()
113 let _x = some_in_macro!(x?);
116 // this one is ok because both the ? and the Some are both inside the macro def
117 macro_rules! some_and_qmark_in_macro {
119 || -> Option<_> { Some($expr) }()
125 let _x = some_and_qmark_in_macro!(x?);
128 async fn async_option_bad(to: TO) -> Option<usize> {
133 async fn async_deref_ref(s: Option<&String>) -> Option<&str> {
137 async fn async_result_bad(s: TR) -> Result<usize, bool> {