6 clippy::if_same_then_else,
9 clippy::equatable_if_let
11 #![warn(clippy::needless_return)]
13 macro_rules! the_answer {
19 fn test_end_of_fn() -> bool {
27 fn test_no_semicolon() -> bool {
31 fn test_if_block() -> bool {
39 fn test_match(x: bool) -> bool {
55 fn test_macro_call() -> i32 {
63 fn test_void_if_fun(b: bool) {
71 fn test_void_match(x: u32) {
78 fn read_line() -> String {
80 let stdin = ::std::io::stdin();
81 return stdin.lock().lines().next().unwrap().unwrap();
84 fn borrows_but_not_last(value: bool) -> String {
87 let stdin = ::std::io::stdin();
88 let _a = stdin.lock().lines().next().unwrap().unwrap();
95 macro_rules! needed_return {
103 fn test_return_in_macro() {
104 // This will return and the macro below won't be executed. Removing the `return` from the macro
105 // will change semantics.
111 #[allow(clippy::unnecessary_lazy_evaluations)]
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 };