3 #![feature(lint_reasons)]
7 clippy::if_same_then_else,
10 clippy::equatable_if_let
12 #![warn(clippy::needless_return)]
14 use std::cell::RefCell;
16 macro_rules! the_answer {
22 fn test_end_of_fn() -> bool {
30 fn test_no_semicolon() -> bool {
34 fn test_if_block() -> bool {
42 fn test_match(x: bool) -> bool {
58 fn test_macro_call() -> i32 {
66 fn test_void_if_fun(b: bool) {
74 fn test_void_match(x: u32) {
81 fn test_nested_match(x: u32) {
92 fn temporary_outlives_local() -> String {
93 let x = RefCell::<String>::default();
94 return x.borrow().clone();
97 fn borrows_but_not_last(value: bool) -> String {
99 let x = RefCell::<String>::default();
100 let _a = x.borrow().clone();
107 macro_rules! needed_return {
115 fn test_return_in_macro() {
116 // This will return and the macro below won't be executed. Removing the `return` from the macro
117 // will change semantics.
123 #[allow(clippy::unnecessary_lazy_evaluations)]
124 fn foo(bar: Result<(), ()>) {
125 bar.unwrap_or_else(|_| {})
136 #[allow(clippy::unnecessary_lazy_evaluations)]
137 fn bar(res: Result<Foo, u8>) -> Foo {
138 res.unwrap_or_else(|_| Foo)
142 async fn async_test_end_of_fn() -> bool {
150 async fn async_test_no_semicolon() -> bool {
154 async fn async_test_if_block() -> bool {
162 async fn async_test_match(x: bool) -> bool {
171 async fn async_test_closure() {
178 async fn async_test_macro_call() -> i32 {
182 async fn async_test_void_fun() {
186 async fn async_test_void_if_fun(b: bool) {
194 async fn async_test_void_match(x: u32) {
201 async fn async_temporary_outlives_local() -> String {
202 let x = RefCell::<String>::default();
203 return x.borrow().clone();
206 async fn async_borrows_but_not_last(value: bool) -> String {
208 let x = RefCell::<String>::default();
209 let _a = x.borrow().clone();
216 async fn async_test_return_in_macro() {
222 let Some(1) = Some(1) else { return };
225 fn needless_return_macro() -> String {
228 format!("Hello {}", "world!")
231 fn issue_9361() -> i32 {
232 #[allow(clippy::integer_arithmetic)]