@@ -129,22 +129,27 @@ pub enum TypeOrigin {
129
129
EquatePredicate ( Span ) ,
130
130
}
131
131
132
- impl fmt:: Display for TypeOrigin {
133
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
134
- let msg = match self {
135
- & TypeOrigin :: Misc ( _) => "mismatched types" ,
136
- & TypeOrigin :: MethodCompatCheck ( _) => "method not compatible with trait" ,
132
+ impl TypeOrigin {
133
+ fn as_str ( & self ) -> & ' static str {
134
+ match self {
135
+ & TypeOrigin :: Misc ( _) |
136
+ & TypeOrigin :: RelateSelfType ( _) |
137
+ & TypeOrigin :: RelateOutputImplTypes ( _) |
137
138
& TypeOrigin :: ExprAssignable ( _) => "mismatched types" ,
138
139
& TypeOrigin :: RelateTraitRefs ( _) => "mismatched traits" ,
139
- & TypeOrigin :: RelateSelfType ( _) => "mismatched types" ,
140
- & TypeOrigin :: RelateOutputImplTypes ( _) => "mismatched types" ,
140
+ & TypeOrigin :: MethodCompatCheck ( _) => "method not compatible with trait" ,
141
141
& TypeOrigin :: MatchExpressionArm ( _, _) => "match arms have incompatible types" ,
142
142
& TypeOrigin :: IfExpression ( _) => "if and else have incompatible types" ,
143
143
& TypeOrigin :: IfExpressionWithNoElse ( _) => "if may be missing an else clause" ,
144
144
& TypeOrigin :: RangeExpression ( _) => "start and end of range have incompatible types" ,
145
145
& TypeOrigin :: EquatePredicate ( _) => "equality predicate not satisfied" ,
146
- } ;
147
- fmt:: Display :: fmt ( msg, f)
146
+ }
147
+ }
148
+ }
149
+
150
+ impl fmt:: Display for TypeOrigin {
151
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
152
+ fmt:: Display :: fmt ( self . as_str ( ) , f)
148
153
}
149
154
}
150
155
0 commit comments