7 clippy::if_same_then_else,
10 clippy::equatable_if_let
12 #![warn(clippy::needless_return)]
14 macro_rules! the_answer {
20 fn test_end_of_fn() -> bool {
28 fn test_no_semicolon() -> bool {
32 fn test_if_block() -> bool {
40 fn test_match(x: bool) -> bool {
56 fn test_macro_call() -> i32 {
64 fn test_void_if_fun(b: bool) {
72 fn test_void_match(x: u32) {
79 fn read_line() -> String {
81 let stdin = ::std::io::stdin();
82 return stdin.lock().lines().next().unwrap().unwrap();
85 fn borrows_but_not_last(value: bool) -> String {
88 let stdin = ::std::io::stdin();
89 let _a = stdin.lock().lines().next().unwrap().unwrap();
96 macro_rules! needed_return {
104 fn test_return_in_macro() {
105 // This will return and the macro below won't be executed. Removing the `return` from the macro
106 // will change semantics.
112 fn foo(bar: Result<(), ()>) {
113 bar.unwrap_or_else(|_| {})
124 #[allow(clippy::unnecessary_lazy_evaluations)]
125 fn bar(res: Result<Foo, u8>) -> Foo {
126 res.unwrap_or_else(|_| Foo)
130 async fn async_test_end_of_fn() -> bool {
138 async fn async_test_no_semicolon() -> bool {
142 async fn async_test_if_block() -> bool {
150 async fn async_test_match(x: bool) -> bool {
159 async fn async_test_closure() {
166 async fn async_test_macro_call() -> i32 {
167 return the_answer!();
170 async fn async_test_void_fun() {
174 async fn async_test_void_if_fun(b: bool) {
182 async fn async_test_void_match(x: u32) {
189 async fn async_read_line() -> String {
190 use std::io::BufRead;
191 let stdin = ::std::io::stdin();
192 return stdin.lock().lines().next().unwrap().unwrap();
195 async fn async_borrows_but_not_last(value: bool) -> String {
197 use std::io::BufRead;
198 let stdin = ::std::io::stdin();
199 let _a = stdin.lock().lines().next().unwrap().unwrap();
206 async fn async_test_return_in_macro() {
212 let Some(1) = Some(1) else { return };