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