Skip to content

Update clippy for latest rustc changes #4650

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 8 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from 6 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
20 changes: 17 additions & 3 deletions clippy_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
if l.is_internal() || l.deprecation.is_some() {
None
} else {
Some(format!(" {}::{},", l.module, l.name.to_uppercase()))
Some(format!(" LintId::of(&{}::{}),", l.module, l.name.to_uppercase()))
}
})
.sorted()
Expand Down Expand Up @@ -143,6 +143,20 @@ pub fn gen_deprecated(lints: &[Lint]) -> Vec<String> {
.collect::<Vec<String>>()
}

pub fn gen_register_lint_list(lints: &[Lint]) -> Vec<String> {
let pre = " store.register_lints(&[".to_string();
let post = " ]);".to_string();
let mut inner = lints
.iter()
.filter(|l| !(l.is_internal() || l.deprecation.is_some()))
.map(|l| format!(" &{}::{},", l.module, l.name.to_uppercase()))
.sorted()
.collect::<Vec<String>>();
inner.insert(0, pre);
inner.push(post);
inner
}

/// Gathers all files in `src/clippy_lints` and gathers all lints inside
pub fn gather_all() -> impl Iterator<Item = Lint> {
lint_files().flat_map(|f| gather_from_file(&f))
Expand Down Expand Up @@ -487,8 +501,8 @@ fn test_gen_lint_group_list() {
Lint::new("incorrect_internal", "internal_style", "abc", None, "module_name"),
];
let expected = vec![
" module_name::ABC,".to_string(),
" module_name::SHOULD_ASSERT_EQ,".to_string(),
" LintId::of(&module_name::ABC),".to_string(),
" LintId::of(&module_name::SHOULD_ASSERT_EQ),".to_string(),
];
assert_eq!(expected, gen_lint_group_list(lints));
}
14 changes: 12 additions & 2 deletions clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ fn update_lints(update_mode: &UpdateMode) {
)
.changed;

file_change |= replace_region_in_file(
"../clippy_lints/src/lib.rs",
"begin register lints",
"end register lints",
false,
update_mode == &UpdateMode::Change,
|| gen_register_lint_list(&lint_list),
)
.changed;

file_change |= replace_region_in_file(
"../clippy_lints/src/lib.rs",
"begin lints modules",
Expand All @@ -183,7 +193,7 @@ fn update_lints(update_mode: &UpdateMode) {
// Generate lists of lints in the clippy::all lint group
file_change |= replace_region_in_file(
"../clippy_lints/src/lib.rs",
r#"reg.register_lint_group\("clippy::all""#,
r#"store.register_group\(true, "clippy::all""#,
r#"\]\);"#,
false,
update_mode == &UpdateMode::Change,
Expand All @@ -206,7 +216,7 @@ fn update_lints(update_mode: &UpdateMode) {
for (lint_group, lints) in Lint::by_lint_group(&usable_lints) {
file_change |= replace_region_in_file(
"../clippy_lints/src/lib.rs",
&format!("reg.register_lint_group\\(\"clippy::{}\"", lint_group),
&format!("store.register_group\\(true, \"clippy::{}\"", lint_group),
r#"\]\);"#,
false,
update_mode == &UpdateMode::Change,
Expand Down
Loading