Add clippy_utils::paths imports
This commit is contained in:
parent
0743e841f0
commit
565400d1f9
@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::source::snippet_opt;
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use clippy_utils::{eq_expr_value, get_trait_def_id, trait_ref_of_method};
|
||||
use clippy_utils::{higher, sugg};
|
||||
use clippy_utils::{higher, paths, sugg};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
@ -93,7 +93,7 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps {
|
||||
$($trait_name:ident),+) => {
|
||||
match $op {
|
||||
$(hir::BinOpKind::$trait_name => {
|
||||
let [krate, module] = clippy_utils::paths::OPS_MODULE;
|
||||
let [krate, module] = paths::OPS_MODULE;
|
||||
let path: [&str; 3] = [krate, module, concat!(stringify!($trait_name), "Assign")];
|
||||
let trait_id = if let Some(trait_id) = get_trait_def_id($cx, &path) {
|
||||
trait_id
|
||||
|
@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use clippy_utils::usage::contains_return_break_continue_macro;
|
||||
use clippy_utils::{in_constant, match_qpath, path_to_local_id, sugg};
|
||||
use clippy_utils::{in_constant, match_qpath, path_to_local_id, paths, sugg};
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Arm, Expr, ExprKind, Pat, PatKind};
|
||||
@ -75,16 +75,16 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
if let Some((idx, or_arm)) = arms.iter().enumerate().find(|(_, arm)|
|
||||
match arm.pat.kind {
|
||||
PatKind::Path(ref some_qpath) =>
|
||||
match_qpath(some_qpath, &clippy_utils::paths::OPTION_NONE),
|
||||
match_qpath(some_qpath, &paths::OPTION_NONE),
|
||||
PatKind::TupleStruct(ref err_qpath, &[Pat { kind: PatKind::Wild, .. }], _) =>
|
||||
match_qpath(err_qpath, &clippy_utils::paths::RESULT_ERR),
|
||||
match_qpath(err_qpath, &paths::RESULT_ERR),
|
||||
_ => false,
|
||||
}
|
||||
);
|
||||
let unwrap_arm = &arms[1 - idx];
|
||||
if let PatKind::TupleStruct(ref unwrap_qpath, &[unwrap_pat], _) = unwrap_arm.pat.kind;
|
||||
if match_qpath(unwrap_qpath, &clippy_utils::paths::OPTION_SOME)
|
||||
|| match_qpath(unwrap_qpath, &clippy_utils::paths::RESULT_OK);
|
||||
if match_qpath(unwrap_qpath, &paths::OPTION_SOME)
|
||||
|| match_qpath(unwrap_qpath, &paths::RESULT_OK);
|
||||
if let PatKind::Binding(_, binding_hir_id, ..) = unwrap_pat.kind;
|
||||
if path_to_local_id(unwrap_arm.body, binding_hir_id);
|
||||
if !contains_return_break_continue_macro(or_arm.body);
|
||||
|
@ -1,5 +1,5 @@
|
||||
use clippy_utils::diagnostics::span_lint;
|
||||
use clippy_utils::{get_trait_def_id, trait_ref_of_method};
|
||||
use clippy_utils::{get_trait_def_id, paths, trait_ref_of_method};
|
||||
use if_chain::if_chain;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||
@ -159,7 +159,7 @@ fn check_binop(
|
||||
expected_ops: &[hir::BinOpKind],
|
||||
) -> Option<&'static str> {
|
||||
let mut trait_ids = vec![];
|
||||
let [krate, module] = clippy_utils::paths::OPS_MODULE;
|
||||
let [krate, module] = paths::OPS_MODULE;
|
||||
|
||||
for &t in traits {
|
||||
let path = [krate, module, t];
|
||||
|
Loading…
x
Reference in New Issue
Block a user