Skip to content

Commit 63fa5d2

Browse files
committed
Fix some formatting issues
1 parent 1751d24 commit 63fa5d2

File tree

14 files changed

+120
-139
lines changed

14 files changed

+120
-139
lines changed

clippy_lints/src/default_trait_access.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,44 +49,44 @@ impl LintPass for DefaultTraitAccess {
4949
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
5050
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
5151
if_chain! {
52-
if let ExprKind::Call(ref path, ..) = expr.node;
53-
if !any_parent_is_automatically_derived(cx.tcx, expr.id);
54-
if let ExprKind::Path(ref qpath) = path.node;
55-
if let Some(def_id) = opt_def_id(cx.tables.qpath_def(qpath, path.hir_id));
56-
if match_def_path(cx.tcx, def_id, &paths::DEFAULT_TRAIT_METHOD);
57-
then {
58-
match qpath {
59-
QPath::Resolved(..) => {
60-
if_chain! {
61-
// Detect and ignore <Foo as Default>::default() because these calls do
62-
// explicitly name the type.
63-
if let ExprKind::Call(ref method, ref _args) = expr.node;
64-
if let ExprKind::Path(ref p) = method.node;
65-
if let QPath::Resolved(Some(_ty), _path) = p;
66-
then {
67-
return;
68-
}
69-
}
70-
71-
// TODO: Work out a way to put "whatever the imported way of referencing
72-
// this type in this file" rather than a fully-qualified type.
73-
let expr_ty = cx.tables.expr_ty(expr);
74-
if let TyKind::Adt(..) = expr_ty.sty {
75-
let replacement = format!("{}::default()", expr_ty);
76-
span_lint_and_sugg(
77-
cx,
78-
DEFAULT_TRAIT_ACCESS,
79-
expr.span,
80-
&format!("Calling {} is more clear than this expression", replacement),
81-
"try",
82-
replacement,
83-
Applicability::Unspecified, // First resolve the TODO above
84-
);
52+
if let ExprKind::Call(ref path, ..) = expr.node;
53+
if !any_parent_is_automatically_derived(cx.tcx, expr.id);
54+
if let ExprKind::Path(ref qpath) = path.node;
55+
if let Some(def_id) = opt_def_id(cx.tables.qpath_def(qpath, path.hir_id));
56+
if match_def_path(cx.tcx, def_id, &paths::DEFAULT_TRAIT_METHOD);
57+
then {
58+
match qpath {
59+
QPath::Resolved(..) => {
60+
if_chain! {
61+
// Detect and ignore <Foo as Default>::default() because these calls do
62+
// explicitly name the type.
63+
if let ExprKind::Call(ref method, ref _args) = expr.node;
64+
if let ExprKind::Path(ref p) = method.node;
65+
if let QPath::Resolved(Some(_ty), _path) = p;
66+
then {
67+
return;
68+
}
8569
}
86-
},
87-
QPath::TypeRelative(..) => {},
88-
}
89-
}
70+
71+
// TODO: Work out a way to put "whatever the imported way of referencing
72+
// this type in this file" rather than a fully-qualified type.
73+
let expr_ty = cx.tables.expr_ty(expr);
74+
if let TyKind::Adt(..) = expr_ty.sty {
75+
let replacement = format!("{}::default()", expr_ty);
76+
span_lint_and_sugg(
77+
cx,
78+
DEFAULT_TRAIT_ACCESS,
79+
expr.span,
80+
&format!("Calling {} is more clear than this expression", replacement),
81+
"try",
82+
replacement,
83+
Applicability::Unspecified, // First resolve the TODO above
84+
);
85+
}
86+
},
87+
QPath::TypeRelative(..) => {},
88+
}
89+
}
9090
}
9191
}
9292
}

clippy_lints/src/explicit_write.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ use if_chain::if_chain;
2727
/// writeln!(&mut io::stderr(), "foo: {:?}", bar).unwrap();
2828
/// ```
2929
declare_clippy_lint! {
30-
pub EXPLICIT_WRITE,
31-
complexity,
32-
"using the `write!()` family of functions instead of the `print!()` family \
33-
of functions, when using the latter would work"
30+
pub EXPLICIT_WRITE,
31+
complexity,
32+
"using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work"
3433
}
3534

3635
#[derive(Copy, Clone, Debug)]

clippy_lints/src/loops.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,9 @@ declare_clippy_lint! {
249249
/// vec.iter().map(|x| /* some operation returning () */).collect::<Vec<_>>();
250250
/// ```
251251
declare_clippy_lint! {
252-
pub UNUSED_COLLECT,
253-
perf,
254-
"`collect()`ing an iterator without using the result; this is usually better \
255-
written as a for loop"
252+
pub UNUSED_COLLECT,
253+
perf,
254+
"`collect()`ing an iterator without using the result; this is usually better written as a for loop"
256255
}
257256

258257
/// **What it does:** Checks for functions collecting an iterator when collect

clippy_lints/src/map_clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
8181
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => {
8282
match closure_expr.node {
8383
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => {
84-
if !cx.tables.expr_ty(inner).is_box() => {
84+
if !cx.tables.expr_ty(inner).is_box() {
8585
lint(cx, e.span, args[0].span, name, inner);
8686
}
8787
},

clippy_lints/src/matches.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ use std::collections::Bound;
4040
/// }
4141
/// ```
4242
declare_clippy_lint! {
43-
pub SINGLE_MATCH,
44-
style,
45-
"a match statement with a single nontrivial arm (i.e. where the other arm \
46-
is `_ => {}`) instead of `if let`"
43+
pub SINGLE_MATCH,
44+
style,
45+
"a match statement with a single nontrivial arm (i.e. where the other arm is `_ => {}`) instead of `if let`"
4746
}
4847

4948
/// **What it does:** Checks for matches with a two arms where an `if let` will
@@ -61,10 +60,9 @@ style,
6160
/// }
6261
/// ```
6362
declare_clippy_lint! {
64-
pub SINGLE_MATCH_ELSE,
65-
pedantic,
66-
"a match statement with a two arms where the second arm's pattern is a wildcard \
67-
instead of `if let`"
63+
pub SINGLE_MATCH_ELSE,
64+
pedantic,
65+
"a match statement with a two arms where the second arm's pattern is a wildcard instead of `if let`"
6866
}
6967

7068
/// **What it does:** Checks for matches where all arms match a reference,

clippy_lints/src/methods/mod.rs

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,9 @@ declare_clippy_lint! {
131131
/// }
132132
/// ```
133133
declare_clippy_lint! {
134-
pub WRONG_SELF_CONVENTION,
135-
style,
136-
"defining a method named with an established prefix (like \"into_\") that takes \
137-
`self` with the wrong convention"
134+
pub WRONG_SELF_CONVENTION,
135+
style,
136+
"defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention"
138137
}
139138

140139
/// **What it does:** This is the same as
@@ -155,10 +154,9 @@ style,
155154
/// }
156155
/// ```
157156
declare_clippy_lint! {
158-
pub WRONG_PUB_SELF_CONVENTION,
159-
restriction,
160-
"defining a public method named with an established prefix (like \"into_\") that takes \
161-
`self` with the wrong convention"
157+
pub WRONG_PUB_SELF_CONVENTION,
158+
restriction,
159+
"defining a public method named with an established prefix (like \"into_\") that takes `self` with the wrong convention"
162160
}
163161

164162
/// **What it does:** Checks for usage of `ok().expect(..)`.
@@ -173,10 +171,9 @@ restriction,
173171
/// x.ok().expect("why did I do this again?")
174172
/// ```
175173
declare_clippy_lint! {
176-
pub OK_EXPECT,
177-
style,
178-
"using `ok().expect()`, which gives worse error messages than \
179-
calling `expect` directly on the Result"
174+
pub OK_EXPECT,
175+
style,
176+
"using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result"
180177
}
181178

182179
/// **What it does:** Checks for usage of `_.map(_).unwrap_or(_)`.
@@ -209,10 +206,9 @@ pedantic,
209206
/// x.map(|a| a + 1).unwrap_or_else(some_function)
210207
/// ```
211208
declare_clippy_lint! {
212-
pub OPTION_MAP_UNWRAP_OR_ELSE,
213-
pedantic,
214-
"using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as \
215-
`map_or_else(g, f)`"
209+
pub OPTION_MAP_UNWRAP_OR_ELSE,
210+
pedantic,
211+
"using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `map_or_else(g, f)`"
216212
}
217213

218214
/// **What it does:** Checks for usage of `result.map(_).unwrap_or_else(_)`.
@@ -227,10 +223,9 @@ pedantic,
227223
/// x.map(|a| a + 1).unwrap_or_else(some_function)
228224
/// ```
229225
declare_clippy_lint! {
230-
pub RESULT_MAP_UNWRAP_OR_ELSE,
231-
pedantic,
232-
"using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as \
233-
`.ok().map_or_else(g, f)`"
226+
pub RESULT_MAP_UNWRAP_OR_ELSE,
227+
pedantic,
228+
"using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as `.ok().map_or_else(g, f)`"
234229
}
235230

236231
/// **What it does:** Checks for usage of `_.map_or(None, _)`.
@@ -245,10 +240,9 @@ pedantic,
245240
/// opt.map_or(None, |a| a + 1)
246241
/// ```
247242
declare_clippy_lint! {
248-
pub OPTION_MAP_OR_NONE,
249-
style,
250-
"using `Option.map_or(None, f)`, which is more succinctly expressed as \
251-
`and_then(f)`"
243+
pub OPTION_MAP_OR_NONE,
244+
style,
245+
"using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`"
252246
}
253247

254248
/// **What it does:** Checks for usage of `_.filter(_).next()`.
@@ -280,10 +274,9 @@ declare_clippy_lint! {
280274
/// iter.map(|x| x.iter()).flatten()
281275
/// ```
282276
declare_clippy_lint! {
283-
pub MAP_FLATTEN,
284-
pedantic,
285-
"using combinations of `flatten` and `map` which can usually be written as a \
286-
single method call"
277+
pub MAP_FLATTEN,
278+
pedantic,
279+
"using combinations of `flatten` and `map` which can usually be written as a single method call"
287280
}
288281

289282
/// **What it does:** Checks for usage of `_.filter(_).map(_)`,
@@ -300,10 +293,9 @@ pedantic,
300293
/// iter.filter(|x| x == 0).map(|x| x * 2)
301294
/// ```
302295
declare_clippy_lint! {
303-
pub FILTER_MAP,
304-
pedantic,
305-
"using combinations of `filter`, `map`, `filter_map` and `flat_map` which can \
306-
usually be written as a single method call"
296+
pub FILTER_MAP,
297+
pedantic,
298+
"using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call"
307299
}
308300

309301
/// **What it does:** Checks for an iterator search (such as `find()`,
@@ -319,10 +311,9 @@ pedantic,
319311
/// iter.find(|x| x == 0).is_some()
320312
/// ```
321313
declare_clippy_lint! {
322-
pub SEARCH_IS_SOME,
323-
complexity,
324-
"using an iterator search followed by `is_some()`, which is more succinctly \
325-
expressed as a call to `any()`"
314+
pub SEARCH_IS_SOME,
315+
complexity,
316+
"using an iterator search followed by `is_some()`, which is more succinctly expressed as a call to `any()`"
326317
}
327318

328319
/// **What it does:** Checks for usage of `.chars().next()` on a `str` to check
@@ -485,10 +476,9 @@ declare_clippy_lint! {
485476
/// **Example:**
486477
/// `_.split("x")` could be `_.split('x')`
487478
declare_clippy_lint! {
488-
pub SINGLE_CHAR_PATTERN,
489-
perf,
490-
"using a single-character str where a char could be used, e.g. \
491-
`_.split(\"x\")`"
479+
pub SINGLE_CHAR_PATTERN,
480+
perf,
481+
"using a single-character str where a char could be used, e.g. `_.split(\"x\")`"
492482
}
493483

494484
/// **What it does:** Checks for getting the inner pointer of a temporary

clippy_lints/src/mut_reference.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ use crate::utils::span_lint;
2727
/// my_vec.push(&mut value)
2828
/// ```
2929
declare_clippy_lint! {
30-
pub UNNECESSARY_MUT_PASSED,
31-
style,
32-
"an argument passed as a mutable reference although the callee only demands an \
33-
immutable reference"
30+
pub UNNECESSARY_MUT_PASSED,
31+
style,
32+
"an argument passed as a mutable reference although the callee only demands an immutable reference"
3433
}
3534

3635
#[derive(Copy, Clone)]

clippy_lints/src/needless_bool.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ use crate::utils::{in_macro, snippet_with_applicability, span_lint, span_lint_an
4040
/// }
4141
/// ```
4242
declare_clippy_lint! {
43-
pub NEEDLESS_BOOL,
44-
complexity,
45-
"if-statements with plain booleans in the then- and else-clause, e.g. \
46-
`if p { true } else { false }`"
43+
pub NEEDLESS_BOOL,
44+
complexity,
45+
"if-statements with plain booleans in the then- and else-clause, e.g. `if p { true } else { false }`"
4746
}
4847

4948
/// **What it does:** Checks for expressions of the form `x == true` (or vice

clippy_lints/src/ptr.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ use std::borrow::Cow;
5454
/// fn foo(&Vec<u32>) { .. }
5555
/// ```
5656
declare_clippy_lint! {
57-
pub PTR_ARG,
58-
style,
59-
"fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` \
60-
instead, respectively"
57+
pub PTR_ARG,
58+
style,
59+
"fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively"
6160
}
6261

6362
/// **What it does:** This lint checks for equality comparisons with `ptr::null`

clippy_lints/src/returns.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ declare_clippy_lint! {
6565
/// }
6666
/// ```
6767
declare_clippy_lint! {
68-
pub LET_AND_RETURN,
69-
style,
70-
"creating a let-binding and then immediately returning it like `let x = expr; x` at \
71-
the end of a block"
68+
pub LET_AND_RETURN,
69+
style,
70+
"creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block"
7271
}
7372

7473
/// **What it does:** Checks for unit (`()`) expressions that can be removed.

clippy_lints/src/shadow.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ declare_clippy_lint! {
5656
/// let y = x + 1;
5757
/// ```
5858
declare_clippy_lint! {
59-
pub SHADOW_REUSE,
60-
restriction,
61-
"rebinding a name to an expression that re-uses the original value, e.g. \
62-
`let x = x + 1`"
59+
pub SHADOW_REUSE,
60+
restriction,
61+
"rebinding a name to an expression that re-uses the original value, e.g. `let x = x + 1`"
6362
}
6463

6564
/// **What it does:** Checks for bindings that shadow other bindings already in

0 commit comments

Comments
 (0)