diff --git a/src/lib.rs b/src/lib.rs index 7d6876ad839..f4da8b03bc2 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,10 +77,19 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_lint_pass(box matches::MatchPass as LintPassObject); reg.register_lint_pass(box misc::PatternPass as LintPassObject); - reg.register_lint_group("shadow", vec![ + reg.register_lint_group("clippy_pedantic", vec![ + methods::OPTION_UNWRAP_USED, + methods::RESULT_UNWRAP_USED, + ptr_arg::PTR_ARG, shadow::SHADOW_REUSE, shadow::SHADOW_SAME, - shadow::SHADOW_UNRELATED, + strings::STRING_ADD, + strings::STRING_ADD_ASSIGN, + types::CAST_POSSIBLE_TRUNCATION, + types::CAST_POSSIBLE_WRAP, + types::CAST_PRECISION_LOSS, + types::CAST_SIGN_LOSS, + unicode::NON_ASCII_LITERAL, ]); reg.register_lint_group("clippy", vec![ @@ -102,8 +111,6 @@ pub fn plugin_registrar(reg: &mut Registry) { loops::WHILE_LET_LOOP, matches::MATCH_REF_PATS, matches::SINGLE_MATCH, - methods::OPTION_UNWRAP_USED, - methods::RESULT_UNWRAP_USED, methods::SHOULD_IMPLEMENT_TRAIT, methods::STR_TO_STRING, methods::STRING_TO_STRING, @@ -116,25 +123,15 @@ pub fn plugin_registrar(reg: &mut Registry) { mut_mut::MUT_MUT, needless_bool::NEEDLESS_BOOL, precedence::PRECEDENCE, - ptr_arg::PTR_ARG, ranges::RANGE_STEP_BY_ZERO, returns::LET_AND_RETURN, returns::NEEDLESS_RETURN, - shadow::SHADOW_REUSE, - shadow::SHADOW_SAME, shadow::SHADOW_UNRELATED, - strings::STRING_ADD, - strings::STRING_ADD_ASSIGN, types::BOX_VEC, - types::CAST_POSSIBLE_TRUNCATION, - types::CAST_POSSIBLE_WRAP, - types::CAST_PRECISION_LOSS, - types::CAST_SIGN_LOSS, types::LET_UNIT_VALUE, types::LINKEDLIST, types::TYPE_COMPLEXITY, types::UNIT_CMP, - unicode::NON_ASCII_LITERAL, unicode::ZERO_WIDTH_SPACE, ]); } diff --git a/tests/compile-fail/methods.rs b/tests/compile-fail/methods.rs index 05f77c1511e..1c81fefc4e5 100755 --- a/tests/compile-fail/methods.rs +++ b/tests/compile-fail/methods.rs @@ -2,7 +2,7 @@ #![plugin(clippy)] #![allow(unused)] -#![deny(clippy)] +#![deny(clippy, clippy_pedantic)] use std::ops::Mul; diff --git a/tests/compile-fail/shadow.rs b/tests/compile-fail/shadow.rs old mode 100644 new mode 100755 index 7098cb38877..8ac9a93b140 --- a/tests/compile-fail/shadow.rs +++ b/tests/compile-fail/shadow.rs @@ -2,7 +2,7 @@ #![plugin(clippy)] #![allow(unused_parens, unused_variables)] -#![deny(shadow)] +#![deny(clippy, clippy_pedantic)] fn id(x: T) -> T { x } @@ -19,9 +19,9 @@ fn main() { let x = first(x); //~ERROR: x is shadowed by first(x) which reuses let y = 1; let x = y; //~ERROR: x is shadowed by y in this declaration - + let o = Some(1u8); - + if let Some(p) = o { assert_eq!(1, p); } match o { Some(p) => p, // no error, because the p above is in its own scope diff --git a/util/dogfood.sh b/util/dogfood.sh index e98d18c40d5..5ba8b4efa17 100755 --- a/util/dogfood.sh +++ b/util/dogfood.sh @@ -1,5 +1,5 @@ #!/bin/sh rm -rf target*/*so -cargo build --lib && cp -R target target_recur && cargo rustc -- -Zextra-plugins=clippy -Ltarget_recur/debug -Dclippy || exit 1 +cargo build --lib && cp -R target target_recur && cargo rustc -- -Zextra-plugins=clippy -Ltarget_recur/debug -Dclippy_pedantic -Dclippy || exit 1 rm -rf target_recur diff --git a/util/update_lints.py b/util/update_lints.py index 8c00f1b4f13..94b2a3a57ba 100755 --- a/util/update_lints.py +++ b/util/update_lints.py @@ -38,7 +38,7 @@ def gen_table(lints, link=None): """Write lint table in Markdown format.""" if link: lints = [(p, '[%s](%s#%s)' % (l, link, l), lvl, d) - for (p, l, lvl, d) in lints] + for (p, l, lvl, d) in lints] # first and third column widths w_name = max(len(l[1]) for l in lints) w_desc = max(len(l[3]) for l in lints) @@ -50,8 +50,10 @@ def gen_table(lints, link=None): yield '%-*s | %-7s | %s\n' % (w_name, name, default, meaning) -def gen_group(lints): +def gen_group(lints, levels=None): """Write lint group (list of all lints in the form module::NAME).""" + if levels: + lints = [tup for tup in lints if tup[2] in levels] for (module, name, _, _) in sorted(lints): yield ' %s::%s,\n' % (module, name.upper()) @@ -113,19 +115,28 @@ def main(print_only=False, check=False): return # replace table in README.md - changed = replace_region('README.md', r'^name +\|', '^$', - lambda: gen_table(lints, link=wiki_link), - write_back=not check) + changed = replace_region( + 'README.md', r'^name +\|', '^$', + lambda: gen_table(lints, link=wiki_link), + write_back=not check) - changed |= replace_region('README.md', + changed |= replace_region( + 'README.md', r'^There are \d+ lints included in this crate:', "", lambda: ['There are %d lints included in this crate:\n' % len(lints)], write_back=not check) # same for "clippy" lint collection - changed |= replace_region('src/lib.rs', r'reg.register_lint_group\("clippy"', r'\]\);', - lambda: gen_group(lints), replace_start=False, - write_back=not check) + changed |= replace_region( + 'src/lib.rs', r'reg.register_lint_group\("clippy"', r'\]\);', + lambda: gen_group(lints, levels=('warn', 'deny')), + replace_start=False, write_back=not check) + + # same for "clippy_pedantic" lint collection + changed |= replace_region( + 'src/lib.rs', r'reg.register_lint_group\("clippy_pedantic"', r'\]\);', + lambda: gen_group(lints, levels=('allow',)), + replace_start=False, write_back=not check) if check and changed: print('Please run util/update_lints.py to regenerate lints lists.')