Skip to content

Commit 01ea06a

Browse files
committed
Auto merge of rust-lang#7780 - mikerite:update_lints_mod_revert, r=llogiq
Revert `update_lints` module list generating code This commit reverts the module list generation code to what it was before the change to `include!` it and generates better output. changelog: none
2 parents 11492c7 + 8f075ec commit 01ea06a

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

clippy_dev/src/update_lints.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use itertools::Itertools;
22
use regex::Regex;
3-
use std::collections::{BTreeSet, HashMap};
3+
use std::collections::HashMap;
44
use std::ffi::OsStr;
55
use std::fs;
66
use std::lazy::SyncLazy;
@@ -105,7 +105,7 @@ pub fn run(update_mode: UpdateMode) {
105105
"end lints modules",
106106
false,
107107
update_mode == UpdateMode::Change,
108-
|| vec![gen_modules_list(usable_lints.iter())],
108+
|| gen_modules_list(usable_lints.iter()),
109109
)
110110
.changed;
111111

@@ -262,14 +262,13 @@ fn gen_lint_group_list<'a>(group_name: &str, lints: impl Iterator<Item = &'a Lin
262262

263263
/// Generates the module declarations for `lints`
264264
#[must_use]
265-
fn gen_modules_list<'a>(lints: impl Iterator<Item = &'a Lint>) -> String {
266-
let module_names: BTreeSet<_> = lints.map(|l| &l.module).collect();
267-
268-
let mut output = GENERATED_FILE_COMMENT.to_string();
269-
for name in module_names {
270-
output.push_str(&format!("mod {};\n", name));
271-
}
272-
output
265+
fn gen_modules_list<'a>(lints: impl Iterator<Item = &'a Lint>) -> Vec<String> {
266+
lints
267+
.map(|l| &l.module)
268+
.unique()
269+
.map(|module| format!("mod {};", module))
270+
.sorted()
271+
.collect::<Vec<String>>()
273272
}
274273

275274
/// Generates the list of lint links at the bottom of the CHANGELOG
@@ -677,8 +676,7 @@ mod tests {
677676
Lint::new("should_assert_eq", "group1", "abc", None, "module_name"),
678677
Lint::new("incorrect_stuff", "group3", "abc", None, "another_module"),
679678
];
680-
let expected =
681-
GENERATED_FILE_COMMENT.to_string() + &["mod another_module;", "mod module_name;"].join("\n") + "\n";
679+
let expected = vec!["mod another_module;".to_string(), "mod module_name;".to_string()];
682680
assert_eq!(expected, gen_modules_list(lints.iter()));
683681
}
684682

clippy_lints/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ mod deprecated_lints;
156156
mod utils;
157157

158158
// begin lints modules, do not remove this comment, it’s used in `update_lints`
159-
// This file was generated by `cargo dev update_lints`.
160-
// Use that command to update this file and do not edit by hand.
161-
// Manual edits will be overwritten.
162-
163159
mod absurd_extreme_comparisons;
164160
mod approx_const;
165161
mod arithmetic;
@@ -390,7 +386,6 @@ mod wildcard_imports;
390386
mod write;
391387
mod zero_div_zero;
392388
mod zero_sized_map_values;
393-
394389
// end lints modules, do not remove this comment, it’s used in `update_lints`
395390

396391
pub use crate::utils::conf::Conf;

0 commit comments

Comments
 (0)