3 #![allow(unknown_lints, unused, no_effect, redundant_closure_call, many_single_char_names)]
4 #![deny(redundant_closure)]
7 let a = Some(1u8).map(|a| foo(a));
8 //~^ ERROR redundant closure found
9 //~| HELP remove closure as shown
10 //~| SUGGESTION let a = Some(1u8).map(foo);
12 //~^ ERROR redundant closure found
13 //~| HELP remove closure as shown
14 //~| SUGGESTION meta(foo);
15 let c = Some(1u8).map(|a| {1+2; foo}(a));
16 //~^ ERROR redundant closure found
17 //~| HELP remove closure as shown
18 //~| SUGGESTION let c = Some(1u8).map({1+2; foo});
19 let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted?
20 all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
21 //~^ WARN needless_borrow
23 Some(1u8).map(|a| unsafe_fn(a)); // unsafe fn
27 let e = Some(1u8).map(|a| divergent(a));
28 let e = Some(1u8).map(|a| generic(a));
29 //~^ ERROR redundant closure found
30 //~| HELP remove closure as shown
31 //~| SUGGESTION map(generic);
32 let e = Some(1u8).map(generic);
35 let a: Option<Box<::std::ops::Deref<Target = [i32]>>> =
36 Some(vec![1i32, 2]).map(|v| -> Box<::std::ops::Deref<Target = [i32]>> { Box::new(v) });
39 fn meta<F>(f: F) where F: Fn(u8) {
47 fn foo2(_: u8) -> u8 {
51 fn all<X, F>(x: &[X], y: &X, f: F) -> bool
52 where F: Fn(&X, &X) -> bool {
53 x.iter().all(|e| f(e, y))
56 fn below(x: &u8, y: &u8) -> bool { x < y }
58 unsafe fn unsafe_fn(_: u8) { }
60 fn divergent(_: u8) -> ! {
64 fn generic<T>(_: T) -> u8 {