review comments

This commit is contained in:
Esteban Küber 2019-10-08 09:46:57 -07:00
parent ac9025c197
commit d0eea6ff6d
2 changed files with 5 additions and 9 deletions

View file

@ -1555,15 +1555,11 @@ impl Expr {
/// `ExprKind` of any given `Expr` for presentation don't have to care about `DropTemps`
/// beyond remembering to call this function before doing analysis on it.
pub fn peel_drop_temps(&self) -> &Self {
let mut base_expr = self;
loop {
match &base_expr.kind {
ExprKind::DropTemps(expr) => {
base_expr = &expr;
}
_ => return base_expr,
}
let mut expr = self;
while let ExprKind::DropTemps(inner) = &expr.kind {
expr = inner;
}
expr
}
}

View file

@ -109,13 +109,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
allow_two_phase: AllowTwoPhase)
-> (Ty<'tcx>, Option<DiagnosticBuilder<'tcx>>) {
let expected = self.resolve_type_vars_with_obligations(expected);
let expr = expr.peel_drop_temps();
let e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase) {
Ok(ty) => return (ty, None),
Err(e) => e
};
let expr = expr.peel_drop_temps();
let cause = self.misc(expr.span);
let expr_ty = self.resolve_type_vars_with_obligations(checked_ty);
let mut err = self.report_mismatched_types(&cause, expected, expr_ty, e);