Skip to content

Commit 6e071bf

Browse files
committed
Format affected files
1 parent 058f7f6 commit 6e071bf

15 files changed

+104
-80
lines changed

clippy_lints/src/let_underscore.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
137137
"non-binding let on a synchronization lock",
138138
None,
139139
"consider using an underscore-prefixed named \
140-
binding or dropping explicitly with `std::mem::drop`"
140+
binding or dropping explicitly with `std::mem::drop`",
141141
);
142142
} else if init_ty.needs_drop(cx.tcx, cx.param_env) {
143143
span_lint_and_help(
@@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
147147
"non-binding `let` on a type that implements `Drop`",
148148
None,
149149
"consider using an underscore-prefixed named \
150-
binding or dropping explicitly with `std::mem::drop`"
150+
binding or dropping explicitly with `std::mem::drop`",
151151
);
152152
} else if is_must_use_ty(cx, cx.typeck_results().expr_ty(init)) {
153153
span_lint_and_help(
@@ -156,7 +156,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
156156
local.span,
157157
"non-binding let on an expression with `#[must_use]` type",
158158
None,
159-
"consider explicitly using expression value"
159+
"consider explicitly using expression value",
160160
);
161161
} else if is_must_use_func_call(cx, init) {
162162
span_lint_and_help(
@@ -165,7 +165,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
165165
local.span,
166166
"non-binding let on a result of a `#[must_use]` function",
167167
None,
168-
"consider explicitly using function result"
168+
"consider explicitly using function result",
169169
);
170170
}
171171
}

clippy_lints/src/loops/needless_range_loop.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
263263
match res {
264264
Res::Local(hir_id) => {
265265
let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
266-
let extent = self.cx
266+
let extent = self
267+
.cx
267268
.tcx
268269
.region_scope_tree(parent_def_id)
269270
.var_scope(hir_id.local_id)
@@ -274,11 +275,12 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
274275
(Some(extent), self.cx.typeck_results().node_type(seqexpr.hir_id)),
275276
);
276277
} else {
277-
self.indexed_indirectly.insert(seqvar.segments[0].ident.name, Some(extent));
278+
self.indexed_indirectly
279+
.insert(seqvar.segments[0].ident.name, Some(extent));
278280
}
279-
return false; // no need to walk further *on the variable*
280-
}
281-
Res::Def(DefKind::Static (_)| DefKind::Const, ..) => {
281+
return false; // no need to walk further *on the variable*
282+
},
283+
Res::Def(DefKind::Static(_) | DefKind::Const, ..) => {
282284
if index_used_directly {
283285
self.indexed_directly.insert(
284286
seqvar.segments[0].ident.name,
@@ -287,8 +289,8 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
287289
} else {
288290
self.indexed_indirectly.insert(seqvar.segments[0].ident.name, None);
289291
}
290-
return false; // no need to walk further *on the variable*
291-
}
292+
return false; // no need to walk further *on the variable*
293+
},
292294
_ => (),
293295
}
294296
}
@@ -310,14 +312,18 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
310312
if (meth.ident.name == sym::index && trait_id == self.cx.tcx.lang_items().index_trait())
311313
|| (meth.ident.name == sym::index_mut && trait_id == self.cx.tcx.lang_items().index_mut_trait());
312314
if !self.check(args_1, args_0, expr);
313-
then { return }
315+
then {
316+
return;
317+
}
314318
}
315319

316320
if_chain! {
317321
// an index op
318322
if let ExprKind::Index(seqexpr, idx) = expr.kind;
319323
if !self.check(idx, seqexpr, expr);
320-
then { return }
324+
then {
325+
return;
326+
}
321327
}
322328

323329
if_chain! {

clippy_lints/src/manual_async_fn.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ fn future_output_ty<'tcx>(trait_ref: &'tcx TraitRef<'tcx>) -> Option<&'tcx Ty<'t
139139
if args.bindings.len() == 1;
140140
let binding = &args.bindings[0];
141141
if binding.ident.name == sym::Output;
142-
if let TypeBindingKind::Equality{term: Term::Ty(output)} = binding.kind;
142+
if let TypeBindingKind::Equality { term: Term::Ty(output) } = binding.kind;
143143
then {
144-
return Some(output)
144+
return Some(output);
145145
}
146146
}
147147

@@ -180,7 +180,10 @@ fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>)
180180
.from_generator_fn()
181181
.and_then(|def_id| match_function_call_with_def_id(cx, block_expr, def_id));
182182
if args.len() == 1;
183-
if let Expr{kind: ExprKind::Closure(&Closure { body, .. }), ..} = args[0];
183+
if let Expr {
184+
kind: ExprKind::Closure(&Closure { body, .. }),
185+
..
186+
} = args[0];
184187
let closure_body = cx.tcx.hir().body(body);
185188
if closure_body.generator_kind == Some(GeneratorKind::Async(AsyncGeneratorKind::Block));
186189
then {

clippy_lints/src/methods/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -3370,15 +3370,17 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
33703370
then {
33713371
let first_arg_span = first_arg_ty.span;
33723372
let first_arg_ty = hir_ty_to_ty(cx.tcx, first_arg_ty);
3373-
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty().skip_binder();
3373+
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id())
3374+
.self_ty()
3375+
.skip_binder();
33743376
wrong_self_convention::check(
33753377
cx,
33763378
item.ident.name.as_str(),
33773379
self_ty,
33783380
first_arg_ty,
33793381
first_arg_span,
33803382
false,
3381-
true
3383+
true,
33823384
);
33833385
}
33843386
}
@@ -3387,7 +3389,9 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
33873389
if item.ident.name == sym::new;
33883390
if let TraitItemKind::Fn(_, _) = item.kind;
33893391
let ret_ty = return_ty(cx, item.hir_id());
3390-
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty().skip_binder();
3392+
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id())
3393+
.self_ty()
3394+
.skip_binder();
33913395
if !ret_ty.contains(self_ty);
33923396

33933397
then {

clippy_lints/src/methods/or_fun_call.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ pub(super) fn check<'tcx>(
121121
macro_expanded_snipped = snippet(cx, snippet_span, "..");
122122
match macro_expanded_snipped.strip_prefix("$crate::vec::") {
123123
Some(stripped) => Cow::from(stripped),
124-
None => macro_expanded_snipped
124+
None => macro_expanded_snipped,
125125
}
126-
}
127-
else {
126+
} else {
128127
not_macro_argument_snippet
129128
}
130129
};

clippy_lints/src/neg_cmp_op_on_partial_ord.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ declare_lint_pass!(NoNegCompOpForPartialOrd => [NEG_CMP_OP_ON_PARTIAL_ORD]);
4747
impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd {
4848
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
4949
if_chain! {
50-
5150
if !in_external_macro(cx.sess(), expr.span);
5251
if let ExprKind::Unary(UnOp::Not, inner) = expr.kind;
5352
if let ExprKind::Binary(ref op, left, _) = inner.kind;
5453
if let BinOpKind::Le | BinOpKind::Ge | BinOpKind::Lt | BinOpKind::Gt = op.node;
5554

5655
then {
57-
5856
let ty = cx.typeck_results().expr_ty(left);
5957

6058
let implements_ord = {
@@ -81,7 +79,7 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd {
8179
"the use of negated comparison operators on partially ordered \
8280
types produces code that is hard to read and refactor, please \
8381
consider using the `partial_cmp` method instead, to make it \
84-
clear that the two values could be incomparable"
82+
clear that the two values could be incomparable",
8583
);
8684
}
8785
}

clippy_lints/src/unit_return_expecting_ord.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,15 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve
9898
if trait_pred.self_ty() == inp;
9999
if let Some(return_ty_pred) = get_projection_pred(cx, generics, *trait_pred);
100100
then {
101-
if ord_preds.iter().any(|ord| Some(ord.self_ty()) == return_ty_pred.term.ty()) {
101+
if ord_preds
102+
.iter()
103+
.any(|ord| Some(ord.self_ty()) == return_ty_pred.term.ty())
104+
{
102105
args_to_check.push((i, "Ord".to_string()));
103-
} else if partial_ord_preds.iter().any(|pord| {
104-
pord.self_ty() == return_ty_pred.term.ty().unwrap()
105-
}) {
106+
} else if partial_ord_preds
107+
.iter()
108+
.any(|pord| pord.self_ty() == return_ty_pred.term.ty().unwrap())
109+
{
106110
args_to_check.push((i, "PartialOrd".to_string()));
107111
}
108112
}

clippy_lints/src/utils/internal_lints/collapsible_calls.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ impl<'tcx> LateLintPass<'tcx> for CollapsibleCalls {
9292
let mut sle = SpanlessEq::new(cx).deny_side_effects();
9393
match ps.ident.as_str() {
9494
"span_suggestion" if sle.eq_expr(&and_then_args[2], &span_call_args[0]) => {
95-
suggest_suggestion(cx, expr, &and_then_snippets, &span_suggestion_snippets(cx, span_call_args));
95+
suggest_suggestion(
96+
cx,
97+
expr,
98+
&and_then_snippets,
99+
&span_suggestion_snippets(cx, span_call_args),
100+
);
96101
},
97102
"span_help" if sle.eq_expr(&and_then_args[2], &span_call_args[0]) => {
98103
let help_snippet = snippet(cx, span_call_args[1].span, r#""...""#);
@@ -105,12 +110,12 @@ impl<'tcx> LateLintPass<'tcx> for CollapsibleCalls {
105110
"help" => {
106111
let help_snippet = snippet(cx, span_call_args[0].span, r#""...""#);
107112
suggest_help(cx, expr, &and_then_snippets, help_snippet.borrow(), false);
108-
}
113+
},
109114
"note" => {
110115
let note_snippet = snippet(cx, span_call_args[0].span, r#""...""#);
111116
suggest_note(cx, expr, &and_then_snippets, note_snippet.borrow(), false);
112-
}
113-
_ => (),
117+
},
118+
_ => (),
114119
}
115120
}
116121
}

clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for CompilerLintFunctions {
6161
let fn_name = path.ident;
6262
if let Some(sugg) = self.map.get(fn_name.as_str());
6363
let ty = cx.typeck_results().expr_ty(self_arg).peel_refs();
64-
if match_type(cx, ty, &paths::EARLY_CONTEXT)
65-
|| match_type(cx, ty, &paths::LATE_CONTEXT);
64+
if match_type(cx, ty, &paths::EARLY_CONTEXT) || match_type(cx, ty, &paths::LATE_CONTEXT);
6665
then {
6766
span_lint_and_help(
6867
cx,

clippy_lints/src/utils/internal_lints/if_chain_style.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ fn check_nested_if_chains(
100100
.iter()
101101
.all(|stmt| matches!(stmt.kind, StmtKind::Local(..)) && !sm.is_multiline(stmt.span));
102102
if if_chain_span.is_some() || !is_else_clause(cx.tcx, if_expr);
103-
then {} else { return }
103+
then {
104+
} else {
105+
return;
106+
}
104107
}
105108
let (span, msg) = match (if_chain_span, is_expn_of(tail.span, "if_chain")) {
106109
(None, Some(_)) => (if_expr.span, "this `if` can be part of the inner `if_chain!`"),

clippy_lints/src/utils/internal_lints/invalid_paths.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ impl<'tcx> LateLintPass<'tcx> for InvalidPaths {
4141
let body = cx.tcx.hir().body(body_id);
4242
let typeck_results = cx.tcx.typeck_body(body_id);
4343
if let Some(Constant::Vec(path)) = constant_simple(cx, typeck_results, body.value);
44-
let path: Vec<&str> = path.iter().map(|x| {
44+
let path: Vec<&str> = path
45+
.iter()
46+
.map(|x| {
4547
if let Constant::Str(s) = x {
4648
s.as_str()
4749
} else {
4850
// We checked the type of the constant above
4951
unreachable!()
5052
}
51-
}).collect();
53+
})
54+
.collect();
5255
if !check_path(cx, &path[..]);
5356
then {
5457
span_lint(cx, INVALID_PATHS, item.span, "invalid path");

clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,7 @@ pub(super) fn extract_clippy_version_value(cx: &LateContext<'_>, item: &'_ Item<
317317
if tool_name.ident.name == sym::clippy;
318318
if attr_name.ident.name == sym::version;
319319
if let Some(version) = attr.value_str();
320-
then {
321-
Some(version)
322-
} else {
323-
None
324-
}
320+
then { Some(version) } else { None }
325321
}
326322
})
327323
}

clippy_lints/src/utils/internal_lints/metadata_collector.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,11 @@ fn parse_config_field_doc(doc_comment: &str) -> Option<(Vec<String>, String)> {
532532

533533
// Extract lints
534534
doc_comment.make_ascii_lowercase();
535-
let lints: Vec<String> = doc_comment.split_off(DOC_START.len()).split(", ").map(str::to_string).collect();
535+
let lints: Vec<String> = doc_comment
536+
.split_off(DOC_START.len())
537+
.split(", ")
538+
.map(str::to_string)
539+
.collect();
536540

537541
// Format documentation correctly
538542
// split off leading `.` from lint name list and indent for correct formatting

clippy_lints/src/utils/internal_lints/outer_expn_data_pass.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'tcx> LateLintPass<'tcx> for OuterExpnDataPass {
4242
let method_names: Vec<&str> = method_names.iter().map(Symbol::as_str).collect();
4343
if_chain! {
4444
if let ["expn_data", "outer_expn"] = method_names.as_slice();
45-
let (self_arg, args)= arg_lists[1];
45+
let (self_arg, args) = arg_lists[1];
4646
if args.is_empty();
4747
let self_ty = cx.typeck_results().expr_ty(self_arg).peel_refs();
4848
if match_type(cx, self_ty, &paths::SYNTAX_CONTEXT);

0 commit comments

Comments
 (0)