Skip to content

Revert update_lints module list generating code #7780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions clippy_dev/src/update_lints.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use itertools::Itertools;
use regex::Regex;
use std::collections::{BTreeSet, HashMap};
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs;
use std::lazy::SyncLazy;
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn run(update_mode: UpdateMode) {
"end lints modules",
false,
update_mode == UpdateMode::Change,
|| vec![gen_modules_list(usable_lints.iter())],
|| gen_modules_list(usable_lints.iter()),
)
.changed;

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

/// Generates the module declarations for `lints`
#[must_use]
fn gen_modules_list<'a>(lints: impl Iterator<Item = &'a Lint>) -> String {
let module_names: BTreeSet<_> = lints.map(|l| &l.module).collect();

let mut output = GENERATED_FILE_COMMENT.to_string();
for name in module_names {
output.push_str(&format!("mod {};\n", name));
}
output
fn gen_modules_list<'a>(lints: impl Iterator<Item = &'a Lint>) -> Vec<String> {
lints
.map(|l| &l.module)
.unique()
.map(|module| format!("mod {};", module))
.sorted()
.collect::<Vec<String>>()
}

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

Expand Down
5 changes: 0 additions & 5 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ mod deprecated_lints;
mod utils;

// begin lints modules, do not remove this comment, it’s used in `update_lints`
// This file was generated by `cargo dev update_lints`.
// Use that command to update this file and do not edit by hand.
// Manual edits will be overwritten.

mod absurd_extreme_comparisons;
mod approx_const;
mod arithmetic;
Expand Down Expand Up @@ -390,7 +386,6 @@ mod wildcard_imports;
mod write;
mod zero_div_zero;
mod zero_sized_map_values;

// end lints modules, do not remove this comment, it’s used in `update_lints`

pub use crate::utils::conf::Conf;
Expand Down