Skip to content

Commit 462df72

Browse files
committed
Dogfood and rustfmt
1 parent 568a3ec commit 462df72

File tree

11 files changed

+20
-49
lines changed

11 files changed

+20
-49
lines changed

clippy_lints/src/booleans.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ declare_clippy_lint! {
5050
}
5151

5252
// For each pairs, both orders are considered.
53-
const METHODS_WITH_NEGATION: [(&str, &str); 2] = [
54-
("is_some", "is_none"),
55-
("is_err", "is_ok"),
56-
];
53+
const METHODS_WITH_NEGATION: [(&str, &str); 2] = [("is_some", "is_none"), ("is_err", "is_ok")];
5754

5855
declare_lint_pass!(NonminimalBool => [NONMINIMAL_BOOL, LOGIC_BUG]);
5956

clippy_lints/src/len_zero.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item, trait_items
139139
}
140140
}
141141

142-
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len"))
143-
{
142+
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
144143
let mut current_and_super_traits = FxHashSet::default();
145144
let visited_trait_def_id = cx.tcx.hir().local_def_id_from_hir_id(visited_trait.hir_id);
146145
fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);

clippy_lints/src/methods/mod.rs

+8-24
Original file line numberDiff line numberDiff line change
@@ -1111,8 +1111,7 @@ fn lint_or_fun_call<'a, 'tcx: 'a>(
11111111

11121112
if ["default", "new"].contains(&path) {
11131113
let arg_ty = cx.tables.expr_ty(arg);
1114-
let default_trait_id = if let Some(default_trait_id) = get_trait_def_id(cx, &paths::DEFAULT_TRAIT)
1115-
{
1114+
let default_trait_id = if let Some(default_trait_id) = get_trait_def_id(cx, &paths::DEFAULT_TRAIT) {
11161115
default_trait_id
11171116
} else {
11181117
return false;
@@ -2254,33 +2253,15 @@ fn lint_chars_cmp_with_unwrap<'a, 'tcx>(
22542253

22552254
/// Checks for the `CHARS_NEXT_CMP` lint with `unwrap()`.
22562255
fn lint_chars_next_cmp_with_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, info: &BinaryExprInfo<'_>) -> bool {
2257-
lint_chars_cmp_with_unwrap(
2258-
cx,
2259-
info,
2260-
&["chars", "next", "unwrap"],
2261-
CHARS_NEXT_CMP,
2262-
"starts_with",
2263-
)
2256+
lint_chars_cmp_with_unwrap(cx, info, &["chars", "next", "unwrap"], CHARS_NEXT_CMP, "starts_with")
22642257
}
22652258

22662259
/// Checks for the `CHARS_LAST_CMP` lint with `unwrap()`.
22672260
fn lint_chars_last_cmp_with_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, info: &BinaryExprInfo<'_>) -> bool {
2268-
if lint_chars_cmp_with_unwrap(
2269-
cx,
2270-
info,
2271-
&["chars", "last", "unwrap"],
2272-
CHARS_LAST_CMP,
2273-
"ends_with",
2274-
) {
2261+
if lint_chars_cmp_with_unwrap(cx, info, &["chars", "last", "unwrap"], CHARS_LAST_CMP, "ends_with") {
22752262
true
22762263
} else {
2277-
lint_chars_cmp_with_unwrap(
2278-
cx,
2279-
info,
2280-
&["chars", "next_back", "unwrap"],
2281-
CHARS_LAST_CMP,
2282-
"ends_with",
2283-
)
2264+
lint_chars_cmp_with_unwrap(cx, info, &["chars", "next_back", "unwrap"], CHARS_LAST_CMP, "ends_with")
22842265
}
22852266
}
22862267

@@ -2344,7 +2325,10 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re
23442325
}
23452326
}
23462327

2347-
fn ty_has_iter_method(cx: &LateContext<'_, '_>, self_ref_ty: Ty<'_>) -> Option<(&'static Lint, &'static str, &'static str)> {
2328+
fn ty_has_iter_method(
2329+
cx: &LateContext<'_, '_>,
2330+
self_ref_ty: Ty<'_>,
2331+
) -> Option<(&'static Lint, &'static str, &'static str)> {
23482332
if let Some(ty_name) = has_iter_method(cx, self_ref_ty) {
23492333
let lint = if ty_name == "array" || ty_name == "PathBuf" {
23502334
INTO_ITER_ON_ARRAY

clippy_lints/src/misc.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
504504
},
505505
ExprKind::Call(ref path, ref v) if v.len() == 1 => {
506506
if let ExprKind::Path(ref path) = path.node {
507-
if match_qpath(path, &["String", "from_str"]) || match_qpath(path, &["String", "from"])
508-
{
507+
if match_qpath(path, &["String", "from_str"]) || match_qpath(path, &["String", "from"]) {
509508
(cx.tables.expr_ty_adjusted(&v[0]), snippet(cx, v[0].span, ".."))
510509
} else {
511510
return;

clippy_lints/src/ptr.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id:
193193
);
194194
}
195195
} else if match_type(cx, ty, &paths::STRING) {
196-
if let Some(spans) = get_spans(
197-
cx,
198-
opt_body_id,
199-
idx,
200-
&[("clone", ".to_string()"), ("as_str", "")],
201-
) {
196+
if let Some(spans) = get_spans(cx, opt_body_id, idx, &[("clone", ".to_string()"), ("as_str", "")]) {
202197
span_lint_and_then(
203198
cx,
204199
PTR_ARG,

clippy_lints/src/ranges.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ fn has_step_by(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
212212
// can't be called on a borrowed range.
213213
let ty = cx.tables.expr_ty_adjusted(expr);
214214

215-
get_trait_def_id(cx, &paths::ITERATOR)
216-
.map_or(false, |iterator_trait| implements_trait(cx, ty, iterator_trait, &[]))
215+
get_trait_def_id(cx, &paths::ITERATOR).map_or(false, |iterator_trait| implements_trait(cx, ty, iterator_trait, &[]))
217216
}
218217

219218
fn y_plus_one(expr: &Expr) -> Option<&Expr> {

clippy_lints/src/redundant_clone.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
9696

9797
let from_borrow = match_def_path(cx, fn_def_id, &paths::CLONE_TRAIT_METHOD)
9898
|| match_def_path(cx, fn_def_id, &paths::TO_OWNED_METHOD)
99-
|| (match_def_path(cx, fn_def_id, &paths::TO_STRING_METHOD)
100-
&& match_type(cx, arg_ty, &paths::STRING));
99+
|| (match_def_path(cx, fn_def_id, &paths::TO_STRING_METHOD) && match_type(cx, arg_ty, &paths::STRING));
101100

102101
let from_deref = !from_borrow
103102
&& (match_def_path(cx, fn_def_id, &paths::PATH_TO_PATH_BUF)

clippy_lints/src/replace_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ReplaceConsts {
5656
}
5757
}
5858

59-
const REPLACEMENTS: [([&str; 3], &'static str); 25] = [
59+
const REPLACEMENTS: [([&str; 3], &str); 25] = [
6060
// Once
6161
(["core", "sync", "ONCE_INIT"], "Once::new()"),
6262
// Min

clippy_lints/src/utils/higher.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O
100100
},
101101
hir::ExprKind::Call(ref path, ref args) => {
102102
if let hir::ExprKind::Path(ref path) = path.node {
103-
if match_qpath(path, &paths::RANGE_INCLUSIVE_STD_NEW)
104-
|| match_qpath(path, &paths::RANGE_INCLUSIVE_NEW)
103+
if match_qpath(path, &paths::RANGE_INCLUSIVE_STD_NEW) || match_qpath(path, &paths::RANGE_INCLUSIVE_NEW)
105104
{
106105
Some(Range {
107106
start: Some(&args[0]),
@@ -128,8 +127,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O
128127
end: Some(get_field("end", fields)?),
129128
limits: ast::RangeLimits::HalfOpen,
130129
})
131-
} else if match_qpath(path, &paths::RANGE_TO_INCLUSIVE_STD)
132-
|| match_qpath(path, &paths::RANGE_TO_INCLUSIVE)
130+
} else if match_qpath(path, &paths::RANGE_TO_INCLUSIVE_STD) || match_qpath(path, &paths::RANGE_TO_INCLUSIVE)
133131
{
134132
Some(Range {
135133
start: None,

clippy_lints/src/utils/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
231231
/// Gets the definition associated to a path.
232232
pub fn path_to_res(cx: &LateContext<'_, '_>, path: &[&str]) -> Option<(def::Res)> {
233233
let crates = cx.tcx.crates();
234-
let krate = crates.iter().find(|&&krate| cx.tcx.crate_name(krate).as_str() == path[0]);
234+
let krate = crates
235+
.iter()
236+
.find(|&&krate| cx.tcx.crate_name(krate).as_str() == path[0]);
235237
if let Some(krate) = krate {
236238
let krate = DefId {
237239
krate: *krate,

clippy_lints/src/utils/sym.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#[macro_export]
32
macro_rules! sym {
43
($tt:tt) => {

0 commit comments

Comments
 (0)