]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/target/multiple.rs
Merge commit '39683d8eb7a32a74bea96ecbf1e87675d3338506' into sync_cg_gcc-2022-03-26
[rust.git] / src / tools / rustfmt / tests / target / multiple.rs
1 // rustfmt-normalize_comments: true
2 // rustfmt-wrap_comments: true
3 // rustfmt-format_strings: true
4 // Test of lots of random stuff.
5 // FIXME split this into multiple, self-contained tests.
6
7 #[attr1]
8 extern crate foo;
9 #[attr2]
10 #[attr3]
11 extern crate foo;
12 #[attr1]
13 extern crate foo;
14 #[attr2]
15 #[attr3]
16 extern crate foo;
17
18 use std::cell::*;
19 use std::{
20     self, any, ascii, borrow, borrow, borrow, borrow, borrow, borrow, borrow, borrow, borrow,
21     borrow, borrow, boxed, boxed, boxed, boxed, boxed, boxed, boxed, boxed, boxed, boxed, char,
22     char, char, char, char, char, char, char, char, char,
23 };
24
25 mod doc;
26 mod other;
27
28 // sfdgfffffffffffffffffffffffffffffffffffffffffffffffffffffff
29 // ffffffffffffffffffffffffffffffffffffffffff
30
31 fn foo(a: isize, b: u32 /* blah blah */, c: f64) {}
32
33 fn foo() -> Box<Write + 'static>
34 where
35     'a: 'b,
36     for<'a> D<'b>: 'a,
37 {
38     hello!()
39 }
40
41 fn baz<
42     'a: 'b,                                                            // comment on 'a
43     T: SomsssssssssssssssssssssssssssssssssssssssssssssssssssssseType, // comment on T
44 >(
45     a: A,
46     b: B, // comment on b
47     c: C,
48 ) -> Bob {
49     #[attr1]
50     extern crate foo;
51     #[attr2]
52     #[attr3]
53     extern crate foo;
54     #[attr1]
55     extern crate foo;
56     #[attr2]
57     #[attr3]
58     extern crate foo;
59 }
60
61 #[rustfmt::skip]
62 fn qux(a: dadsfa,   // Comment 1
63        b: sdfasdfa, // Comment 2
64        c: dsfdsafa) // Comment 3
65 {
66
67 }
68
69 /// Blah blah blah.
70 impl Bar {
71     fn foo(
72         &mut self,
73         a: sdfsdfcccccccccccccccccccccccccccccccccccccccccccccccccc, // comment on a
74         b: sdfasdfsdfasfs,                                           // closing comment
75     ) -> isize {
76     }
77
78     /// Blah blah blah.
79     pub fn f2(self) {
80         (foo, bar)
81     }
82
83     #[an_attribute]
84     fn f3(self) -> Dog {}
85 }
86
87 /// The `nodes` and `edges` method each return instantiations of
88 /// `Cow<[T]>` to leave implementers the freedom to create
89
90 /// entirely new vectors or to pass back slices into internally owned
91 /// vectors.
92 pub trait GraphWalk<'a, N, E> {
93     /// Returns all the nodes in this graph.
94     fn nodes(&'a self) -> Nodes<'a, N>;
95     /// Returns all of the edges in this graph.
96     fn edges(&'a self) -> Edges<'a, E>;
97     /// The source node for `edge`.
98     fn source(&'a self, edge: &E) -> N;
99     /// The target node for `edge`.
100     fn target(&'a self, edge: &E) -> N;
101 }
102
103 /// A Doc comment
104 #[AnAttribute]
105 pub struct Foo {
106     #[rustfmt::skip]
107     f :   SomeType, // Comment beside a field
108     f: SomeType, // Comment beside a field
109     // Comment on a field
110     g: SomeOtherType,
111     /// A doc comment on a field
112     h: AThirdType,
113 }
114
115 struct Bar;
116
117 // With a where-clause and generics.
118 pub struct Foo<'a, Y: Baz>
119 where
120     X: Whatever,
121 {
122     f: SomeType, // Comment beside a field
123 }
124
125 fn foo(ann: &'a (PpAnn + 'a)) {}
126
127 fn main() {
128     for i in 0i32..4 {
129         println!("{}", i);
130     }
131
132     while true {
133         hello();
134     }
135
136     let rc = Cell::new(
137         42usize,
138         42usize,
139         Cell::new(
140             42usize,
141             remaining_widthremaining_widthremaining_widthremaining_width,
142         ),
143         42usize,
144     );
145     let rc = RefCell::new(42usize, remaining_width, remaining_width); // a comment
146     let x = "Hello!!!!!!!!! abcd  abcd abcd abcd abcd abcd\n abcd abcd abcd abcd abcd abcd abcd \
147              abcd abcd abcd  abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd \
148              abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd \
149              abcd abcd";
150     let s = expand(a, b);
151 }
152
153 fn deconstruct() -> (
154     SocketAddr,
155     Method,
156     Headers,
157     RequestUri,
158     HttpVersion,
159     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
160 ) {
161 }
162
163 fn deconstruct(
164     foo: Bar,
165 ) -> (
166     SocketAddr,
167     Method,
168     Headers,
169     RequestUri,
170     HttpVersion,
171     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
172 ) {
173 }
174
175 #[rustfmt::skip]
176 mod a{
177 fn foo(x:    T) {
178     let x:    T = dfasdf;
179 }
180 }