@@ -36,6 +36,60 @@ pub enum UpdateMode {
36
36
pub fn update ( update_mode : UpdateMode ) {
37
37
let ( lints, deprecated_lints, renamed_lints) = gather_all ( ) ;
38
38
generate_lint_files ( update_mode, & lints, & deprecated_lints, & renamed_lints) ;
39
+ remove_old_files ( update_mode) ;
40
+ }
41
+
42
+ /// Remove files no longer needed after <https://github.com/rust-lang/rust-clippy/pull/9541>
43
+ /// that may be reintroduced unintentionally
44
+ ///
45
+ /// FIXME: This is a temporary measure that should be removed when there are no more PRs that
46
+ /// include the stray files
47
+ fn remove_old_files ( update_mode : UpdateMode ) {
48
+ let mut failed = false ;
49
+ let mut remove_file = |path : & Path | match update_mode {
50
+ UpdateMode :: Check => {
51
+ if path. exists ( ) {
52
+ failed = true ;
53
+ println ! ( "unexpected file: {}" , path. display( ) ) ;
54
+ }
55
+ } ,
56
+ UpdateMode :: Change => {
57
+ if fs:: remove_file ( path) . is_ok ( ) {
58
+ println ! ( "removed file: {}" , path. display( ) ) ;
59
+ }
60
+ } ,
61
+ } ;
62
+
63
+ let files = [
64
+ "clippy_lints/src/lib.register_all.rs" ,
65
+ "clippy_lints/src/lib.register_cargo.rs" ,
66
+ "clippy_lints/src/lib.register_complexity.rs" ,
67
+ "clippy_lints/src/lib.register_correctness.rs" ,
68
+ "clippy_lints/src/lib.register_internal.rs" ,
69
+ "clippy_lints/src/lib.register_lints.rs" ,
70
+ "clippy_lints/src/lib.register_nursery.rs" ,
71
+ "clippy_lints/src/lib.register_pedantic.rs" ,
72
+ "clippy_lints/src/lib.register_perf.rs" ,
73
+ "clippy_lints/src/lib.register_restriction.rs" ,
74
+ "clippy_lints/src/lib.register_style.rs" ,
75
+ "clippy_lints/src/lib.register_suspicious.rs" ,
76
+ "src/docs.rs" ,
77
+ ] ;
78
+
79
+ for file in files {
80
+ remove_file ( Path :: new ( file) ) ;
81
+ }
82
+
83
+ if let Ok ( docs_dir) = fs:: read_dir ( "src/docs" ) {
84
+ for doc_file in docs_dir {
85
+ let path = doc_file. unwrap ( ) . path ( ) ;
86
+ remove_file ( & path) ;
87
+ }
88
+ }
89
+
90
+ if failed {
91
+ exit_with_failure ( ) ;
92
+ }
39
93
}
40
94
41
95
fn generate_lint_files (
0 commit comments