]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/blocks_in_if_conditions_closure.rs
1 #![warn(clippy::blocks_in_if_conditions)]
2 #![allow(unused, clippy::let_and_return)]
4 fn predicate
<F
: FnOnce(T
) -> bool
, T
>(pfn
: F
, val
: T
) -> bool
{
11 // This is a sneaky case, where the block isn't directly in the condition,
12 // but is actually inside a closure that the condition is using.
13 // The same principle applies -- add some extra expressions to make sure
14 // linter isn't confused by them.
35 fn closure_without_block() {
36 if predicate(|x
| x
== 3, 6) {}
39 fn macro_in_closure() {
40 let option
= Some(true);
42 if option
.unwrap_or_else(|| unimplemented
!()) {
49 let mut range
= 0..10;
50 range
.all(|i
| {i < 10}
);
52 let v
= vec
![1, 2, 3];
53 if v
.into_iter().any(|x
| {x == 4}
) {
54 println
!("contains 4!");