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 {
35 fn test_multiple_semicolon() -> bool {
40 fn test_multiple_semicolon_with_spaces() -> bool {
44 fn test_if_block() -> bool {
52 fn test_match(x: bool) -> bool {
68 fn test_macro_call() -> i32 {
75 fn test_void_if_fun(b: bool) {
81 fn test_void_match(x: u32) {
88 fn test_nested_match(x: u32) {
98 fn temporary_outlives_local() -> String {
99 let x = RefCell::<String>::default();
100 return x.borrow().clone();
103 fn borrows_but_not_last(value: bool) -> String {
105 let x = RefCell::<String>::default();
106 let _a = x.borrow().clone();
113 macro_rules! needed_return {
121 fn test_return_in_macro() {
122 // This will return and the macro below won't be executed. Removing the `return` from the macro
123 // will change semantics.
129 #[allow(clippy::unnecessary_lazy_evaluations)]
130 fn foo(bar: Result<(), ()>) {
131 bar.unwrap_or_else(|_| {})
141 #[allow(clippy::unnecessary_lazy_evaluations)]
142 fn bar(res: Result<Foo, u8>) -> Foo {
143 res.unwrap_or_else(|_| Foo)
147 async fn async_test_end_of_fn() -> bool {
155 async fn async_test_no_semicolon() -> bool {
159 async fn async_test_if_block() -> bool {
167 async fn async_test_match(x: bool) -> bool {
176 async fn async_test_closure() {
183 async fn async_test_macro_call() -> i32 {
187 async fn async_test_void_fun() {
190 async fn async_test_void_if_fun(b: bool) {
196 async fn async_test_void_match(x: u32) {
203 async fn async_temporary_outlives_local() -> String {
204 let x = RefCell::<String>::default();
205 return x.borrow().clone();
208 async fn async_borrows_but_not_last(value: bool) -> String {
210 let x = RefCell::<String>::default();
211 let _a = x.borrow().clone();
218 async fn async_test_return_in_macro() {
224 let Some(1) = Some(1) else { return };
227 fn needless_return_macro() -> String {
230 format!("Hello {}", "world!")
233 fn issue_9361() -> i32 {
234 #[allow(clippy::integer_arithmetic)]
238 fn issue8336(x: i32) -> bool {
240 println!("something");
247 fn issue8156(x: u8) -> u64 {
258 // Ideally the compiler should throw `unused_braces` in this case
259 fn issue9192() -> i32 {
265 fn issue9503(x: usize) -> isize {
270 !*(x as *const isize)
276 pub fn with_newline() {
286 fn issue9947() -> Result<(), String> {
290 // without anyhow, but triggers the same bug I believe
291 #[expect(clippy::useless_format)]
292 fn issue10051() -> Result<String, String> {