]> git.lizzy.rs Git - rust.git/blob - tests/ui/eta.rs
Merge pull request #1564 from Manishearth/cleanup
[rust.git] / tests / ui / eta.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3 #![allow(unknown_lints, unused, no_effect, redundant_closure_call, many_single_char_names, needless_pass_by_value)]
4 #![deny(redundant_closure)]
5
6 fn main() {
7     let a = Some(1u8).map(|a| foo(a));
8
9
10
11     meta(|a| foo(a));
12
13
14
15     let c = Some(1u8).map(|a| {1+2; foo}(a));
16
17
18
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
22     unsafe {
23         Some(1u8).map(|a| unsafe_fn(a)); // unsafe fn
24     }
25
26     // See #815
27     let e = Some(1u8).map(|a| divergent(a));
28     let e = Some(1u8).map(|a| generic(a));
29
30
31
32     let e = Some(1u8).map(generic);
33
34     // See #515
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) });
37 }
38
39 fn meta<F>(f: F) where F: Fn(u8) {
40     f(1u8)
41 }
42
43 fn foo(_: u8) {
44
45 }
46
47 fn foo2(_: u8) -> u8 {
48     1u8
49 }
50
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))
54 }
55
56 fn below(x: &u8, y: &u8) -> bool { x < y }
57
58 unsafe fn unsafe_fn(_: u8) { }
59
60 fn divergent(_: u8) -> ! {
61     unimplemented!()
62 }
63
64 fn generic<T>(_: T) -> u8 {
65     0
66 }