6 clippy::if_same_then_else,
8 clippy::branches_sharing_code,
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 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();
89 return String::from("test");
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 fn foo(bar: Result<(), ()>) {
112 bar.unwrap_or_else(|_| return)
123 #[allow(clippy::unnecessary_lazy_evaluations)]
124 fn bar(res: Result<Foo, u8>) -> Foo {
125 res.unwrap_or_else(|_| return Foo)
129 async fn async_test_end_of_fn() -> bool {
137 async fn async_test_no_semicolon() -> bool {
141 async fn async_test_if_block() -> bool {
149 async fn async_test_match(x: bool) -> bool {
151 true => return false,
158 async fn async_test_closure() {
162 let _ = || return true;
165 async fn async_test_macro_call() -> i32 {
166 return the_answer!();
169 async fn async_test_void_fun() {
173 async fn async_test_void_if_fun(b: bool) {
181 async fn async_test_void_match(x: u32) {
188 async fn async_read_line() -> String {
189 use std::io::BufRead;
190 let stdin = ::std::io::stdin();
191 return stdin.lock().lines().next().unwrap().unwrap();
194 async fn async_borrows_but_not_last(value: bool) -> String {
196 use std::io::BufRead;
197 let stdin = ::std::io::stdin();
198 let _a = stdin.lock().lines().next().unwrap().unwrap();
199 return String::from("test");
201 return String::new();
205 async fn async_test_return_in_macro() {