@@ -1136,18 +1136,16 @@ impl<'a> InferenceContext<'a> {
11361136 if self . diverges . is_always ( ) {
11371137 // we don't even make an attempt at coercion
11381138 self . table . new_maybe_never_var ( )
1139- } else {
1140- if let Some ( t) = expected. only_has_type ( & mut self . table ) {
1141- if self . coerce ( Some ( expr) , & TyBuilder :: unit ( ) , & t) . is_err ( ) {
1142- self . result . type_mismatches . insert (
1143- expr. into ( ) ,
1144- TypeMismatch { expected : t. clone ( ) , actual : TyBuilder :: unit ( ) } ,
1145- ) ;
1146- }
1147- t
1148- } else {
1149- TyBuilder :: unit ( )
1139+ } else if let Some ( t) = expected. only_has_type ( & mut self . table ) {
1140+ if self . coerce ( Some ( expr) , & TyBuilder :: unit ( ) , & t) . is_err ( ) {
1141+ self . result . type_mismatches . insert (
1142+ expr. into ( ) ,
1143+ TypeMismatch { expected : t. clone ( ) , actual : TyBuilder :: unit ( ) } ,
1144+ ) ;
11501145 }
1146+ t
1147+ } else {
1148+ TyBuilder :: unit ( )
11511149 }
11521150 }
11531151 }
@@ -1314,13 +1312,13 @@ impl<'a> InferenceContext<'a> {
13141312 } else {
13151313 param_ty
13161314 } ;
1317- if !coercion_target. is_unknown ( ) {
1318- if self . coerce ( Some ( arg) , & ty, & coercion_target) . is_err ( ) {
1319- self . result . type_mismatches . insert (
1320- arg . into ( ) ,
1321- TypeMismatch { expected : coercion_target , actual : ty . clone ( ) } ,
1322- ) ;
1323- }
1315+ if !coercion_target. is_unknown ( )
1316+ && self . coerce ( Some ( arg) , & ty, & coercion_target) . is_err ( )
1317+ {
1318+ self . result . type_mismatches . insert (
1319+ arg . into ( ) ,
1320+ TypeMismatch { expected : coercion_target , actual : ty . clone ( ) } ,
1321+ ) ;
13241322 }
13251323 }
13261324 }
0 commit comments