Skip to content

Commit b5a2f29

Browse files
committed
Fix clippy::match_like_matches_macro
1 parent 8320183 commit b5a2f29

File tree

5 files changed

+17
-39
lines changed

5 files changed

+17
-39
lines changed

chalk-engine/src/context.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ pub enum AnswerResult<I: Interner> {
2727

2828
impl<I: Interner> AnswerResult<I> {
2929
pub fn is_answer(&self) -> bool {
30-
match self {
31-
Self::Answer(_) => true,
32-
_ => false,
33-
}
30+
matches!(self, Self::Answer(_))
3431
}
3532

3633
pub fn answer(self) -> CompleteAnswer<I> {
@@ -41,17 +38,11 @@ impl<I: Interner> AnswerResult<I> {
4138
}
4239

4340
pub fn is_no_more_solutions(&self) -> bool {
44-
match self {
45-
Self::NoMoreSolutions => true,
46-
_ => false,
47-
}
41+
matches!(self, Self::NoMoreSolutions)
4842
}
4943

5044
pub fn is_quantum_exceeded(&self) -> bool {
51-
match self {
52-
Self::QuantumExceeded => true,
53-
_ => false,
54-
}
45+
matches!(self, Self::QuantumExceeded)
5546
}
5647
}
5748

chalk-ir/src/lib.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -486,26 +486,20 @@ impl<I: Interner> Ty<I> {
486486

487487
/// Returns true if this is an `Alias`.
488488
pub fn is_alias(&self, interner: I) -> bool {
489-
match self.kind(interner) {
490-
TyKind::Alias(..) => true,
491-
_ => false,
492-
}
489+
matches!(self.kind(interner), TyKind::Alias(..))
493490
}
494491

495492
/// Returns true if this is an `IntTy` or `UintTy`.
496493
pub fn is_integer(&self, interner: I) -> bool {
497-
match self.kind(interner) {
498-
TyKind::Scalar(Scalar::Int(_)) | TyKind::Scalar(Scalar::Uint(_)) => true,
499-
_ => false,
500-
}
494+
matches!(
495+
self.kind(interner),
496+
TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_))
497+
)
501498
}
502499

503500
/// Returns true if this is a `FloatTy`.
504501
pub fn is_float(&self, interner: I) -> bool {
505-
match self.kind(interner) {
506-
TyKind::Scalar(Scalar::Float(_)) => true,
507-
_ => false,
508-
}
502+
matches!(self.kind(interner), TyKind::Scalar(Scalar::Float(_)))
509503
}
510504

511505
/// Returns `Some(adt_id)` if this is an ADT, `None` otherwise

chalk-parse/src/ast.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,7 @@ pub enum FnArgs {
525525

526526
impl FnArgs {
527527
pub fn is_variadic(&self) -> bool {
528-
match self {
529-
Self::Variadic(..) => true,
530-
_ => false,
531-
}
528+
matches!(self, Self::Variadic(..))
532529
}
533530

534531
pub fn to_tys(self) -> Vec<Ty> {

chalk-recursive/src/fulfill.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ enum Outcome {
2626

2727
impl Outcome {
2828
fn is_complete(&self) -> bool {
29-
match *self {
30-
Outcome::Complete => true,
31-
_ => false,
32-
}
29+
matches!(self, Outcome::Complete)
3330
}
3431
}
3532

chalk-solve/src/clauses/builtin_traits/fn_family.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,12 @@ pub fn add_fn_trait_program_clauses<I: Interner>(
111111
}
112112
TyKind::Closure(closure_id, substitution) => {
113113
let closure_kind = db.closure_kind(*closure_id, substitution);
114-
let trait_matches = match (well_known, closure_kind) {
115-
(WellKnownTrait::Fn, ClosureKind::Fn) => true,
116-
(WellKnownTrait::FnMut, ClosureKind::FnMut)
117-
| (WellKnownTrait::FnMut, ClosureKind::Fn) => true,
118-
(WellKnownTrait::FnOnce, _) => true,
119-
_ => false,
120-
};
114+
let trait_matches = matches!(
115+
(well_known, closure_kind),
116+
(WellKnownTrait::Fn, ClosureKind::Fn)
117+
| (WellKnownTrait::FnMut, ClosureKind::FnMut | ClosureKind::Fn)
118+
| (WellKnownTrait::FnOnce, _)
119+
);
121120
if !trait_matches {
122121
return Ok(());
123122
}

0 commit comments

Comments
 (0)