]> git.lizzy.rs Git - rust.git/blob - tests/target/fn.rs
Merge pull request #678 from marcusklaas/length-one-tuplez
[rust.git] / tests / target / fn.rs
1 // Tests different fns
2
3 fn foo(a: AAAA, b: BBB, c: CCC) -> RetType {}
4
5 fn foo(a: AAAA, b: BBB /* some, weird, inline comment */, c: CCC) -> RetType
6     where T: Blah
7 {
8
9 }
10
11 fn foo(a: AAA /* (comment) */)
12     where T: Blah
13 {
14
15 }
16
17 fn foo(a: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
18        b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB)
19        -> RetType
20     where T: Blah
21 {
22
23 }
24
25
26 fn foo<U, T>(a: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
27              b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB)
28              -> RetType
29     where T: Blah,
30           U: dsfasdfasdfasd
31 {
32
33 }
34
35 fn foo<U: Fn(A) -> B /* paren inside generics */>() {}
36
37 impl Foo {
38     fn with_no_errors<T, F>(&mut self, f: F) -> T
39         where F: FnOnce(&mut Resolver) -> T
40     {
41     }
42
43     fn foo(mut self, mut bar: u32) {}
44
45     fn bar(self, mut bazz: u32) {}
46 }
47
48 pub fn render<'a,
49               N: Clone + 'a,
50               E: Clone + 'a,
51               G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
52               W: Write>
53     (g: &'a G,
54      w: &mut W)
55      -> io::Result<()> {
56     render_opts(g, w, &[])
57 }
58
59 const fn foo() {
60     x;
61 }
62
63 pub const fn foo() {
64     x;
65 }
66
67 impl Foo {
68     const fn foo() {
69         x;
70     }
71 }
72
73 fn homura<T: Deref<Target = i32>>(_: T) {}
74
75 fn issue377() -> (Box<CompositorProxy + Send>, Box<CompositorReceiver>) {}
76
77 fn main() {
78     let _ = function(move || 5);
79     let _ = move || 42;
80     let _ = || unsafe { abort() };
81 }
82
83 // With inner attributes.
84 fn inner() {
85     #![inline]
86     x
87 }
88
89 #[cfg_attr(rustfmt, rustfmt_skip)]
90 fn foo(a: i32) -> i32 {
91     // comment
92     if a > 0 { 1 } else { 2 }
93 }