Skip to content

Commit e44b879

Browse files
committed
Remove lib.register_* and src/docs* in cargo dev update_lints
1 parent 9a42501 commit e44b879

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

clippy_dev/src/update_lints.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,57 @@ pub enum UpdateMode {
3636
pub fn update(update_mode: UpdateMode) {
3737
let (lints, deprecated_lints, renamed_lints) = gather_all();
3838
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+
fn remove_old_files(update_mode: UpdateMode) {
45+
let mut failed = false;
46+
let mut remove_file = |path: &Path| match update_mode {
47+
UpdateMode::Check => {
48+
if path.exists() {
49+
failed = true;
50+
println!("unexpected file: {}", path.display());
51+
}
52+
},
53+
UpdateMode::Change => {
54+
if fs::remove_file(path).is_ok() {
55+
println!("removed file: {}", path.display());
56+
}
57+
},
58+
};
59+
60+
let files = [
61+
"clippy_lints/src/lib.register_all.rs",
62+
"clippy_lints/src/lib.register_cargo.rs",
63+
"clippy_lints/src/lib.register_complexity.rs",
64+
"clippy_lints/src/lib.register_correctness.rs",
65+
"clippy_lints/src/lib.register_internal.rs",
66+
"clippy_lints/src/lib.register_lints.rs",
67+
"clippy_lints/src/lib.register_nursery.rs",
68+
"clippy_lints/src/lib.register_pedantic.rs",
69+
"clippy_lints/src/lib.register_perf.rs",
70+
"clippy_lints/src/lib.register_restriction.rs",
71+
"clippy_lints/src/lib.register_style.rs",
72+
"clippy_lints/src/lib.register_suspicious.rs",
73+
"src/docs.rs",
74+
];
75+
76+
for file in files {
77+
remove_file(Path::new(file));
78+
}
79+
80+
if let Ok(docs_dir) = fs::read_dir("src/docs") {
81+
for doc_file in docs_dir {
82+
let path = doc_file.unwrap().path();
83+
remove_file(&path);
84+
}
85+
}
86+
87+
if failed {
88+
exit_with_failure();
89+
}
3990
}
4091

4192
fn generate_lint_files(

0 commit comments

Comments
 (0)