diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index ab9ba4a9327..790c2884273 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -143,7 +143,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { if_chain! { if parent_impl != ast::CRATE_NODE_ID; if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl); - if let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = item.node; + if let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) = + item.node; if trait_ref.path.def.def_id() == trait_id; then { return; } } diff --git a/clippy_lints/src/invalid_ref.rs b/clippy_lints/src/invalid_ref.rs index 8cc12323fd5..90eb92b8ca4 100644 --- a/clippy_lints/src/invalid_ref.rs +++ b/clippy_lints/src/invalid_ref.rs @@ -22,8 +22,8 @@ declare_lint! { const ZERO_REF_SUMMARY: &str = "reference to zeroed memory"; const UNINIT_REF_SUMMARY: &str = "reference to uninitialized memory"; -const HELP: &str = - "Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html"; +const HELP: &str = "Creation of a null reference is undefined behavior; \ + see https://doc.rust-lang.org/reference/behavior-considered-undefined.html"; pub struct InvalidRef; @@ -42,9 +42,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidRef { if let ty::TyRef(..) = cx.tables.expr_ty(expr).sty; if let Some(def_id) = opt_def_id(cx.tables.qpath_def(qpath, path.hir_id)); then { - let msg = if match_def_path(cx.tcx, def_id, &paths::MEM_ZEROED) | match_def_path(cx.tcx, def_id, &paths::INIT) { + let msg = if match_def_path(cx.tcx, def_id, &paths::MEM_ZEROED) | + match_def_path(cx.tcx, def_id, &paths::INIT) + { ZERO_REF_SUMMARY - } else if match_def_path(cx.tcx, def_id, &paths::MEM_UNINIT) | match_def_path(cx.tcx, def_id, &paths::UNINIT) { + } else if match_def_path(cx.tcx, def_id, &paths::MEM_UNINIT) | + match_def_path(cx.tcx, def_id, &paths::UNINIT) + { UNINIT_REF_SUMMARY } else { return; diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 547caf46082..251c4ac3a11 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -782,7 +782,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { for &(ref conv, self_kinds) in &CONVENTIONS { if_chain! { if conv.check(&name.as_str()); - if !self_kinds.iter().any(|k| k.matches(first_arg_ty, first_arg, self_ty, is_copy, &implitem.generics)); + if !self_kinds + .iter() + .any(|k| k.matches(first_arg_ty, first_arg, self_ty, is_copy, &implitem.generics)); then { let lint = if item.vis == hir::Visibility::Public { WRONG_PUB_SELF_CONVENTION @@ -1039,12 +1041,15 @@ fn lint_cstring_as_ptr(cx: &LateContext, expr: &hir::Expr, new: &hir::Expr, unwr if let Def::Method(did) = cx.tables.qpath_def(path, fun.hir_id); if match_def_path(cx.tcx, did, &paths::CSTRING_NEW); then { - span_lint_and_then(cx, TEMPORARY_CSTRING_AS_PTR, expr.span, - "you are getting the inner pointer of a temporary `CString`", - |db| { - db.note("that pointer will be invalid outside this expression"); - db.span_help(unwrap.span, "assign the `CString` to a variable to extend its lifetime"); - }); + span_lint_and_then( + cx, + TEMPORARY_CSTRING_AS_PTR, + expr.span, + "you are getting the inner pointer of a temporary `CString`", + |db| { + db.note("that pointer will be invalid outside this expression"); + db.span_help(unwrap.span, "assign the `CString` to a variable to extend its lifetime"); + }); } } } diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index b09fb107b07..d56833eb457 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -142,7 +142,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault { span, &format!("you should consider adding a `Default` implementation for `{}`", self_ty), |db| { - db.suggest_prepend_item(cx, span, "try this", &create_new_without_default_suggest_msg(self_ty)); + db.suggest_prepend_item( + cx, + span, + "try this", + &create_new_without_default_suggest_msg(self_ty), + ); }, ); } diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 22722c919a2..25fc666d3e1 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -156,7 +156,11 @@ fn check_suspicious_swap(cx: &LateContext, block: &Block) { let lhs0 = Sugg::hir_opt(cx, lhs0); let rhs0 = Sugg::hir_opt(cx, rhs0); let (what, lhs, rhs) = if let (Some(first), Some(second)) = (lhs0, rhs0) { - (format!(" `{}` and `{}`", first, second), first.mut_addr().to_string(), second.mut_addr().to_string()) + ( + format!(" `{}` and `{}`", first, second), + first.mut_addr().to_string(), + second.mut_addr().to_string(), + ) } else { ("".to_owned(), "".to_owned(), "".to_owned()) }; diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index cb472789099..8d5dd3d19b4 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -166,11 +166,13 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) { if let Some(did) = opt_def_id(cx.tables.qpath_def(qpath, cx.tcx.hir.node_to_hir_id(vec.id))); if match_def_path(cx.tcx, did, &paths::VEC); then { - span_help_and_lint(cx, - BOX_VEC, - ast_ty.span, - "you seem to be trying to use `Box>`. Consider using just `Vec`", - "`Vec` is already on the heap, `Box>` makes an extra allocation."); + span_help_and_lint( + cx, + BOX_VEC, + ast_ty.span, + "you seem to be trying to use `Box>`. Consider using just `Vec`", + "`Vec` is already on the heap, `Box>` makes an extra allocation.", + ); return; // don't recurse into the type } } diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index 90a6896b348..e1c226466f9 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -52,7 +52,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { if is_copy(cx, vec_type(cx.tables.expr_ty_adjusted(arg))); then { // report the error around the `vec!` not inside `:` - let span = arg.span.ctxt().outer().expn_info().map(|info| info.call_site).expect("unable to get call_site"); + let span = arg.span + .ctxt() + .outer() + .expn_info() + .map(|info| info.call_site) + .expect("unable to get call_site"); check_vec_macro(cx, &vec_args, span); } } diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index 313af61bf15..efe23bcdc47 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -49,9 +49,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { | (_, FloatWidth::F64) => "f64", _ => "f32" }; - span_help_and_lint(cx, ZERO_DIVIDED_BY_ZERO, expr.span, + span_help_and_lint( + cx, + ZERO_DIVIDED_BY_ZERO, + expr.span, "constant division of 0.0 with 0.0 will always result in NaN", - &format!("Consider using `std::{}::NAN` if you would like a constant representing NaN", float_type)); + &format!( + "Consider using `std::{}::NAN` if you would like a constant representing NaN", + float_type, + ), + ); } } }