1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 #![warn(clippy::block_in_if_condition_expr)]
11 #![warn(clippy::block_in_if_condition_stmt)]
12 #![allow(unused, clippy::let_and_return)]
13 #![warn(clippy::nonminimal_bool)]
21 macro_rules! blocky_too {
34 fn condition_has_block() -> i32 {
45 fn condition_has_block_with_single_expression() -> i32 {
53 fn predicate<F: FnOnce(T) -> bool, T>(pfn: F, val: T) -> bool {
60 // this is a sneaky case, where the block isn't directly in the condition, but is actually
61 // inside a closure that the condition is using. same principle applies. add some extra
62 // expressions to make sure linter isn't confused by them.
83 fn condition_is_normal() -> i32 {
92 fn closure_without_block() {
93 if predicate(|x| x == 3, 6) {}
96 fn condition_is_unsafe_block() {
99 // this should not warn because the condition is an unsafe block
100 if unsafe { 1u32 == std::mem::transmute(a) } {
101 println!("1u32 == a");
107 fn macro_in_closure() {
108 let option = Some(true);
110 if option.unwrap_or_else(|| unimplemented!()) {