]> git.lizzy.rs Git - rust.git/blob - tests/ui/eta.rs
Allow new lint in ui/eta.rs
[rust.git] / tests / ui / eta.rs
1
2
3 #![allow(unknown_lints, unused, no_effect, redundant_closure_call, many_single_char_names, needless_pass_by_value, option_map_unit_fn)]
4 #![warn(redundant_closure, needless_borrow)]
5
6 fn main() {
7     let a = Some(1u8).map(|a| foo(a));
8     meta(|a| foo(a));
9     let c = Some(1u8).map(|a| {1+2; foo}(a));
10     let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted?
11     all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
12     unsafe {
13         Some(1u8).map(|a| unsafe_fn(a)); // unsafe fn
14     }
15
16     // See #815
17     let e = Some(1u8).map(|a| divergent(a));
18     let e = Some(1u8).map(|a| generic(a));
19     let e = Some(1u8).map(generic);
20     // See #515
21     let a: Option<Box<::std::ops::Deref<Target = [i32]>>> =
22         Some(vec![1i32, 2]).map(|v| -> Box<::std::ops::Deref<Target = [i32]>> { Box::new(v) });
23 }
24
25 fn meta<F>(f: F) where F: Fn(u8) {
26     f(1u8)
27 }
28
29 fn foo(_: u8) {
30 }
31
32 fn foo2(_: u8) -> u8 {
33     1u8
34 }
35
36 fn all<X, F>(x: &[X], y: &X, f: F) -> bool
37 where F: Fn(&X, &X) -> bool {
38     x.iter().all(|e| f(e, y))
39 }
40
41 fn below(x: &u8, y: &u8) -> bool { x < y }
42
43 unsafe fn unsafe_fn(_: u8) { }
44
45 fn divergent(_: u8) -> ! {
46     unimplemented!()
47 }
48
49 fn generic<T>(_: T) -> u8 {
50     0
51 }