2015-05-10 00:09:04 -05:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(clippy)]
|
|
|
|
#![allow(unknown_lints, unused)]
|
|
|
|
#![deny(redundant_closure)]
|
|
|
|
|
|
|
|
fn main() {
|
2015-08-14 07:21:05 -05:00
|
|
|
let a = Some(1u8).map(|a| foo(a));
|
2015-08-12 03:46:49 -05:00
|
|
|
//~^ ERROR redundant closure found. Consider using `foo` in its place
|
2015-08-14 07:21:05 -05:00
|
|
|
meta(|a| foo(a));
|
|
|
|
//~^ ERROR redundant closure found. Consider using `foo` in its place
|
|
|
|
let c = Some(1u8).map(|a| {1+2; foo}(a));
|
2015-08-12 03:46:49 -05:00
|
|
|
//~^ ERROR redundant closure found. Consider using `{ 1 + 2; foo }` in its place
|
2015-08-14 07:21:05 -05:00
|
|
|
let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted?
|
|
|
|
all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
|
|
|
|
}
|
|
|
|
|
|
|
|
fn meta<F>(f: F) where F: Fn(u8) {
|
|
|
|
f(1u8)
|
2015-05-10 00:09:04 -05:00
|
|
|
}
|
|
|
|
|
2015-08-14 07:21:05 -05:00
|
|
|
fn foo(_: u8) {
|
2015-05-10 00:09:04 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-08-14 07:21:05 -05:00
|
|
|
fn foo2(_: u8) -> u8 {
|
2015-05-10 00:09:04 -05:00
|
|
|
1u8
|
2015-08-12 03:46:49 -05:00
|
|
|
}
|
2015-08-14 07:21:05 -05:00
|
|
|
|
|
|
|
fn all<X, F>(x: &[X], y: &X, f: F) -> bool
|
|
|
|
where F: Fn(&X, &X) -> bool {
|
|
|
|
x.iter().all(|e| f(e, y))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn below(x: &u8, y: &u8) -> bool { x < y }
|