@@ -225,6 +225,31 @@ fn fmt_conf(check: bool) -> Result<(), Error> {
225
225
Ok ( ( ) )
226
226
}
227
227
228
+ /// Format the symbols list
229
+ fn fmt_syms ( check : bool ) -> Result < ( ) , Error > {
230
+ let path = "clippy_utils/src/sym.rs" ;
231
+ let text = fs:: read_to_string ( path) ?;
232
+
233
+ let ( pre, conf) = text. split_once ( "generate! {\n " ) . expect ( "can't find generate! call" ) ;
234
+ let ( conf, post) = conf. split_once ( "\n }\n " ) . expect ( "can't find end of generate! call" ) ;
235
+ let mut lines = conf
236
+ . lines ( )
237
+ . map ( |line| {
238
+ let line = line. trim ( ) ;
239
+ line. strip_suffix ( ',' ) . unwrap_or ( line) . trim_end ( )
240
+ } )
241
+ . collect :: < Vec < _ > > ( ) ;
242
+ lines. sort_by_cached_key ( |a| a. to_uppercase ( ) ) ;
243
+ let new_text = format ! ( "{pre}generate! {{\n {},\n }}\n {post}" , lines. join( ",\n " ) , ) ;
244
+ if text != new_text {
245
+ if check {
246
+ return Err ( Error :: CheckFailed ) ;
247
+ }
248
+ fs:: write ( path, new_text. as_bytes ( ) ) ?;
249
+ }
250
+ Ok ( ( ) )
251
+ }
252
+
228
253
fn run_rustfmt ( clippy : & ClippyInfo , update_mode : UpdateMode ) {
229
254
let mut rustfmt_path = String :: from_utf8 ( run_with_output (
230
255
"rustup which rustfmt" ,
@@ -337,7 +362,7 @@ pub fn run(clippy: &ClippyInfo, update_mode: UpdateMode) {
337
362
}
338
363
run_rustfmt ( clippy, update_mode) ;
339
364
340
- if let Err ( e) = fmt_conf ( update_mode. is_check ( ) ) {
365
+ if let Err ( e) = fmt_conf ( update_mode. is_check ( ) ) . and_then ( | ( ) | fmt_syms ( update_mode . is_check ( ) ) ) {
341
366
e. display ( ) ;
342
367
process:: exit ( 1 ) ;
343
368
}
0 commit comments