6 #![allow(clippy::if_same_then_else, clippy::single_match, clippy::needless_bool)]
7 #![warn(clippy::needless_return)]
9 macro_rules! the_answer {
15 fn test_end_of_fn() -> bool {
23 fn test_no_semicolon() -> bool {
27 fn test_if_block() -> bool {
35 fn test_match(x: bool) -> bool {
48 let _ = || return true;
51 fn test_macro_call() -> i32 {
59 fn test_void_if_fun(b: bool) {
67 fn test_void_match(x: u32) {
74 fn read_line() -> String {
76 let stdin = ::std::io::stdin();
77 return stdin.lock().lines().next().unwrap().unwrap();
80 fn borrows_but_not_last(value: bool) -> String {
83 let stdin = ::std::io::stdin();
84 let _a = stdin.lock().lines().next().unwrap().unwrap();
85 return String::from("test");
91 macro_rules! needed_return {
99 fn test_return_in_macro() {
100 // This will return and the macro below won't be executed. Removing the `return` from the macro
101 // will change semantics.
107 fn foo(bar: Result<(), ()>) {
108 bar.unwrap_or_else(|_| return)
119 #[allow(clippy::unnecessary_lazy_evaluations)]
120 fn bar(res: Result<Foo, u8>) -> Foo {
121 res.unwrap_or_else(|_| return Foo)
125 async fn async_test_end_of_fn() -> bool {
133 async fn async_test_no_semicolon() -> bool {
137 async fn async_test_if_block() -> bool {
145 async fn async_test_match(x: bool) -> bool {
147 true => return false,
154 async fn async_test_closure() {
158 let _ = || return true;
161 async fn async_test_macro_call() -> i32 {
162 return the_answer!();
165 async fn async_test_void_fun() {
169 async fn async_test_void_if_fun(b: bool) {
177 async fn async_test_void_match(x: u32) {
184 async fn async_read_line() -> String {
185 use std::io::BufRead;
186 let stdin = ::std::io::stdin();
187 return stdin.lock().lines().next().unwrap().unwrap();
190 async fn async_borrows_but_not_last(value: bool) -> String {
192 use std::io::BufRead;
193 let stdin = ::std::io::stdin();
194 let _a = stdin.lock().lines().next().unwrap().unwrap();
195 return String::from("test");
197 return String::new();
201 async fn async_test_return_in_macro() {
207 let Some(1) = Some(1) else { return };