]> git.lizzy.rs Git - rust.git/commitdiff
Build the import lint in update_lints.py
authormcarton <cartonmartin+git@gmail.com>
Sat, 20 Feb 2016 16:00:36 +0000 (17:00 +0100)
committermcarton <cartonmartin+git@gmail.com>
Sat, 20 Feb 2016 16:46:16 +0000 (17:46 +0100)
src/lib.rs
util/update_lints.py

index 106d63aa0daf3bae2dc5a4c69771ddbf22caf423..23accd2ebaace30dc52c43f3b326309daf5019cd 100644 (file)
@@ -35,59 +35,62 @@ fn main() {
 
 use rustc_plugin::Registry;
 
+pub mod consts;
 #[macro_use]
 pub mod utils;
+
+// begin lints modules, do not remove this comment, it’s used in `update_lints`
+pub mod approx_const;
+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 consts;
-pub mod types;
-pub mod misc;
+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 bit_mask;
-pub mod ptr_arg;
-pub mod needless_bool;
-pub mod approx_const;
+pub mod escape;
 pub mod eta_reduction;
-pub mod enum_variants;
 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 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 open_options;
 pub mod panic;
-pub mod derive;
+pub mod precedence;
 pub mod print;
-pub mod vec;
-pub mod drop_ref;
+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 types;
+pub mod unicode;
+pub mod vec;
+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};
index 9f105a2699cc95d86f71333a182a14c19f8e8541..2eaa6ab62116d8a279fb336310f4aa798132f129 100755 (executable)
@@ -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'\]\);',