@@ -11,10 +11,14 @@ use crate::config::Config;
11
11
12
12
#[ config_type]
13
13
pub enum NewlineStyle {
14
- Auto , // Auto-detect based on the raw source input
15
- Windows , // \r\n
16
- Unix , // \n
17
- Native , // \r\n in Windows, \n on other platforms
14
+ /// Auto-detect based on the raw source input.
15
+ Auto ,
16
+ /// Force CRLF (`\r\n`).
17
+ Windows ,
18
+ /// Force CR (`\n).
19
+ Unix ,
20
+ /// `\r\n` in Windows, `\n`` on other platforms.
21
+ Native ,
18
22
}
19
23
20
24
impl NewlineStyle {
@@ -74,58 +78,66 @@ impl NewlineStyle {
74
78
}
75
79
76
80
#[ config_type]
81
+ /// Where to put the opening brace of items (`fn`, `impl`, etc.).
77
82
pub enum BraceStyle {
83
+ /// Put the opening brace on the next line.
78
84
AlwaysNextLine ,
85
+ /// Put the opening brace on the same line, if possible.
79
86
PreferSameLine ,
80
- // Prefer same line except where there is a where-clause, in which case force
81
- // the brace to the next line.
87
+ /// Prefer the same line except where there is a where-clause, in which
88
+ /// case force the brace to be put on the next line.
82
89
SameLineWhere ,
83
90
}
84
91
85
92
#[ config_type]
93
+ /// Where to put the opening brace of conditional expressions (`if`, `match`, etc.).
86
94
pub enum ControlBraceStyle {
87
- // K&R style, Rust community default
95
+ /// K&R style, Rust community default
88
96
AlwaysSameLine ,
89
- // Stroustrup style
97
+ /// Stroustrup style
90
98
ClosingNextLine ,
91
- // Allman style
99
+ /// Allman style
92
100
AlwaysNextLine ,
93
101
}
94
102
95
103
#[ config_type]
104
+ /// How to indent.
96
105
pub enum IndentStyle {
97
- // First line on the same line as the opening brace, all lines aligned with
98
- // the first line.
106
+ /// First line on the same line as the opening brace, all lines aligned with
107
+ /// the first line.
99
108
Visual ,
100
- // First line is on a new line and all lines align with block indent.
109
+ /// First line is on a new line and all lines align with ** block** indent.
101
110
Block ,
102
111
}
103
112
104
113
#[ config_type]
114
+ /// How to place a list-like items.
105
115
pub enum Density {
106
- // Fit as much on one line as possible.
116
+ /// Fit as much on one line as possible.
107
117
Compressed ,
108
- // Use more lines.
118
+ /// Use more lines.
109
119
Tall ,
110
- // Place every item on a separate line.
120
+ /// Place every item on a separate line.
111
121
Vertical ,
112
122
}
113
123
114
124
#[ config_type]
125
+ /// Spacing around type combinators.
115
126
pub enum TypeDensity {
116
- // No spaces around "=" and "+"
127
+ /// No spaces around "=" and "+"
117
128
Compressed ,
118
- // Spaces around " = " and " + "
129
+ /// Spaces around " = " and " + "
119
130
Wide ,
120
131
}
121
132
122
133
#[ config_type]
134
+ /// To what extent does rustfmt pursue its heuristics?
123
135
pub enum Heuristics {
124
- // Turn off any heuristics
136
+ /// Turn off any heuristics
125
137
Off ,
126
- // Turn on max heuristics
138
+ /// Turn on max heuristics
127
139
Max ,
128
- // Use Rustfmt's defaults
140
+ /// Use Rustfmt's defaults
129
141
Default ,
130
142
}
131
143
@@ -147,42 +159,44 @@ pub enum ReportTactic {
147
159
Never ,
148
160
}
149
161
150
- // What Rustfmt should emit. Mostly corresponds to the `--emit` command line
151
- // option.
162
+ /// What Rustfmt should emit. Mostly corresponds to the `--emit` command line
163
+ /// option.
152
164
#[ config_type]
153
165
pub enum EmitMode {
154
- // Emits to files.
166
+ /// Emits to files.
155
167
Files ,
156
- // Writes the output to stdout.
168
+ /// Writes the output to stdout.
157
169
Stdout ,
158
- // Displays how much of the input file was processed
170
+ /// Displays how much of the input file was processed
159
171
Coverage ,
160
- // Unfancy stdout
172
+ /// Unfancy stdout
161
173
Checkstyle ,
162
- // Output the changed lines (for internal value only)
174
+ /// Output the changed lines (for internal value only)
163
175
ModifiedLines ,
164
- // Checks if a diff can be generated. If so, rustfmt outputs a diff and quits with exit code 1.
165
- // This option is designed to be run in CI where a non-zero exit signifies non-standard code
166
- // formatting. Used for `--check`.
176
+ /// Checks if a diff can be generated. If so, rustfmt outputs a diff and
177
+ /// quits with exit code 1.
178
+ /// This option is designed to be run in CI where a non-zero exit signifies
179
+ /// non-standard code formatting. Used for `--check`.
167
180
Diff ,
168
181
}
169
182
170
- // Client-preference for coloured output.
183
+ /// Client-preference for coloured output.
171
184
#[ config_type]
172
185
pub enum Color {
173
- // Always use color, whether it is a piped or terminal output
186
+ /// Always use color, whether it is a piped or terminal output
174
187
Always ,
175
- // Never use color
188
+ /// Never use color
176
189
Never ,
177
- // Automatically use color, if supported by terminal
190
+ /// Automatically use color, if supported by terminal
178
191
Auto ,
179
192
}
180
193
181
194
#[ config_type]
195
+ /// rustfmt format style version.
182
196
pub enum Version {
183
- // 1.x.y
197
+ /// 1.x.y. When specified, rustfmt will format in the same style as 1.0.0.
184
198
One ,
185
- // 2.x.y
199
+ /// 2.x.y. When specified, rustfmt will formatin the the latest style.
186
200
Two ,
187
201
}
188
202
@@ -197,13 +211,14 @@ impl Color {
197
211
}
198
212
}
199
213
200
- // How chatty should Rustfmt be?
214
+ /// How chatty should Rustfmt be?
201
215
#[ config_type]
202
216
pub enum Verbosity {
203
- // Emit more.
217
+ /// Emit more.
204
218
Verbose ,
219
+ /// Default.
205
220
Normal ,
206
- // Emit as little as possible.
221
+ /// Emit as little as possible.
207
222
Quiet ,
208
223
}
209
224
@@ -369,14 +384,16 @@ pub trait CliOptions {
369
384
fn config_path ( & self ) -> Option < & Path > ;
370
385
}
371
386
372
- // The edition of the compiler (RFC 2052)
387
+ /// The edition of the syntax and semntics of code (RFC 2052).
373
388
#[ config_type]
374
389
pub enum Edition {
375
390
#[ value = "2015" ]
376
391
#[ doc_hint = "2015" ]
392
+ /// Edition 2015.
377
393
Edition2015 ,
378
394
#[ value = "2018" ]
379
395
#[ doc_hint = "2018" ]
396
+ /// Edition 2018.
380
397
Edition2018 ,
381
398
}
382
399
0 commit comments