3 #![feature(lint_reasons)]
6 clippy::if_same_then_else,
9 clippy::equatable_if_let
11 #![warn(clippy::needless_return)]
13 use std::cell::RefCell;
15 macro_rules! the_answer {
21 fn test_end_of_fn() -> bool {
29 fn test_no_semicolon() -> bool {
33 fn test_if_block() -> bool {
41 fn test_match(x: bool) -> bool {
57 fn test_macro_call() -> i32 {
65 fn test_void_if_fun(b: bool) {
73 fn test_void_match(x: u32) {
80 fn test_nested_match(x: u32) {
91 fn temporary_outlives_local() -> String {
92 let x = RefCell::<String>::default();
93 return x.borrow().clone();
96 fn borrows_but_not_last(value: bool) -> String {
98 let x = RefCell::<String>::default();
99 let _a = x.borrow().clone();
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(|_| {})
135 #[allow(clippy::unnecessary_lazy_evaluations)]
136 fn bar(res: Result<Foo, u8>) -> Foo {
137 res.unwrap_or_else(|_| 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 {
170 async fn async_test_closure() {
177 async fn async_test_macro_call() -> i32 {
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_temporary_outlives_local() -> String {
201 let x = RefCell::<String>::default();
202 return x.borrow().clone();
205 async fn async_borrows_but_not_last(value: bool) -> String {
207 let x = RefCell::<String>::default();
208 let _a = x.borrow().clone();
215 async fn async_test_return_in_macro() {
221 let Some(1) = Some(1) else { return };
224 fn needless_return_macro() -> String {
227 format!("Hello {}", "world!")
230 fn issue_9361() -> i32 {
231 #[allow(clippy::integer_arithmetic)]