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 {
52 let _ = || return true;
55 fn test_macro_call() -> i32 {
63 fn test_void_if_fun(b: bool) {
71 fn test_void_match(x: u32) {
78 fn test_nested_match(x: u32) {
89 fn read_line() -> String {
91 let stdin = ::std::io::stdin();
92 return stdin.lock().lines().next().unwrap().unwrap();
95 fn borrows_but_not_last(value: bool) -> String {
98 let stdin = ::std::io::stdin();
99 let _a = stdin.lock().lines().next().unwrap().unwrap();
100 return String::from("test");
102 return String::new();
106 macro_rules! needed_return {
114 fn test_return_in_macro() {
115 // This will return and the macro below won't be executed. Removing the `return` from the macro
116 // will change semantics.
122 #[allow(clippy::unnecessary_lazy_evaluations)]
123 fn foo(bar: Result<(), ()>) {
124 bar.unwrap_or_else(|_| return)
135 #[allow(clippy::unnecessary_lazy_evaluations)]
136 fn bar(res: Result<Foo, u8>) -> Foo {
137 res.unwrap_or_else(|_| return Foo)
141 async fn async_test_end_of_fn() -> bool {
149 async fn async_test_no_semicolon() -> bool {
153 async fn async_test_if_block() -> bool {
161 async fn async_test_match(x: bool) -> bool {
163 true => return false,
170 async fn async_test_closure() {
174 let _ = || return true;
177 async fn async_test_macro_call() -> i32 {
178 return the_answer!();
181 async fn async_test_void_fun() {
185 async fn async_test_void_if_fun(b: bool) {
193 async fn async_test_void_match(x: u32) {
200 async fn async_read_line() -> String {
201 use std::io::BufRead;
202 let stdin = ::std::io::stdin();
203 return stdin.lock().lines().next().unwrap().unwrap();
206 async fn async_borrows_but_not_last(value: bool) -> String {
208 use std::io::BufRead;
209 let stdin = ::std::io::stdin();
210 let _a = stdin.lock().lines().next().unwrap().unwrap();
211 return String::from("test");
213 return String::new();
217 async fn async_test_return_in_macro() {
223 let Some(1) = Some(1) else { return };