Update clippy_dev

This commit is contained in:
Mark Rousskov
2019-10-11 08:33:42 -04:00
committed by flip1995
parent 7e77f3c29f
commit 8c205018d2
2 changed files with 32 additions and 8 deletions

View File

@@ -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()
@@ -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))
@@ -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));
}