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 {
65 fn test_void_if_fun(b: bool) {
71 fn test_void_match(x: u32) {
78 fn test_nested_match(x: u32) {
88 fn temporary_outlives_local() -> String {
89 let x = RefCell::<String>::default();
90 return x.borrow().clone();
93 fn borrows_but_not_last(value: bool) -> String {
95 let x = RefCell::<String>::default();
96 let _a = x.borrow().clone();
103 macro_rules! needed_return {
111 fn test_return_in_macro() {
112 // This will return and the macro below won't be executed. Removing the `return` from the macro
113 // will change semantics.
119 #[allow(clippy::unnecessary_lazy_evaluations)]
120 fn foo(bar: Result<(), ()>) {
121 bar.unwrap_or_else(|_| {})
131 #[allow(clippy::unnecessary_lazy_evaluations)]
132 fn bar(res: Result<Foo, u8>) -> Foo {
133 res.unwrap_or_else(|_| Foo)
137 async fn async_test_end_of_fn() -> bool {
145 async fn async_test_no_semicolon() -> bool {
149 async fn async_test_if_block() -> bool {
157 async fn async_test_match(x: bool) -> bool {
166 async fn async_test_closure() {
173 async fn async_test_macro_call() -> i32 {
177 async fn async_test_void_fun() {
180 async fn async_test_void_if_fun(b: bool) {
186 async fn async_test_void_match(x: u32) {
193 async fn async_temporary_outlives_local() -> String {
194 let x = RefCell::<String>::default();
195 return x.borrow().clone();
198 async fn async_borrows_but_not_last(value: bool) -> String {
200 let x = RefCell::<String>::default();
201 let _a = x.borrow().clone();
208 async fn async_test_return_in_macro() {
214 let Some(1) = Some(1) else { return };
217 fn needless_return_macro() -> String {
220 format!("Hello {}", "world!")
223 fn issue_9361() -> i32 {
224 #[allow(clippy::integer_arithmetic)]
228 fn issue8336(x: i32) -> bool {
230 println!("something");
237 fn issue8156(x: u8) -> u64 {
248 // Ideally the compiler should throw `unused_braces` in this case
249 fn issue9192() -> i32 {
255 fn issue9503(x: usize) -> isize {
260 !*(x as *const isize)
266 pub fn with_newline() {
276 fn issue9947() -> Result<(), String> {
280 // without anyhow, but triggers the same bug I believe
281 #[expect(clippy::useless_format)]
282 fn issue10051() -> Result<String, String> {