]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/target/issue_4573.rs
Rollup merge of #95040 - frank-king:fix/94981, r=Mark-Simulacrum
[rust.git] / src / tools / rustfmt / tests / target / issue_4573.rs
1 // rustmft-version:Two
2 // rustmft-use_small_heuristics:Max
3 // rustmft-merge_derives:false
4 // These are the same rustfmt configuration options that are used
5 // in the comiler as of ce39461ca75a and 8eb7c58dbb7b
6 // These are commits in https://github.com/rust-lang/rust
7
8 #![no_std] // inner attribute comment
9 // inner attribute comment
10 #![no_implicit_prelude]
11 // post inner attribute comment
12
13 #[cfg(not(miri))] // inline comment
14 #[no_link]
15 extern crate foo;
16
17 // before attributes
18 #[no_link]
19 // between attributes
20 #[cfg(not(miri))] // inline comment
21 extern crate foo as bar;
22
23 #[cfg(not(miri))] // inline comment
24 // between attribute and use
25 use foo;
26
27 #[cfg(not(miri))] // inline comment
28 use foo;
29
30 /* pre attributre */
31 #[cfg(not(miri))]
32 use foo::bar;
33
34 #[cfg(not(miri))] // inline comment
35 use foo::bar as FooBar;
36
37 #[cfg(not(miri))] // inline comment
38 #[allow(unused)]
39 #[deprecated(
40     since = "5.2",  // inline inner comment
41     note = "FOO was rarely used. Users should instead use BAR"
42 )]
43 #[allow(unused)]
44 static FOO: i32 = 42;
45
46 #[used]
47 #[export_name = "FOO"]
48 #[cfg(not(miri))] // inline comment
49 #[deprecated(
50     since = "5.2",
51     note = "FOO was rarely used. Users should instead use BAR"
52 )]
53 static FOO: i32 = 42;
54
55 #[cfg(not(miri))] // inline comment
56 #[export_name = "FOO"]
57 static BAR: &'static str = "bar";
58
59 #[cfg(not(miri))] // inline comment
60 const BAR: i32 = 42;
61
62 #[cfg(not(miri))] // inline comment
63 #[no_mangle]
64 #[link_section = ".example_section"]
65 fn foo(bar: usize) {
66     #[cfg(not(miri))] // inline comment
67     println!("hello world!");
68 }
69
70 #[cfg(not(miri))] // inline comment
71 mod foo {}
72
73 #[cfg(not(miri))] // inline comment
74 extern "C" {
75     fn my_c_function(x: i32) -> bool;
76 }
77
78 #[cfg(not(miri))] // inline comment
79 #[link(name = "CoreFoundation", kind = "framework")]
80 extern "C" {
81
82     #[link_name = "actual_symbol_name"] // inline comment
83     // between attribute and function
84     fn my_c_function(x: i32) -> bool;
85 }
86
87 #[cfg(not(miri))] // inline comment
88 pub extern "C" fn callable_from_c(x: i32) -> bool {
89     x % 3 == 0
90 }
91
92 #[cfg(not(miri))] // inline comment
93 /* between attribute block comment */
94 #[no_mangle]
95 /* between attribute and type */
96 type Foo = Bar<u8>;
97
98 #[no_mangle]
99 #[cfg(not(miri))] // inline comment
100 #[non_exhaustive] // inline comment
101 enum Foo {
102     Bar,
103     Baz,
104 }
105
106 #[no_mangle]
107 #[cfg(not(miri))] /* inline comment */
108 struct Foo<A> {
109     x: A,
110 }
111
112 #[cfg(not(miri))] // inline comment
113 union Foo<A, B> {
114     x: A,
115     y: B,
116 }
117
118 #[cfg(not(miri))] // inline comment
119 trait Foo {}
120
121 #[cfg(not(miri))] // inline comment
122 trait Foo = Bar + Quux;
123
124 #[cfg(not(miri))] // inline comment
125 impl Foo {}
126
127 #[cfg(not(miri))] // inline comment
128 macro_rules! bar {
129     (3) => {};
130 }
131
132 mod nested {
133     #[cfg(not(miri))] // inline comment
134     // between attribute and use
135     use foo;
136
137     #[cfg(not(miri))] // inline comment
138     use foo;
139
140     #[cfg(not(miri))] // inline comment
141     use foo::bar;
142
143     #[cfg(not(miri))] // inline comment
144     use foo::bar as FooBar;
145
146     #[cfg(not(miri))] // inline comment
147     static FOO: i32 = 42;
148
149     #[cfg(not(miri))] // inline comment
150     static FOO: i32 = 42;
151
152     #[cfg(not(miri))] // inline comment
153     static FOO: &'static str = "bar";
154
155     #[cfg(not(miri))] // inline comment
156     const FOO: i32 = 42;
157
158     #[cfg(not(miri))] // inline comment
159     fn foo(bar: usize) {
160         #[cfg(not(miri))] // inline comment
161         println!("hello world!");
162     }
163
164     #[cfg(not(miri))] // inline comment
165     mod foo {}
166
167     #[cfg(not(miri))] // inline comment
168     mod foo {}
169
170     #[cfg(not(miri))] // inline comment
171     extern "C" {
172         fn my_c_function(x: i32) -> bool;
173     }
174
175     #[cfg(not(miri))] // inline comment
176     #[link(name = "CoreFoundation", kind = "framework")]
177     extern "C" {
178
179         #[link_name = "actual_symbol_name"] // inline comment
180         // between attribute and function
181         fn my_c_function(x: i32) -> bool;
182     }
183
184     #[cfg(not(miri))] // inline comment
185     pub extern "C" fn callable_from_c(x: i32) -> bool {
186         x % 3 == 0
187     }
188
189     #[cfg(not(miri))] // inline comment
190     type Foo = Bar<u8>;
191
192     #[cfg(not(miri))] // inline comment
193     #[non_exhaustive] // inline comment
194     enum Foo {
195         // comment
196         #[attribute_1]
197         #[attribute_2] // comment
198         // comment!
199         Bar,
200         /* comment */
201         #[attribute_1]
202         #[attribute_2] /* comment */
203         #[attribute_3]
204         #[attribute_4]
205         /* comment! */
206         Baz,
207     }
208
209     #[cfg(not(miri))] // inline comment
210     struct Foo<A> {
211         x: A,
212     }
213
214     #[cfg(not(miri))] // inline comment
215     union Foo<A, B> {
216         #[attribute_1]
217         #[attribute_2] /* comment */
218         #[attribute_3]
219         #[attribute_4] // comment
220         x: A,
221         y: B,
222     }
223
224     #[cfg(not(miri))] // inline comment
225     #[allow(missing_docs)]
226     trait Foo {
227         #[must_use] /* comment
228                      * that wrappes to
229                      * the next line */
230         fn bar() {}
231     }
232
233     #[allow(missing_docs)]
234     #[cfg(not(miri))] // inline comment
235     trait Foo = Bar + Quux;
236
237     #[allow(missing_docs)]
238     #[cfg(not(miri))] // inline comment
239     impl Foo {}
240
241     #[cfg(not(miri))] // inline comment
242     macro_rules! bar {
243         (3) => {};
244     }
245 }