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