5 clippy::if_same_then_else,
7 clippy::branches_sharing_code,
10 #![warn(clippy::needless_return)]
12 macro_rules! the_answer {
18 fn test_end_of_fn() -> bool {
26 fn test_no_semicolon() -> bool {
30 fn test_if_block() -> bool {
38 fn test_match(x: bool) -> bool {
54 fn test_macro_call() -> i32 {
62 fn test_void_if_fun(b: bool) {
70 fn test_void_match(x: u32) {
77 fn read_line() -> String {
79 let stdin = ::std::io::stdin();
80 return stdin.lock().lines().next().unwrap().unwrap();
83 fn borrows_but_not_last(value: bool) -> String {
86 let stdin = ::std::io::stdin();
87 let _a = stdin.lock().lines().next().unwrap().unwrap();
94 macro_rules! needed_return {
102 fn test_return_in_macro() {
103 // This will return and the macro below won't be executed. Removing the `return` from the macro
104 // will change semantics.
110 fn foo(bar: Result<(), ()>) {
111 bar.unwrap_or_else(|_| {})
122 #[allow(clippy::unnecessary_lazy_evaluations)]
123 fn bar(res: Result<Foo, u8>) -> Foo {
124 res.unwrap_or_else(|_| Foo)
129 let _ = test_end_of_fn();
130 let _ = test_no_semicolon();
131 let _ = test_if_block();
132 let _ = test_match(true);