Rollup merge of #76888 - matthiaskrgr:clippy_single_match_2, r=Dylan-DPC
use if let instead of single match arm expressions use if let instead of single match arm expressions to compact code and reduce nesting (clippy::single_match)
This commit is contained in:
commit
dcf4d1f2be
8 changed files with 28 additions and 58 deletions
|
@ -834,14 +834,11 @@ fn foo(&self) -> Self::T { String::new() }
|
|||
kind: hir::ItemKind::Impl { items, .. }, ..
|
||||
})) => {
|
||||
for item in &items[..] {
|
||||
match item.kind {
|
||||
hir::AssocItemKind::Type => {
|
||||
if self.type_of(self.hir().local_def_id(item.id.hir_id)) == found {
|
||||
db.span_label(item.span, "expected this associated type");
|
||||
return true;
|
||||
}
|
||||
if let hir::AssocItemKind::Type = item.kind {
|
||||
if self.type_of(self.hir().local_def_id(item.id.hir_id)) == found {
|
||||
db.span_label(item.span, "expected this associated type");
|
||||
return true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2125,17 +2125,10 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
|
|||
// Iterate all local crate items no matter where they are defined.
|
||||
let hir = tcx.hir();
|
||||
for item in hir.krate().items.values() {
|
||||
if item.ident.name.as_str().is_empty() {
|
||||
if item.ident.name.as_str().is_empty() || matches!(item.kind, ItemKind::Use(_, _)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match item.kind {
|
||||
ItemKind::Use(_, _) => {
|
||||
continue;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if let Some(local_def_id) = hir.definitions().opt_hir_id_to_local_def_id(item.hir_id) {
|
||||
let def_id = local_def_id.to_def_id();
|
||||
let ns = tcx.def_kind(def_id).ns().unwrap_or(Namespace::TypeNS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue