@@ -149,7 +149,8 @@ impl MetadataCollector {
149
149
fn get_lint_configs ( & self , lint_name : & str ) -> Option < String > {
150
150
self . config
151
151
. iter ( )
152
- . filter_map ( |x| x. lints . iter ( ) . any ( |x| x == lint_name) . then ( || format ! ( "{}" , x) ) )
152
+ . filter ( |config| config. lints . iter ( ) . any ( |lint| lint == lint_name) )
153
+ . map ( ToString :: to_string)
153
154
. reduce ( |acc, x| acc + & x)
154
155
. map ( |configurations| format ! ( CONFIGURATION_SECTION_TEMPLATE !( ) , configurations = configurations) )
155
156
}
@@ -261,52 +262,40 @@ impl Serialize for ApplicabilityInfo {
261
262
// ==================================================================
262
263
// Configuration
263
264
// ==================================================================
264
- #[ derive( Debug ) ]
265
- pub ( crate ) struct ClippyConfigurationBasicInfo {
266
- pub name : & ' static str ,
267
- pub config_type : & ' static str ,
268
- pub default : & ' static str ,
269
- pub doc_comment : & ' static str ,
270
- pub deprecation_reason : Option < & ' static str > ,
271
- }
272
-
273
265
#[ derive( Debug , Clone , Default ) ]
274
- struct ClippyConfiguration {
266
+ pub struct ClippyConfiguration {
275
267
name : String ,
276
- lints : Vec < String > ,
277
- doc : String ,
278
268
config_type : & ' static str ,
279
269
default : String ,
270
+ lints : Vec < String > ,
271
+ doc : String ,
280
272
deprecation_reason : Option < & ' static str > ,
281
273
}
282
274
283
- fn collect_configs ( ) -> Vec < ClippyConfiguration > {
284
- let cons = crate :: utils:: conf:: metadata:: get_configuration_metadata ( ) ;
285
- cons. iter ( )
286
- . map ( move |x| {
287
- let ( lints, doc) = parse_config_field_doc ( x. doc_comment )
288
- . unwrap_or_else ( || ( vec ! [ ] , "[ERROR] MALFORMED DOC COMMENT" . to_string ( ) ) ) ;
289
-
290
- ClippyConfiguration {
291
- name : to_kebab ( x. name ) ,
292
- lints,
293
- doc,
294
- config_type : x. config_type ,
295
- default : clarify_default ( x. default ) ,
296
- deprecation_reason : x. deprecation_reason ,
297
- }
298
- } )
299
- . collect ( )
300
- }
275
+ impl ClippyConfiguration {
276
+ pub fn new (
277
+ name : & ' static str ,
278
+ config_type : & ' static str ,
279
+ default : String ,
280
+ doc_comment : & ' static str ,
281
+ deprecation_reason : Option < & ' static str > ,
282
+ ) -> Self {
283
+ let ( lints, doc) = parse_config_field_doc ( doc_comment)
284
+ . unwrap_or_else ( || ( vec ! [ ] , "[ERROR] MALFORMED DOC COMMENT" . to_string ( ) ) ) ;
301
285
302
- fn clarify_default ( default : & ' static str ) -> String {
303
- if let Some ( ( _start, init) ) = default. split_once ( '[' ) {
304
- if let Some ( ( init, _end) ) = init. split_once ( ']' ) {
305
- return format ! ( "[{}]" , init) ;
286
+ Self {
287
+ name : to_kebab ( name) ,
288
+ lints,
289
+ doc,
290
+ config_type,
291
+ default,
292
+ deprecation_reason,
306
293
}
307
294
}
295
+ }
308
296
309
- default. to_string ( )
297
+ fn collect_configs ( ) -> Vec < ClippyConfiguration > {
298
+ crate :: utils:: conf:: metadata:: get_configuration_metadata ( )
310
299
}
311
300
312
301
/// This parses the field documentation of the config struct.
0 commit comments