mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Build the import lint in update_lints.py
This commit is contained in:
parent
78b31c61bd
commit
5fe6e9f911
2 changed files with 51 additions and 35 deletions
73
src/lib.rs
73
src/lib.rs
|
@ -35,59 +35,62 @@ extern crate rustc_plugin;
|
|||
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
pub mod consts;
|
||||
#[macro_use]
|
||||
pub mod utils;
|
||||
pub mod copies;
|
||||
pub mod consts;
|
||||
pub mod types;
|
||||
pub mod misc;
|
||||
pub mod enum_glob_use;
|
||||
pub mod eq_op;
|
||||
pub mod bit_mask;
|
||||
pub mod ptr_arg;
|
||||
pub mod needless_bool;
|
||||
|
||||
// begin lints modules, do not remove this comment, it’s used in `update_lints`
|
||||
pub mod approx_const;
|
||||
pub mod eta_reduction;
|
||||
pub mod array_indexing;
|
||||
pub mod attrs;
|
||||
pub mod bit_mask;
|
||||
pub mod block_in_if_condition;
|
||||
pub mod collapsible_if;
|
||||
pub mod copies;
|
||||
pub mod cyclomatic_complexity;
|
||||
pub mod derive;
|
||||
pub mod drop_ref;
|
||||
pub mod entry;
|
||||
pub mod enum_glob_use;
|
||||
pub mod enum_variants;
|
||||
pub mod eq_op;
|
||||
pub mod escape;
|
||||
pub mod eta_reduction;
|
||||
pub mod identity_op;
|
||||
pub mod items_after_statements;
|
||||
pub mod minmax;
|
||||
pub mod mut_mut;
|
||||
pub mod mut_reference;
|
||||
pub mod len_zero;
|
||||
pub mod attrs;
|
||||
pub mod collapsible_if;
|
||||
pub mod block_in_if_condition;
|
||||
pub mod unicode;
|
||||
pub mod shadow;
|
||||
pub mod strings;
|
||||
pub mod methods;
|
||||
pub mod returns;
|
||||
pub mod lifetimes;
|
||||
pub mod loops;
|
||||
pub mod ranges;
|
||||
pub mod map_clone;
|
||||
pub mod matches;
|
||||
pub mod precedence;
|
||||
pub mod methods;
|
||||
pub mod minmax;
|
||||
pub mod misc;
|
||||
pub mod misc_early;
|
||||
pub mod mut_mut;
|
||||
pub mod mut_reference;
|
||||
pub mod mutex_atomic;
|
||||
pub mod zero_div_zero;
|
||||
pub mod open_options;
|
||||
pub mod needless_bool;
|
||||
pub mod needless_features;
|
||||
pub mod needless_update;
|
||||
pub mod no_effect;
|
||||
pub mod open_options;
|
||||
pub mod panic;
|
||||
pub mod precedence;
|
||||
pub mod print;
|
||||
pub mod ptr_arg;
|
||||
pub mod ranges;
|
||||
pub mod regex;
|
||||
pub mod returns;
|
||||
pub mod shadow;
|
||||
pub mod strings;
|
||||
pub mod temporary_assignment;
|
||||
pub mod transmute;
|
||||
pub mod cyclomatic_complexity;
|
||||
pub mod escape;
|
||||
pub mod entry;
|
||||
pub mod misc_early;
|
||||
pub mod array_indexing;
|
||||
pub mod panic;
|
||||
pub mod derive;
|
||||
pub mod print;
|
||||
pub mod types;
|
||||
pub mod unicode;
|
||||
pub mod vec;
|
||||
pub mod drop_ref;
|
||||
pub mod regex;
|
||||
pub mod zero_div_zero;
|
||||
// end lints modules, do not remove this comment, it’s used in `update_lints`
|
||||
|
||||
mod reexport {
|
||||
pub use syntax::ast::{Name, NodeId};
|
||||
|
|
|
@ -60,6 +60,13 @@ def gen_group(lints, levels=None):
|
|||
yield ' %s::%s,\n' % (module, name.upper())
|
||||
|
||||
|
||||
def gen_mods(lints):
|
||||
"""Declare modules"""
|
||||
|
||||
for module in sorted(set(lint[0] for lint in lints)):
|
||||
yield 'pub mod %s;\n' % module
|
||||
|
||||
|
||||
def replace_region(fn, region_start, region_end, callback,
|
||||
replace_start=True, write_back=True):
|
||||
"""Replace a region in a file delimited by two lines matching regexes.
|
||||
|
@ -128,6 +135,12 @@ def main(print_only=False, check=False):
|
|||
lambda: ['There are %d lints included in this crate:\n' % len(lints)],
|
||||
write_back=not check)
|
||||
|
||||
# update the `pub mod` list
|
||||
changed |= replace_region(
|
||||
'src/lib.rs', r'begin lints modules', r'end lints modules',
|
||||
lambda: gen_mods(lints),
|
||||
replace_start=False, write_back=not check)
|
||||
|
||||
# same for "clippy" lint collection
|
||||
changed |= replace_region(
|
||||
'src/lib.rs', r'reg.register_lint_group\("clippy"', r'\]\);',
|
||||
|
|
Loading…
Reference in a new issue