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 {
55 let _ = || return true;
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();
101 return String::from("test");
103 return String::new();
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(|_| return)
136 #[allow(clippy::unnecessary_lazy_evaluations)]
137 fn bar(res: Result<Foo, u8>) -> Foo {
138 res.unwrap_or_else(|_| return 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 {
164 true => return false,
171 async fn async_test_closure() {
175 let _ = || return true;
178 async fn async_test_macro_call() -> i32 {
179 return the_answer!();
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();
210 return String::from("test");
212 return String::new();
216 async fn async_test_return_in_macro() {
222 let Some(1) = Some(1) else { return };
225 fn needless_return_macro() -> String {
228 return format!("Hello {}", "world!");
231 fn issue_9361() -> i32 {
232 #[allow(clippy::integer_arithmetic)]
236 fn issue8336(x: i32) -> bool {
238 println!("something");
245 fn issue8156(x: u8) -> u64 {
256 // Ideally the compiler should throw `unused_braces` in this case
257 fn issue9192() -> i32 {
263 fn issue9503(x: usize) -> isize {
266 return *(x as *const isize);
268 return !*(x as *const isize);
274 pub fn with_newline() {
286 fn issue9947() -> Result<(), String> {