diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-05-18 00:58:25 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-05-18 00:58:25 +0200 |
| commit | 462df721008210c45993c440c501ccd9576c2fb2 (patch) | |
| tree | c5bbfbee88ada2f04f56b16aef0297b28c598ab5 | |
| parent | 568a3ecfc3eebe099c1ffe44c3d9afdc5d445fd2 (diff) | |
| download | rust-462df721008210c45993c440c501ccd9576c2fb2.tar.gz rust-462df721008210c45993c440c501ccd9576c2fb2.zip | |
Dogfood and rustfmt
| -rw-r--r-- | clippy_lints/src/booleans.rs | 5 | ||||
| -rw-r--r-- | clippy_lints/src/len_zero.rs | 3 | ||||
| -rw-r--r-- | clippy_lints/src/methods/mod.rs | 32 | ||||
| -rw-r--r-- | clippy_lints/src/misc.rs | 3 | ||||
| -rw-r--r-- | clippy_lints/src/ptr.rs | 7 | ||||
| -rw-r--r-- | clippy_lints/src/ranges.rs | 3 | ||||
| -rw-r--r-- | clippy_lints/src/redundant_clone.rs | 3 | ||||
| -rw-r--r-- | clippy_lints/src/replace_consts.rs | 2 | ||||
| -rw-r--r-- | clippy_lints/src/utils/higher.rs | 6 | ||||
| -rw-r--r-- | clippy_lints/src/utils/mod.rs | 4 | ||||
| -rw-r--r-- | clippy_lints/src/utils/sym.rs | 1 |
11 files changed, 20 insertions, 49 deletions
diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 9a3f1075520..57390f84c82 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -50,10 +50,7 @@ declare_clippy_lint! { } // For each pairs, both orders are considered. -const METHODS_WITH_NEGATION: [(&str, &str); 2] = [ - ("is_some", "is_none"), - ("is_err", "is_ok"), -]; +const METHODS_WITH_NEGATION: [(&str, &str); 2] = [("is_some", "is_none"), ("is_err", "is_ok")]; declare_lint_pass!(NonminimalBool => [NONMINIMAL_BOOL, LOGIC_BUG]); diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index ccf899ca73c..624e5eabff0 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -139,8 +139,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item, trait_items } } - if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) - { + if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) { let mut current_and_super_traits = FxHashSet::default(); let visited_trait_def_id = cx.tcx.hir().local_def_id_from_hir_id(visited_trait.hir_id); fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx); diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index c97a60bb853..44cc537844a 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1111,8 +1111,7 @@ fn lint_or_fun_call<'a, 'tcx: 'a>( if ["default", "new"].contains(&path) { let arg_ty = cx.tables.expr_ty(arg); - let default_trait_id = if let Some(default_trait_id) = get_trait_def_id(cx, &paths::DEFAULT_TRAIT) - { + let default_trait_id = if let Some(default_trait_id) = get_trait_def_id(cx, &paths::DEFAULT_TRAIT) { default_trait_id } else { return false; @@ -2254,33 +2253,15 @@ fn lint_chars_cmp_with_unwrap<'a, 'tcx>( /// Checks for the `CHARS_NEXT_CMP` lint with `unwrap()`. fn lint_chars_next_cmp_with_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, info: &BinaryExprInfo<'_>) -> bool { - lint_chars_cmp_with_unwrap( - cx, - info, - &["chars", "next", "unwrap"], - CHARS_NEXT_CMP, - "starts_with", - ) + lint_chars_cmp_with_unwrap(cx, info, &["chars", "next", "unwrap"], CHARS_NEXT_CMP, "starts_with") } /// Checks for the `CHARS_LAST_CMP` lint with `unwrap()`. fn lint_chars_last_cmp_with_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, info: &BinaryExprInfo<'_>) -> bool { - if lint_chars_cmp_with_unwrap( - cx, - info, - &["chars", "last", "unwrap"], - CHARS_LAST_CMP, - "ends_with", - ) { + if lint_chars_cmp_with_unwrap(cx, info, &["chars", "last", "unwrap"], CHARS_LAST_CMP, "ends_with") { true } else { - lint_chars_cmp_with_unwrap( - cx, - info, - &["chars", "next_back", "unwrap"], - CHARS_LAST_CMP, - "ends_with", - ) + lint_chars_cmp_with_unwrap(cx, info, &["chars", "next_back", "unwrap"], CHARS_LAST_CMP, "ends_with") } } @@ -2344,7 +2325,10 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re } } -fn ty_has_iter_method(cx: &LateContext<'_, '_>, self_ref_ty: Ty<'_>) -> Option<(&'static Lint, &'static str, &'static str)> { +fn ty_has_iter_method( + cx: &LateContext<'_, '_>, + self_ref_ty: Ty<'_>, +) -> Option<(&'static Lint, &'static str, &'static str)> { if let Some(ty_name) = has_iter_method(cx, self_ref_ty) { let lint = if ty_name == "array" || ty_name == "PathBuf" { INTO_ITER_ON_ARRAY diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 72680d3a6f4..b1942e9498f 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -504,8 +504,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { }, ExprKind::Call(ref path, ref v) if v.len() == 1 => { if let ExprKind::Path(ref path) = path.node { - if match_qpath(path, &["String", "from_str"]) || match_qpath(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; diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index e3ea27d0f50..af69d62ddb7 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -193,12 +193,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id: ); } } else if match_type(cx, ty, &paths::STRING) { - if let Some(spans) = get_spans( - cx, - opt_body_id, - idx, - &[("clone", ".to_string()"), ("as_str", "")], - ) { + if let Some(spans) = get_spans(cx, opt_body_id, idx, &[("clone", ".to_string()"), ("as_str", "")]) { span_lint_and_then( cx, PTR_ARG, diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index cd4e27110b3..a37ac3a1139 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -212,8 +212,7 @@ fn has_step_by(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { // can't be called on a borrowed range. let ty = cx.tables.expr_ty_adjusted(expr); - get_trait_def_id(cx, &paths::ITERATOR) - .map_or(false, |iterator_trait| implements_trait(cx, ty, iterator_trait, &[])) + get_trait_def_id(cx, &paths::ITERATOR).map_or(false, |iterator_trait| implements_trait(cx, ty, iterator_trait, &[])) } fn y_plus_one(expr: &Expr) -> Option<&Expr> { diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 80b9a94d7e4..db275ef9e58 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -96,8 +96,7 @@ 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) - && match_type(cx, arg_ty, &paths::STRING)); + || (match_def_path(cx, fn_def_id, &paths::TO_STRING_METHOD) && match_type(cx, arg_ty, &paths::STRING)); let from_deref = !from_borrow && (match_def_path(cx, fn_def_id, &paths::PATH_TO_PATH_BUF) diff --git a/clippy_lints/src/replace_consts.rs b/clippy_lints/src/replace_consts.rs index 7f1303d5bee..81d7f7d58e7 100644 --- a/clippy_lints/src/replace_consts.rs +++ b/clippy_lints/src/replace_consts.rs @@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ReplaceConsts { } } -const REPLACEMENTS: [([&str; 3], &'static str); 25] = [ +const REPLACEMENTS: [([&str; 3], &str); 25] = [ // Once (["core", "sync", "ONCE_INIT"], "Once::new()"), // Min diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 7c655277a60..6ba2f91eb03 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -100,8 +100,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O }, hir::ExprKind::Call(ref path, ref args) => { if let hir::ExprKind::Path(ref path) = path.node { - if match_qpath(path, &paths::RANGE_INCLUSIVE_STD_NEW) - || match_qpath(path, &paths::RANGE_INCLUSIVE_NEW) + if match_qpath(path, &paths::RANGE_INCLUSIVE_STD_NEW) || match_qpath(path, &paths::RANGE_INCLUSIVE_NEW) { Some(Range { start: Some(&args[0]), @@ -128,8 +127,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O end: Some(get_field("end", fields)?), limits: ast::RangeLimits::HalfOpen, }) - } else if match_qpath(path, &paths::RANGE_TO_INCLUSIVE_STD) - || match_qpath(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, diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 33bb2d78732..3d22732a6d4 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -231,7 +231,9 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool { /// Gets the definition associated to a path. pub fn path_to_res(cx: &LateContext<'_, '_>, path: &[&str]) -> Option<(def::Res)> { let crates = cx.tcx.crates(); - let krate = crates.iter().find(|&&krate| cx.tcx.crate_name(krate).as_str() == path[0]); + let krate = crates + .iter() + .find(|&&krate| cx.tcx.crate_name(krate).as_str() == path[0]); if let Some(krate) = krate { let krate = DefId { krate: *krate, diff --git a/clippy_lints/src/utils/sym.rs b/clippy_lints/src/utils/sym.rs index 61de41d96d7..acd0763dbdc 100644 --- a/clippy_lints/src/utils/sym.rs +++ b/clippy_lints/src/utils/sym.rs @@ -1,4 +1,3 @@ - #[macro_export] macro_rules! sym { ($tt:tt) => { |
