]> git.lizzy.rs Git - rust.git/commitdiff
Merge branch 'pr-482'
authorManish Goregaokar <manishsmail@gmail.com>
Mon, 7 Dec 2015 12:23:52 +0000 (07:23 -0500)
committerManish Goregaokar <manishsmail@gmail.com>
Mon, 7 Dec 2015 12:23:52 +0000 (07:23 -0500)
1  2 
README.md
src/lib.rs
src/misc_early.rs
src/utils.rs

diff --cc README.md
index e19ab474c5e35b017e5cf4445df11d7f461f392b,af4c3e80437cf98ad84db4e99d8b8c8283585be6..7e8c60e78e5ad3195f411f59367c5536a8dc70db
+++ b/README.md
@@@ -81,6 -81,7 +81,7 @@@ nam
  [unicode_not_nfc](https://github.com/Manishearth/rust-clippy/wiki#unicode_not_nfc)                       | allow   | using a unicode literal not in NFC normal form (see http://www.unicode.org/reports/tr15/ for further information)
  [unit_cmp](https://github.com/Manishearth/rust-clippy/wiki#unit_cmp)                                     | warn    | comparing unit values (which is always `true` or `false`, respectively)
  [unnecessary_mut_passed](https://github.com/Manishearth/rust-clippy/wiki#unnecessary_mut_passed)         | warn    | an argument is passed as a mutable reference although the function/method only demands an immutable reference
 -[unneeded_binding](https://github.com/Manishearth/rust-clippy/wiki#unneeded_binding)                     | warn    | Type fields are bound when not necessary
++[unneeded_field_pattern](https://github.com/Manishearth/rust-clippy/wiki#unneeded_field_pattern)         | warn    | Struct fields are bound to a wildcard instead of using `..`
  [unstable_as_mut_slice](https://github.com/Manishearth/rust-clippy/wiki#unstable_as_mut_slice)           | warn    | as_mut_slice is not stable and can be replaced by &mut v[..]see https://github.com/rust-lang/rust/issues/27729
  [unstable_as_slice](https://github.com/Manishearth/rust-clippy/wiki#unstable_as_slice)                   | warn    | as_slice is not stable and can be replaced by & v[..]see https://github.com/rust-lang/rust/issues/27729
  [unused_collect](https://github.com/Manishearth/rust-clippy/wiki#unused_collect)                         | warn    | `collect()`ing an iterator without using the result; this is usually better written as a for loop
diff --cc src/lib.rs
index 9ead05b93b2f05c33a63960dba3bb6ed9d1d345d,abb3f0425df0dd0798e695e2c9dcbfb146ccfc36..64dfc24d1efa431442b48167f419c81a48020b2b
@@@ -181,6 -183,7 +183,7 @@@ pub fn plugin_registrar(reg: &mut Regis
          misc::MODULO_ONE,
          misc::REDUNDANT_PATTERN,
          misc::TOPLEVEL_REF_ARG,
 -        misc_early::UNNEEDED_BINDING,
++        misc_early::UNNEEDED_FIELD_PATTERN,
          mut_reference::UNNECESSARY_MUT_PASSED,
          mutex_atomic::MUTEX_ATOMIC,
          needless_bool::NEEDLESS_BOOL,
index 0000000000000000000000000000000000000000,5bec753d3ebd36cd5f7f527f965bb897df012872..8adff7523371cd9e1504f1cf59537a29bc42ad56
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,48 +1,48 @@@
 -declare_lint!(pub UNNEEDED_BINDING, Warn,
 -              "Type fields are bound when not necessary");
+ //use rustc_front::hir::*;
+ use rustc::lint::*;
+ use syntax::ast::*;
+ use utils::span_lint;
 -        lint_array!(UNNEEDED_BINDING)
++declare_lint!(pub UNNEEDED_FIELD_PATTERN, Warn,
++              "Struct fields are bound to a wildcard instead of using `..`");
+ #[derive(Copy, Clone)]
+ pub struct MiscEarly;
+ impl LintPass for MiscEarly {
+     fn get_lints(&self) -> LintArray {
 -                span_lint(cx, UNNEEDED_BINDING, pat.span,
++        lint_array!(UNNEEDED_FIELD_PATTERN)
+     }
+ }
+ impl EarlyLintPass for MiscEarly {
+     fn check_pat(&mut self, cx: &EarlyContext, pat: &Pat) {
+         if let PatStruct(_, ref pfields, _) = pat.node {
+             let mut wilds = 0;
+             for field in pfields {
+                 if field.node.pat.node == PatWild {
+                     wilds += 1;
+                 }
+             }
+             if !pfields.is_empty() && wilds == pfields.len() {
 -                        span_lint(cx, UNNEEDED_BINDING, field.span,
++                span_lint(cx, UNNEEDED_FIELD_PATTERN, pat.span,
+                           "All the struct fields are matched to a wildcard pattern, \
+                            consider using `..`.");
+                 return;
+             }
+             if wilds > 0 {
+                 for field in pfields {
+                     if field.node.pat.node == PatWild {
++                        span_lint(cx, UNNEEDED_FIELD_PATTERN, field.span,
+                                   "You matched a field with a wildcard pattern. \
+                                    Consider using `..` instead");
+                     }
+                 }
+             }
+         }
+     }
+ }
diff --cc src/utils.rs
Simple merge