Skip to content

Commit

Permalink
cargo dev fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
phansch committed Apr 23, 2020
1 parent c3acaf3 commit af6dc6c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/format.rs
@@ -1,7 +1,7 @@
use crate::utils::paths;
use crate::utils::{
is_expn_of, is_type_diagnostic_item, last_path_segment, match_def_path, match_function_call, snippet, span_lint_and_then,
walk_ptrs_ty,
is_expn_of, is_type_diagnostic_item, last_path_segment, match_def_path, match_function_call, snippet,
span_lint_and_then, walk_ptrs_ty,
};
use if_chain::if_chain;
use rustc_ast::ast::LitKind;
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/inherent_to_string.rs
Expand Up @@ -4,8 +4,8 @@ use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};

use crate::utils::{
get_trait_def_id, is_type_diagnostic_item, implements_trait, paths, return_ty, span_lint_and_help, trait_ref_of_method,
walk_ptrs_ty,
get_trait_def_id, implements_trait, is_type_diagnostic_item, paths, return_ty, span_lint_and_help,
trait_ref_of_method, walk_ptrs_ty,
};

declare_clippy_lint! {
Expand Down
11 changes: 6 additions & 5 deletions clippy_lints/src/methods/inefficient_to_string.rs
@@ -1,5 +1,7 @@
use super::INEFFICIENT_TO_STRING;
use crate::utils::{match_def_path, is_type_diagnostic_item, paths, snippet_with_applicability, span_lint_and_then, walk_ptrs_ty_depth};
use crate::utils::{
is_type_diagnostic_item, match_def_path, paths, snippet_with_applicability, span_lint_and_then, walk_ptrs_ty_depth,
};
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir as hir;
Expand Down Expand Up @@ -45,16 +47,15 @@ pub fn lint<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &hir::Expr<'_>, arg: &hir::E
/// Currently, these are `str`, `String`, and `Cow<'_, str>`.
fn specializes_tostring(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> bool {
if let ty::Str = ty.kind {
return true
return true;
}

if is_type_diagnostic_item(cx, ty, sym!(string_type)) {
return true
return true;
}

if let ty::Adt(adt, substs) = ty.kind {
match_def_path(cx, adt.did, &paths::COW) &&
substs.type_at(1).is_str()
match_def_path(cx, adt.did, &paths::COW) && substs.type_at(1).is_str()
} else {
false
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/needless_pass_by_value.rs
@@ -1,7 +1,7 @@
use crate::utils::ptr::get_spans;
use crate::utils::{
get_trait_def_id, implements_trait, is_copy, is_self, is_type_diagnostic_item, multispan_sugg, paths,
snippet, snippet_opt, span_lint_and_then,
get_trait_def_id, implements_trait, is_copy, is_self, is_type_diagnostic_item, multispan_sugg, paths, snippet,
snippet_opt, span_lint_and_then,
};
use if_chain::if_chain;
use rustc_ast::ast::Attribute;
Expand Down
7 changes: 4 additions & 3 deletions clippy_lints/src/redundant_clone.rs
@@ -1,6 +1,6 @@
use crate::utils::{
fn_has_unsatisfiable_preds, has_drop, is_copy, is_type_diagnostic_item, match_def_path, match_type, paths, snippet_opt, span_lint_hir,
span_lint_hir_and_then, walk_ptrs_ty_depth,
fn_has_unsatisfiable_preds, has_drop, is_copy, is_type_diagnostic_item, match_def_path, match_type, paths,
snippet_opt, span_lint_hir, span_lint_hir_and_then, walk_ptrs_ty_depth,
};
use if_chain::if_chain;
use rustc_data_structures::{fx::FxHashMap, transitive_relation::TransitiveRelation};
Expand Down Expand Up @@ -113,7 +113,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {

let from_borrow = match_def_path(cx, fn_def_id, &paths::CLONE_TRAIT_METHOD)
|| match_def_path(cx, fn_def_id, &paths::TO_OWNED_METHOD)
|| (match_def_path(cx, fn_def_id, &paths::TO_STRING_METHOD) && is_type_diagnostic_item(cx, arg_ty, sym!(string_type)));
|| (match_def_path(cx, fn_def_id, &paths::TO_STRING_METHOD)
&& is_type_diagnostic_item(cx, arg_ty, sym!(string_type)));

let from_deref = !from_borrow
&& (match_def_path(cx, fn_def_id, &paths::PATH_TO_PATH_BUF)
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/swap.rs
@@ -1,7 +1,7 @@
use crate::utils::sugg::Sugg;
use crate::utils::{
differing_macro_contexts, is_type_diagnostic_item, snippet_with_applicability,
span_lint_and_then, walk_ptrs_ty, SpanlessEq,
differing_macro_contexts, is_type_diagnostic_item, snippet_with_applicability, span_lint_and_then, walk_ptrs_ty,
SpanlessEq,
};
use if_chain::if_chain;
use rustc_errors::Applicability;
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/types.rs
Expand Up @@ -29,10 +29,10 @@ use rustc_typeck::hir_ty_to_ty;
use crate::consts::{constant, Constant};
use crate::utils::paths;
use crate::utils::{
clip, comparisons, differing_macro_contexts, higher, in_constant, int_bits, is_type_diagnostic_item, last_path_segment, match_def_path,
match_path, method_chain_args, multispan_sugg, numeric_literal::NumericLiteral, qpath_res, same_tys, sext, snippet,
snippet_opt, snippet_with_applicability, snippet_with_macro_callsite, span_lint, span_lint_and_help,
span_lint_and_sugg, span_lint_and_then, unsext,
clip, comparisons, differing_macro_contexts, higher, in_constant, int_bits, is_type_diagnostic_item,
last_path_segment, match_def_path, match_path, method_chain_args, multispan_sugg, numeric_literal::NumericLiteral,
qpath_res, same_tys, sext, snippet, snippet_opt, snippet_with_applicability, snippet_with_macro_callsite,
span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then, unsext,
};

declare_clippy_lint! {
Expand Down

0 comments on commit af6dc6c

Please sign in to comment.