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