Skip to content

Commit 9bba047

Browse files
committedMar 30, 2020
Use if let instead of match when only matching a single variant (clippy::single_match)
Makes code more compact and reduces nestig.
1 parent 8926bb4 commit 9bba047

File tree

48 files changed

+591
-751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+591
-751
lines changed
 

‎src/librustc_ast_lowering/item.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -1332,17 +1332,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
13321332
self.resolver.definitions().as_local_node_id(def_id)
13331333
{
13341334
for param in &generics.params {
1335-
match param.kind {
1336-
GenericParamKind::Type { .. } => {
1337-
if node_id == param.id {
1338-
add_bounds
1339-
.entry(param.id)
1340-
.or_default()
1341-
.push(bound.clone());
1342-
continue 'next_bound;
1343-
}
1335+
if let GenericParamKind::Type { .. } = param.kind {
1336+
if node_id == param.id {
1337+
add_bounds
1338+
.entry(param.id)
1339+
.or_default()
1340+
.push(bound.clone());
1341+
continue 'next_bound;
13441342
}
1345-
_ => {}
13461343
}
13471344
}
13481345
}

‎src/librustc_ast_passes/feature_gate.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -516,27 +516,25 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
516516
}
517517

518518
fn visit_generic_param(&mut self, param: &'a GenericParam) {
519-
match param.kind {
520-
GenericParamKind::Const { .. } => gate_feature_post!(
519+
if let GenericParamKind::Const { .. } = param.kind {
520+
gate_feature_post!(
521521
&self,
522522
const_generics,
523523
param.ident.span,
524524
"const generics are unstable"
525-
),
526-
_ => {}
525+
)
527526
}
528527
visit::walk_generic_param(self, param)
529528
}
530529

531530
fn visit_assoc_ty_constraint(&mut self, constraint: &'a AssocTyConstraint) {
532-
match constraint.kind {
533-
AssocTyConstraintKind::Bound { .. } => gate_feature_post!(
531+
if let AssocTyConstraintKind::Bound { .. } = constraint.kind {
532+
gate_feature_post!(
534533
&self,
535534
associated_type_bounds,
536535
constraint.span,
537536
"associated type bounds are unstable"
538-
),
539-
_ => {}
537+
)
540538
}
541539
visit::walk_assoc_ty_constraint(self, constraint)
542540
}

0 commit comments

Comments
 (0)