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