Skip to content

Commit bd7f9c6

Browse files
committed
Merge remote-tracking branch 'upstream/master' into sync-from-rust
2 parents 0e527ba + 50bca8a commit bd7f9c6

31 files changed

+722
-109
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,7 @@ Released 2018-09-13
20242024
[`redundant_closure`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
20252025
[`redundant_closure_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_call
20262026
[`redundant_closure_for_method_calls`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
2027+
[`redundant_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_else
20272028
[`redundant_field_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
20282029
[`redundant_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern
20292030
[`redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching

clippy_lints/src/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, span: Span) {
480480
| ItemKind::ForeignMod(..) => return false,
481481
// We found a main function ...
482482
ItemKind::Fn(_, sig, _, Some(block)) if item.ident.name == sym::main => {
483-
let is_async = matches!(sig.header.asyncness, Async::Yes{..});
483+
let is_async = matches!(sig.header.asyncness, Async::Yes { .. });
484484
let returns_nothing = match &sig.decl.output {
485485
FnRetTy::Default(..) => true,
486486
FnRetTy::Ty(ty) if ty.kind.is_unit() => true,

clippy_lints/src/functions.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,10 @@ impl<'tcx> Functions {
405405
break;
406406
}
407407
if in_comment {
408-
match line.find("*/") {
409-
Some(i) => {
410-
line = &line[i + 2..];
411-
in_comment = false;
412-
continue;
413-
},
414-
None => break,
408+
if let Some(i) = line.find("*/") {
409+
line = &line[i + 2..];
410+
in_comment = false;
411+
continue;
415412
}
416413
} else {
417414
let multi_idx = line.find("/*").unwrap_or_else(|| line.len());
@@ -423,8 +420,8 @@ impl<'tcx> Functions {
423420
in_comment = true;
424421
continue;
425422
}
426-
break;
427423
}
424+
break;
428425
}
429426
if code_in_line {
430427
line_count += 1;

clippy_lints/src/future_not_send.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,8 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
9292
|db| {
9393
cx.tcx.infer_ctxt().enter(|infcx| {
9494
for FulfillmentError { obligation, .. } in send_errors {
95-
infcx.maybe_note_obligation_cause_for_async_await(
96-
db,
97-
&obligation,
98-
);
99-
if let Trait(trait_pred, _) =
100-
obligation.predicate.skip_binders()
101-
{
95+
infcx.maybe_note_obligation_cause_for_async_await(db, &obligation);
96+
if let Trait(trait_pred, _) = obligation.predicate.skip_binders() {
10297
db.note(&format!(
10398
"`{}` doesn't implement `{}`",
10499
trait_pred.self_ty(),

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,8 @@ fn check_impl_items(cx: &LateContext<'_>, item: &Item<'_>, impl_items: &[ImplIte
222222
let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(cx, i, "is_empty")) {
223223
if cx.access_levels.is_exported(is_empty.id.hir_id) {
224224
return;
225-
} else {
226-
"a private"
227225
}
226+
"a private"
228227
} else {
229228
"no corresponding"
230229
};

clippy_lints/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ mod question_mark;
294294
mod ranges;
295295
mod redundant_clone;
296296
mod redundant_closure_call;
297+
mod redundant_else;
297298
mod redundant_field_names;
298299
mod redundant_pub_crate;
299300
mod redundant_static_lifetimes;
@@ -831,6 +832,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
831832
&ranges::REVERSED_EMPTY_RANGES,
832833
&redundant_clone::REDUNDANT_CLONE,
833834
&redundant_closure_call::REDUNDANT_CLOSURE_CALL,
835+
&redundant_else::REDUNDANT_ELSE,
834836
&redundant_field_names::REDUNDANT_FIELD_NAMES,
835837
&redundant_pub_crate::REDUNDANT_PUB_CRATE,
836838
&redundant_static_lifetimes::REDUNDANT_STATIC_LIFETIMES,
@@ -1132,6 +1134,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11321134
store.register_early_pass(|| box items_after_statements::ItemsAfterStatements);
11331135
store.register_early_pass(|| box precedence::Precedence);
11341136
store.register_early_pass(|| box needless_continue::NeedlessContinue);
1137+
store.register_early_pass(|| box redundant_else::RedundantElse);
11351138
store.register_late_pass(|| box create_dir::CreateDir);
11361139
store.register_early_pass(|| box needless_arbitrary_self_type::NeedlessArbitrarySelfType);
11371140
store.register_early_pass(|| box redundant_static_lifetimes::RedundantStaticLifetimes);
@@ -1308,6 +1311,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13081311
LintId::of(&pass_by_ref_or_value::TRIVIALLY_COPY_PASS_BY_REF),
13091312
LintId::of(&ranges::RANGE_MINUS_ONE),
13101313
LintId::of(&ranges::RANGE_PLUS_ONE),
1314+
LintId::of(&redundant_else::REDUNDANT_ELSE),
13111315
LintId::of(&ref_option_ref::REF_OPTION_REF),
13121316
LintId::of(&shadow::SHADOW_UNRELATED),
13131317
LintId::of(&strings::STRING_ADD_ASSIGN),

clippy_lints/src/matches.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,10 +689,9 @@ fn check_single_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp
689689
if stmts.len() == 1 && block_expr.is_none() || stmts.is_empty() && block_expr.is_some() {
690690
// single statement/expr "else" block, don't lint
691691
return;
692-
} else {
693-
// block with 2+ statements or 1 expr and 1+ statement
694-
Some(els)
695692
}
693+
// block with 2+ statements or 1 expr and 1+ statement
694+
Some(els)
696695
} else {
697696
// not a block, don't lint
698697
return;

clippy_lints/src/methods/unnecessary_filter_map.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ fn check_expression<'tcx>(cx: &LateContext<'tcx>, arg_id: hir::HirId, expr: &'tc
6969
}
7070
}
7171
return (true, false);
72-
} else {
73-
// We don't know. It might do anything.
74-
return (true, true);
7572
}
73+
// We don't know. It might do anything.
74+
return (true, true);
7675
}
7776
}
7877
(true, true)

clippy_lints/src/missing_const_for_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
9999
let has_const_generic_params = generics
100100
.params
101101
.iter()
102-
.any(|param| matches!(param.kind, GenericParamKind::Const{ .. }));
102+
.any(|param| matches!(param.kind, GenericParamKind::Const { .. }));
103103

104104
if already_const(header) || has_const_generic_params {
105105
return;

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
9090

9191
// Exclude non-inherent impls
9292
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
93-
if matches!(item.kind, ItemKind::Impl{ of_trait: Some(_), .. } |
94-
ItemKind::Trait(..))
95-
{
93+
if matches!(
94+
item.kind,
95+
ItemKind::Impl { of_trait: Some(_), .. } | ItemKind::Trait(..)
96+
) {
9697
return;
9798
}
9899
}

0 commit comments

Comments
 (0)