File tree Expand file tree Collapse file tree 5 files changed +17
-39
lines changed
chalk-solve/src/clauses/builtin_traits Expand file tree Collapse file tree 5 files changed +17
-39
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,7 @@ pub enum AnswerResult<I: Interner> {
27
27
28
28
impl < I : Interner > AnswerResult < I > {
29
29
pub fn is_answer ( & self ) -> bool {
30
- match self {
31
- Self :: Answer ( _) => true ,
32
- _ => false ,
33
- }
30
+ matches ! ( self , Self :: Answer ( _) )
34
31
}
35
32
36
33
pub fn answer ( self ) -> CompleteAnswer < I > {
@@ -41,17 +38,11 @@ impl<I: Interner> AnswerResult<I> {
41
38
}
42
39
43
40
pub fn is_no_more_solutions ( & self ) -> bool {
44
- match self {
45
- Self :: NoMoreSolutions => true ,
46
- _ => false ,
47
- }
41
+ matches ! ( self , Self :: NoMoreSolutions )
48
42
}
49
43
50
44
pub fn is_quantum_exceeded ( & self ) -> bool {
51
- match self {
52
- Self :: QuantumExceeded => true ,
53
- _ => false ,
54
- }
45
+ matches ! ( self , Self :: QuantumExceeded )
55
46
}
56
47
}
57
48
Original file line number Diff line number Diff line change @@ -486,26 +486,20 @@ impl<I: Interner> Ty<I> {
486
486
487
487
/// Returns true if this is an `Alias`.
488
488
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 ( ..) )
493
490
}
494
491
495
492
/// Returns true if this is an `IntTy` or `UintTy`.
496
493
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
+ )
501
498
}
502
499
503
500
/// Returns true if this is a `FloatTy`.
504
501
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 ( _) ) )
509
503
}
510
504
511
505
/// Returns `Some(adt_id)` if this is an ADT, `None` otherwise
Original file line number Diff line number Diff line change @@ -525,10 +525,7 @@ pub enum FnArgs {
525
525
526
526
impl FnArgs {
527
527
pub fn is_variadic ( & self ) -> bool {
528
- match self {
529
- Self :: Variadic ( ..) => true ,
530
- _ => false ,
531
- }
528
+ matches ! ( self , Self :: Variadic ( ..) )
532
529
}
533
530
534
531
pub fn to_tys ( self ) -> Vec < Ty > {
Original file line number Diff line number Diff line change @@ -26,10 +26,7 @@ enum Outcome {
26
26
27
27
impl Outcome {
28
28
fn is_complete ( & self ) -> bool {
29
- match * self {
30
- Outcome :: Complete => true ,
31
- _ => false ,
32
- }
29
+ matches ! ( self , Outcome :: Complete )
33
30
}
34
31
}
35
32
Original file line number Diff line number Diff line change @@ -111,13 +111,12 @@ pub fn add_fn_trait_program_clauses<I: Interner>(
111
111
}
112
112
TyKind :: Closure ( closure_id, substitution) => {
113
113
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
+ ) ;
121
120
if !trait_matches {
122
121
return Ok ( ( ) ) ;
123
122
}
You can’t perform that action at this time.
0 commit comments