/// Infer type of expression with possibly implicit coerce to the expected type.
/// Return the type after possible coercion.
Infer type of expression with possibly implicit coerce to the expected type.
Return the type after possible coercion.
Infer type of expression with possibly implicit coerce to the expected type . Return the type after possible coercion .
pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) -> Ty {
        let ty = self.infer_expr_inner(expr, &expected);
        let ty = if !self.coerce(&ty, &expected.coercion_target()) {
            self.result
                .type_mismatches
                .insert(expr, TypeMismatch { expected: expected.ty.clone(), actual: ty.clone() });
            // Return actual type when type mismatch.
            // This is needed for diagnostic when return type mismatch.
            ty
        } else if expected.coercion_target() == &Ty::Unknown {
            ty
        } else {
            expected.ty.clone()
        };
        self.resolve_ty_as_possible(ty)
    }
pub ( super ) fn infer_expr_coerce ( & mut self , expr : ExprId , expected : & Expectation ) -> Ty { let ty = self . infer_expr_inner ( expr , & expected ) ; let ty = if ! self . coerce ( & ty , & expected . coercion_target ( ) ) { self . result . type_mismatches . insert ( expr , TypeMismatch { expected : expected . ty . clone ( ) , actual : ty . clone ( ) } ) ; // Return actual type when type mismatch. // This is needed for diagnostic when return type mismatch. ty } else if expected . coercion_target ( ) == & Ty :: Unknown { ty } else { expected . ty . clone ( ) } ; self . resolve_ty_as_possible ( ty ) }
Infer type of expression with possibly implicit coerce to the expected type.
Infer type of expression with possibly implicit coerce to the expected type .
&mut self
expr
ExprId
expected
&Expectation