]> git.lizzy.rs Git - rust.git/commitdiff
Rename `match_path_old` to `match_path`
authorAlexey Zabelin <hello@alexeyzabelin.com>
Thu, 24 Aug 2017 22:21:46 +0000 (18:21 -0400)
committerAlexey Zabelin <hello@alexeyzabelin.com>
Fri, 25 Aug 2017 00:42:50 +0000 (20:42 -0400)
The old `match_path` was renamed to `match_qpath`.

As per #1983.

13 files changed:
clippy_lints/src/derive.rs
clippy_lints/src/if_let_redundant_pattern_matching.rs
clippy_lints/src/map_clone.rs
clippy_lints/src/methods.rs
clippy_lints/src/misc.rs
clippy_lints/src/print.rs
clippy_lints/src/ptr.rs
clippy_lints/src/unused_io_amount.rs
clippy_lints/src/utils/author.rs
clippy_lints/src/utils/higher.rs
clippy_lints/src/utils/internal_lints.rs
clippy_lints/src/utils/mod.rs
tests/ui/trailing_zeros.stdout

index e186dd5e4db748704af702720ff87d224c5e0041..36576365eac8b6cb2dcd0edd9fe07fcdd3aeadf0 100644 (file)
@@ -3,7 +3,7 @@
 use rustc::hir::*;
 use syntax::codemap::Span;
 use utils::paths;
-use utils::{is_automatically_derived, span_lint_and_then, match_path_old, is_copy};
+use utils::{is_automatically_derived, span_lint_and_then, match_path, is_copy};
 
 /// **What it does:** Checks for deriving `Hash` but implementing `PartialEq`
 /// explicitly.
@@ -92,7 +92,7 @@ fn check_hash_peq<'a, 'tcx>(
     hash_is_automatically_derived: bool,
 ) {
     if_let_chain! {[
-        match_path_old(&trait_ref.path, &paths::HASH),
+        match_path(&trait_ref.path, &paths::HASH),
         let Some(peq_trait_def_id) = cx.tcx.lang_items.eq_trait()
     ], {
         // Look for the PartialEq implementations for `ty`
@@ -132,7 +132,7 @@ fn check_hash_peq<'a, 'tcx>(
 
 /// Implementation of the `EXPL_IMPL_CLONE_ON_COPY` lint.
 fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref: &TraitRef, ty: Ty<'tcx>) {
-    if match_path_old(&trait_ref.path, &paths::CLONE_TRAIT) {
+    if match_path(&trait_ref.path, &paths::CLONE_TRAIT) {
         if !is_copy(cx, ty) {
             return;
         }
index 058052769ef6108a784451a5e2d30abe3a713dbf..0e1dd6449ab4114fac43c0d0129bb325d1a037f8 100644 (file)
@@ -1,7 +1,7 @@
 use rustc::lint::*;
 use rustc::hir::*;
 use syntax::codemap::Span;
-use utils::{paths, span_lint_and_then, match_path, snippet};
+use utils::{paths, span_lint_and_then, match_qpath, snippet};
 
 /// **What it does:*** Lint for redundant pattern matching over `Result` or
 /// `Option`
@@ -53,18 +53,18 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
 
                 let good_method = match arms[0].pats[0].node {
                     PatKind::TupleStruct(ref path, ref pats, _) if pats.len() == 1 && pats[0].node == PatKind::Wild => {
-                        if match_path(path, &paths::RESULT_OK) {
+                        if match_qpath(path, &paths::RESULT_OK) {
                             "is_ok()"
-                        } else if match_path(path, &paths::RESULT_ERR) {
+                        } else if match_qpath(path, &paths::RESULT_ERR) {
                             "is_err()"
-                        } else if match_path(path, &paths::OPTION_SOME) {
+                        } else if match_qpath(path, &paths::OPTION_SOME) {
                             "is_some()"
                         } else {
                             return;
                         }
                     },
 
-                    PatKind::Path(ref path) if match_path(path, &paths::OPTION_NONE) => "is_none()",
+                    PatKind::Path(ref path) if match_qpath(path, &paths::OPTION_NONE) => "is_none()",
 
                     _ => return,
                 };
index 457c6cc8d65ef77f25bdbbabf583632339fa3242..fcb84e90eb603a1b3e3017cf39697074d5aad2e1 100644 (file)
@@ -2,7 +2,7 @@
 use rustc::hir::*;
 use rustc::ty;
 use syntax::ast;
-use utils::{is_adjusted, match_path, match_trait_method, match_type, remove_blocks, paths, snippet,
+use utils::{is_adjusted, match_qpath, match_trait_method, match_type, remove_blocks, paths, snippet,
             span_help_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth, iter_input_pats};
 
 /// **What it does:** Checks for mapping `clone()` over an iterator.
@@ -74,7 +74,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
                         }}
                     },
                     ExprPath(ref path) => {
-                        if match_path(path, &paths::CLONE) {
+                        if match_qpath(path, &paths::CLONE) {
                             let type_name = get_type_name(cx, expr, &args[0]).unwrap_or("_");
                             span_help_and_lint(
                                 cx,
index a50d77f5521fedf473265e9bff749d96b7ebe215..1811142ae2775ef9ab5cb84bdb5eb6cf2745136f 100644 (file)
@@ -8,10 +8,10 @@
 use std::borrow::Cow;
 use std::fmt;
 use syntax::codemap::Span;
-use utils::{get_trait_def_id, implements_trait, in_external_macro, in_macro, is_copy, match_path, match_trait_method,
+use utils::{get_trait_def_id, implements_trait, in_external_macro, in_macro, is_copy, match_qpath, match_trait_method,
             match_type, method_chain_args, return_ty, same_tys, snippet, span_lint, span_lint_and_then,
             span_lint_and_sugg, span_note_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth, last_path_segment,
-            single_segment_path, match_def_path, is_self, is_self_ty, iter_input_pats, match_path_old};
+            single_segment_path, match_def_path, is_self, is_self_ty, iter_input_pats, match_path};
 use utils::paths;
 use utils::sugg;
 
@@ -1462,7 +1462,7 @@ fn is_as_ref_or_mut_trait(ty: &hir::Ty, self_ty: &hir::Ty, generics: &hir::Gener
                 param.bounds.iter().any(|bound| {
                     if let hir::TyParamBound::TraitTyParamBound(ref ptr, ..) = *bound {
                         let path = &ptr.trait_ref.path;
-                        match_path_old(path, name) &&
+                        match_path(path, name) &&
                             path.segments.last().map_or(false, |s| {
                                 if let hir::PathParameters::AngleBracketedParameters(ref data) = s.parameters {
                                     data.types.len() == 1 &&
@@ -1540,7 +1540,7 @@ fn matches(&self, ty: &hir::FunctionRetTy) -> bool {
 
 fn is_bool(ty: &hir::Ty) -> bool {
     if let hir::TyPath(ref p) = ty.node {
-        match_path(p, &["bool"])
+        match_qpath(p, &["bool"])
     } else {
         false
     }
index ef42bfe0b0284b1d6b1c3188b15f2fcb003869a9..43c539a7a6515bd71cde3deaa6e903ecff8c7c37 100644 (file)
@@ -8,7 +8,7 @@
 use rustc_const_eval::ConstContext;
 use rustc_const_math::ConstFloat;
 use syntax::codemap::{Span, ExpnFormat};
-use utils::{get_item_name, get_parent_expr, implements_trait, in_macro, is_integer_literal, match_path, snippet,
+use utils::{get_item_name, get_parent_expr, implements_trait, in_macro, is_integer_literal, match_qpath, snippet,
             span_lint, span_lint_and_then, walk_ptrs_ty, last_path_segment, iter_input_pats, in_constant,
             match_trait_method, paths};
 use utils::sugg::Sugg;
@@ -486,7 +486,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr) {
         },
         ExprCall(ref path, ref v) if v.len() == 1 => {
             if let ExprPath(ref path) = path.node {
-                if match_path(path, &["String", "from_str"]) || match_path(path, &["String", "from"]) {
+                if match_qpath(path, &["String", "from_str"]) || match_qpath(path, &["String", "from"]) {
                     (cx.tables.expr_ty_adjusted(&v[0]), snippet(cx, v[0].span, ".."))
                 } else {
                     return;
index 4a427fc79bd4dd12235860bb2fa53be9b8032a2a..982b46e20d3d0ca286cbbdc46b6a6f4e77c7da3a 100644 (file)
@@ -2,7 +2,7 @@
 use rustc::hir::map::Node::{NodeItem, NodeImplItem};
 use rustc::lint::*;
 use utils::paths;
-use utils::{is_expn_of, match_def_path, resolve_node, span_lint, match_path_old};
+use utils::{is_expn_of, match_def_path, resolve_node, span_lint, match_path};
 use format::get_argument_fmtstr_parts;
 
 /// **What it does:** This lint warns when you using `print!()` with a format
@@ -144,7 +144,7 @@ fn is_in_debug_impl(cx: &LateContext, expr: &Expr) -> bool {
         // `Debug` impl
         if let Some(NodeItem(item)) = map.find(map.get_parent(item.id)) {
             if let ItemImpl(_, _, _, _, Some(ref tr), _, _) = item.node {
-                return match_path_old(&tr.path, &["Debug"]);
+                return match_path(&tr.path, &["Debug"]);
             }
         }
     }
index 5b5c63c1aca8053353b0ffb546dbb60ba48a88b0..a21142a257d7ec7a676e0d3184d0ca865e4fc2c4 100644 (file)
@@ -7,7 +7,7 @@
 use syntax::ast::NodeId;
 use syntax::codemap::Span;
 use syntax_pos::MultiSpan;
-use utils::{match_path, match_type, paths, span_lint, span_lint_and_then};
+use utils::{match_qpath, match_type, paths, span_lint, span_lint_and_then};
 
 /// **What it does:** This lint checks for function arguments of type `&String`
 /// or `&Vec` unless
@@ -190,7 +190,7 @@ fn is_null_path(expr: &Expr) -> bool {
     if let ExprCall(ref pathexp, ref args) = expr.node {
         if args.is_empty() {
             if let ExprPath(ref path) = pathexp.node {
-                return match_path(path, &paths::PTR_NULL) || match_path(path, &paths::PTR_NULL_MUT);
+                return match_qpath(path, &paths::PTR_NULL) || match_qpath(path, &paths::PTR_NULL_MUT);
             }
         }
     }
index ff2148c88a9195301b7fb32bb5d28d0617080dfb..1ac775ce7c19730213c56581d0b799fa25798a45 100644 (file)
@@ -1,6 +1,6 @@
 use rustc::lint::*;
 use rustc::hir;
-use utils::{span_lint, match_path, match_trait_method, is_try, paths};
+use utils::{span_lint, match_qpath, match_trait_method, is_try, paths};
 
 /// **What it does:** Checks for unused written/read amount.
 ///
@@ -49,7 +49,7 @@ fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
             hir::ExprMatch(ref res, _, _) if is_try(expr).is_some() => {
                 if let hir::ExprCall(ref func, ref args) = res.node {
                     if let hir::ExprPath(ref path) = func.node {
-                        if match_path(path, &paths::TRY_INTO_RESULT) && args.len() == 1 {
+                        if match_qpath(path, &paths::TRY_INTO_RESULT) && args.len() == 1 {
                             check_method_call(cx, &args[0], expr);
                         }
                     }
index a7fdc3d281baa8621d7692b9cbf9f7076c9cfcff..ba8f0022b32b237f143b68b04ccad685fa15c1c5 100644 (file)
@@ -428,7 +428,7 @@ fn visit_expr(&mut self, expr: &Expr) {
     }
 
     fn visit_qpath(&mut self, path: &QPath, _: NodeId, _: Span) {
-        print!("    match_path({}, &[", self.current);
+        print!("    match_qpath({}, &[", self.current);
         print_path(path, &mut true);
         println!("]),");
     }
index 67319f0c35512cbe2665594f1a9d5466df39424f..aa57e12bca88e9be517bf919ff03214b3f7f682a 100644 (file)
@@ -6,7 +6,7 @@
 use rustc::hir;
 use rustc::lint::LateContext;
 use syntax::ast;
-use utils::{is_expn_of, match_path, match_def_path, resolve_node, paths};
+use utils::{is_expn_of, match_qpath, match_def_path, resolve_node, paths};
 
 /// Convert a hir binary operator to the corresponding `ast` type.
 pub fn binop(op: hir::BinOp_) -> ast::BinOpKind {
@@ -63,7 +63,7 @@ fn get_field<'a>(name: &str, fields: &'a [hir::Field]) -> Option<&'a hir::Expr>
 
     match expr.node {
         hir::ExprPath(ref path) => {
-            if match_path(path, &paths::RANGE_FULL_STD) || match_path(path, &paths::RANGE_FULL) {
+            if match_qpath(path, &paths::RANGE_FULL_STD) || match_qpath(path, &paths::RANGE_FULL) {
                 Some(Range {
                     start: None,
                     end: None,
@@ -74,31 +74,31 @@ fn get_field<'a>(name: &str, fields: &'a [hir::Field]) -> Option<&'a hir::Expr>
             }
         },
         hir::ExprStruct(ref path, ref fields, None) => {
-            if match_path(path, &paths::RANGE_FROM_STD) || match_path(path, &paths::RANGE_FROM) {
+            if match_qpath(path, &paths::RANGE_FROM_STD) || match_qpath(path, &paths::RANGE_FROM) {
                 Some(Range {
                     start: get_field("start", fields),
                     end: None,
                     limits: ast::RangeLimits::HalfOpen,
                 })
-            } else if match_path(path, &paths::RANGE_INCLUSIVE_STD) || match_path(path, &paths::RANGE_INCLUSIVE) {
+            } else if match_qpath(path, &paths::RANGE_INCLUSIVE_STD) || match_qpath(path, &paths::RANGE_INCLUSIVE) {
                 Some(Range {
                     start: get_field("start", fields),
                     end: get_field("end", fields),
                     limits: ast::RangeLimits::Closed,
                 })
-            } else if match_path(path, &paths::RANGE_STD) || match_path(path, &paths::RANGE) {
+            } else if match_qpath(path, &paths::RANGE_STD) || match_qpath(path, &paths::RANGE) {
                 Some(Range {
                     start: get_field("start", fields),
                     end: get_field("end", fields),
                     limits: ast::RangeLimits::HalfOpen,
                 })
-            } else if match_path(path, &paths::RANGE_TO_INCLUSIVE_STD) || match_path(path, &paths::RANGE_TO_INCLUSIVE) {
+            } else if match_qpath(path, &paths::RANGE_TO_INCLUSIVE_STD) || match_qpath(path, &paths::RANGE_TO_INCLUSIVE) {
                 Some(Range {
                     start: None,
                     end: get_field("end", fields),
                     limits: ast::RangeLimits::Closed,
                 })
-            } else if match_path(path, &paths::RANGE_TO_STD) || match_path(path, &paths::RANGE_TO) {
+            } else if match_qpath(path, &paths::RANGE_TO_STD) || match_qpath(path, &paths::RANGE_TO) {
                 Some(Range {
                     start: None,
                     end: get_field("end", fields),
index f81aff24338da3b736e35c67f762999a6e0c9dde..d83e094212a21792f989a2547959651e1c495aab 100644 (file)
@@ -1,7 +1,7 @@
 use rustc::lint::*;
 use rustc::hir::*;
 use rustc::hir::intravisit::{Visitor, walk_expr, NestedVisitorMap};
-use utils::{paths, match_path, span_lint};
+use utils::{paths, match_qpath, span_lint};
 use syntax::symbol::InternedString;
 use syntax::ast::{Name, NodeId, ItemKind, Crate as AstCrate};
 use syntax::codemap::Span;
@@ -167,7 +167,7 @@ fn is_lint_ref_type(ty: &Ty) -> bool {
             return false;
         }
         if let TyPath(ref path) = inner.node {
-            return match_path(path, &paths::LINT);
+            return match_qpath(path, &paths::LINT);
         }
     }
     false
@@ -176,7 +176,7 @@ fn is_lint_ref_type(ty: &Ty) -> bool {
 
 fn is_lint_array_type(ty: &Ty) -> bool {
     if let TyPath(ref path) = ty.node {
-        match_path(path, &paths::LINT_ARRAY)
+        match_qpath(path, &paths::LINT_ARRAY)
     } else {
         false
     }
index c24ccd5d57342612796059583739212fee0b5287..c08f7d4254fe9f5c51e0ddd3e437fc95b80da7d7 100644 (file)
@@ -240,15 +240,15 @@ pub fn single_segment_path(path: &QPath) -> Option<&PathSegment> {
 ///
 /// # Examples
 /// ```rust,ignore
-/// match_path(path, &["std", "rt", "begin_unwind"])
+/// match_qpath(path, &["std", "rt", "begin_unwind"])
 /// ```
-pub fn match_path(path: &QPath, segments: &[&str]) -> bool {
+pub fn match_qpath(path: &QPath, segments: &[&str]) -> bool {
     match *path {
-        QPath::Resolved(_, ref path) => match_path_old(path, segments),
+        QPath::Resolved(_, ref path) => match_path(path, segments),
         QPath::TypeRelative(ref ty, ref segment) => {
             match ty.node {
                 TyPath(ref inner_path) => {
-                    !segments.is_empty() && match_path(inner_path, &segments[..(segments.len() - 1)]) &&
+                    !segments.is_empty() && match_qpath(inner_path, &segments[..(segments.len() - 1)]) &&
                         segment.name == segments[segments.len() - 1]
                 },
                 _ => false,
@@ -257,7 +257,7 @@ pub fn match_path(path: &QPath, segments: &[&str]) -> bool {
     }
 }
 
-pub fn match_path_old(path: &Path, segments: &[&str]) -> bool {
+pub fn match_path(path: &Path, segments: &[&str]) -> bool {
     path.segments.iter().rev().zip(segments.iter().rev()).all(
         |(a, b)| a.name == *b,
     )
@@ -267,7 +267,7 @@ pub fn match_path_old(path: &Path, segments: &[&str]) -> bool {
 ///
 /// # Examples
 /// ```rust,ignore
-/// match_path(path, &["std", "rt", "begin_unwind"])
+/// match_qpath(path, &["std", "rt", "begin_unwind"])
 /// ```
 pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
     path.segments.iter().rev().zip(segments.iter().rev()).all(
@@ -988,7 +988,7 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> {
     fn is_ok(arm: &Arm) -> bool {
         if_let_chain! {[
             let PatKind::TupleStruct(ref path, ref pat, None) = arm.pats[0].node,
-            match_path(path, &paths::RESULT_OK[1..]),
+            match_qpath(path, &paths::RESULT_OK[1..]),
             let PatKind::Binding(_, defid, _, None) = pat[0].node,
             let ExprPath(QPath::Resolved(None, ref path)) = arm.body.node,
             path.def.def_id() == defid,
@@ -1000,7 +1000,7 @@ fn is_ok(arm: &Arm) -> bool {
 
     fn is_err(arm: &Arm) -> bool {
         if let PatKind::TupleStruct(ref path, _, _) = arm.pats[0].node {
-            match_path(path, &paths::RESULT_ERR[1..])
+            match_qpath(path, &paths::RESULT_ERR[1..])
         } else {
             false
         }
index 98025316da4d22cf69be068693486b5382d8fa6f..52ec01260bebf9f21a5134a88b6d5da278d2b825 100644 (file)
@@ -4,7 +4,7 @@ if_let_chain!{[
     let Expr_::ExprBinary(ref op1, ref left1, ref right1) = left.node,
     BinOp_::BiBitAnd == op1.node,
     let Expr_::ExprPath(ref path) = left1.node,
-    match_path(path, &["x"]),
+    match_qpath(path, &["x"]),
     let Expr_::ExprLit(ref lit) = right1.node,
     let LitKind::Int(15, _) = lit.node,
     let Expr_::ExprLit(ref lit1) = right.node,