@@ -363,12 +363,12 @@ pub fn deprecate(name: &str, reason: Option<&String>) {
363
363
let name_upper = name. to_uppercase ( ) ;
364
364
365
365
let ( mut lints, deprecated_lints, renamed_lints) = gather_all ( ) ;
366
- let Some ( lint) = lints. iter ( ) . find ( |l| l. name == name_lower) else { panic ! ( "failed to find lint `{}`" , name) } ;
366
+ let Some ( lint) = lints. iter ( ) . find ( |l| l. name == name_lower) else { eprintln ! ( "error: failed to find lint `{}`" , name) ; return ; } ;
367
367
368
368
let mod_path = {
369
369
let mut mod_path = PathBuf :: from ( format ! ( "clippy_lints/src/{}" , lint. module) ) ;
370
370
if mod_path. is_dir ( ) {
371
- mod_path = mod_path. join ( name ) ;
371
+ mod_path = mod_path. join ( "mod" ) ;
372
372
}
373
373
374
374
mod_path. set_extension ( "rs" ) ;
@@ -422,7 +422,7 @@ fn remove_lint_declaration(name: &str, path: &Path, lints: &mut Vec<Lint>) -> io
422
422
let mut lint_name_end = impl_lint_pass_start + ( lint_name_pos + lint_name_upper. len ( ) ) ;
423
423
for c in content[ lint_name_end..impl_lint_pass_end] . chars ( ) {
424
424
// Remove trailing whitespace
425
- if c. is_whitespace ( ) {
425
+ if c == ',' || c . is_whitespace ( ) {
426
426
lint_name_end += 1 ;
427
427
} else {
428
428
break ;
@@ -440,39 +440,41 @@ fn remove_lint_declaration(name: &str, path: &Path, lints: &mut Vec<Lint>) -> io
440
440
fs:: remove_file ( path) ?;
441
441
} else {
442
442
// We can't delete the entire file, just remove the declaration
443
- if lint. module != name {
444
- let mut mod_decl_path = path. to_path_buf ( ) ;
445
- if mod_decl_path. is_dir ( ) {
446
- mod_decl_path = Path :: new ( "clippy_lints/src" ) . join ( & lint. module ) . join ( "mod.rs" ) ;
447
- }
448
-
449
- let mut content = fs:: read_to_string ( & mod_decl_path)
450
- . unwrap_or_else ( |_| panic ! ( "failed to read `{}`" , path. to_string_lossy( ) ) ) ;
451
-
452
- eprintln ! (
453
- "warn: you will have to manually remove any code related to `{}` from `{}`" ,
454
- name,
455
- & mod_decl_path. to_string_lossy( )
456
- ) ;
457
-
458
- assert ! (
459
- content[ lint. declaration_range. clone( ) ] . contains( & name. to_uppercase( ) ) ,
460
- "error: `{}` does not contain lint `{}`'s declaration" ,
461
- mod_decl_path. display( ) ,
462
- lint. name
463
- ) ;
464
-
465
- // Remove lint declaration (declare_clippy_lint!)
466
- content. replace_range ( lint. declaration_range . clone ( ) , "" ) ;
467
-
468
- // Remove the module declaration (mod xyz;)
469
- let mod_decl = format ! ( "\n mod {};" , name) ;
470
- content = content. replacen ( & mod_decl, "" , 1 ) ;
471
-
472
- remove_impl_lint_pass ( & lint. name . to_uppercase ( ) , & mut content) ;
473
- fs:: write ( mod_decl_path, content)
474
- . unwrap_or_else ( |_| panic ! ( "failed to write to `{}`" , path. to_string_lossy( ) ) ) ;
443
+
444
+ if let Some ( Some ( "mod.rs" ) ) = path. file_name ( ) . map ( OsStr :: to_str) {
445
+ // Remove clippy_lints/src/some_mod/some_lint.rs
446
+ let mut lint_mod_path = path. to_path_buf ( ) ;
447
+ lint_mod_path. set_file_name ( name) ;
448
+ lint_mod_path. set_extension ( "rs" ) ;
449
+
450
+ fs:: remove_file ( lint_mod_path) . ok ( ) ;
475
451
}
452
+
453
+ let mut content =
454
+ fs:: read_to_string ( & path) . unwrap_or_else ( |_| panic ! ( "failed to read `{}`" , path. to_string_lossy( ) ) ) ;
455
+
456
+ eprintln ! (
457
+ "warn: you will have to manually remove any code related to `{}` from `{}`" ,
458
+ name,
459
+ path. display( )
460
+ ) ;
461
+
462
+ assert ! (
463
+ content[ lint. declaration_range. clone( ) ] . contains( & name. to_uppercase( ) ) ,
464
+ "error: `{}` does not contain lint `{}`'s declaration" ,
465
+ path. display( ) ,
466
+ lint. name
467
+ ) ;
468
+
469
+ // Remove lint declaration (declare_clippy_lint!)
470
+ content. replace_range ( lint. declaration_range . clone ( ) , "" ) ;
471
+
472
+ // Remove the module declaration (mod xyz;)
473
+ let mod_decl = format ! ( "\n mod {};" , name) ;
474
+ content = content. replacen ( & mod_decl, "" , 1 ) ;
475
+
476
+ remove_impl_lint_pass ( & lint. name . to_uppercase ( ) , & mut content) ;
477
+ fs:: write ( path, content) . unwrap_or_else ( |_| panic ! ( "failed to write to `{}`" , path. to_string_lossy( ) ) ) ;
476
478
}
477
479
478
480
remove_test_assets ( name) ;
0 commit comments