]> git.lizzy.rs Git - rust.git/blob - tests/target/fn.rs
Merge pull request #1709 from theotherphil/master
[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
7     T: Blah,
8 {
9 }
10
11 fn foo(a: AAA /* (comment) */)
12 where
13     T: Blah,
14 {
15 }
16
17 fn foo(
18     a: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
19     b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
20 ) -> RetType
21 where
22     T: Blah,
23 {
24
25 }
26
27
28 fn foo<U, T>(
29     a: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
30     b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
31 ) -> RetType
32 where
33     T: Blah,
34     U: dsfasdfasdfasd,
35 {
36
37 }
38
39 fn foo<U: Fn(A) -> B /* paren inside generics */>() {}
40
41 impl Foo {
42     fn with_no_errors<T, F>(&mut self, f: F) -> T
43     where
44         F: FnOnce(&mut Resolver) -> T,
45     {
46     }
47
48     fn foo(mut self, mut bar: u32) {}
49
50     fn bar(self, mut bazz: u32) {}
51 }
52
53 pub fn render<
54     'a,
55     N: Clone + 'a,
56     E: Clone + 'a,
57     G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
58     W: Write,
59 >(
60     g: &'a G,
61     w: &mut W,
62 ) -> io::Result<()> {
63     render_opts(g, w, &[])
64 }
65
66 const fn foo() {
67     x;
68 }
69
70 pub const fn foo() {
71     x;
72 }
73
74 impl Foo {
75     const fn foo() {
76         x;
77     }
78 }
79
80 fn homura<T: Deref<Target = i32>>(_: T) {}
81
82 fn issue377() -> (Box<CompositorProxy + Send>, Box<CompositorReceiver>) {}
83
84 fn main() {
85     let _ = function(move || 5);
86     let _ = move || 42;
87     let _ = || unsafe { abort() };
88 }
89
90 // With inner attributes.
91 fn inner() {
92     #![inline]
93     x
94 }
95
96 #[cfg_attr(rustfmt, rustfmt_skip)]
97 fn foo(a: i32) -> i32 {
98     // comment
99     if a > 0 { 1 } else { 2 }
100 }
101
102 fn ______________________baz(
103     a: i32,
104 ) -> *mut ::std::option::Option<
105     extern "C" fn(arg1: i32, _____________________a: i32, arg3: i32) -> (),
106 > {
107 }
108
109 pub fn check_path<'a, 'tcx>(
110     tcx: TyCtxt<'a, 'tcx, 'tcx>,
111     path: &hir::Path,
112     id: ast::NodeId,
113     cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Depecation>),
114 ) {
115 }
116
117 pub fn check_path<'a, 'tcx>(
118     tcx: TyCtxt<'a, 'tcx, 'tcx>,
119     path: &hir::Path,
120     id: ast::NodeId,
121     cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>),
122 ) {
123 }