Skip to content

Commit d0eea6f

Browse files
committed
review comments
1 parent ac9025c commit d0eea6f

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/librustc/hir/mod.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -1555,15 +1555,11 @@ impl Expr {
15551555
/// `ExprKind` of any given `Expr` for presentation don't have to care about `DropTemps`
15561556
/// beyond remembering to call this function before doing analysis on it.
15571557
pub fn peel_drop_temps(&self) -> &Self {
1558-
let mut base_expr = self;
1559-
loop {
1560-
match &base_expr.kind {
1561-
ExprKind::DropTemps(expr) => {
1562-
base_expr = &expr;
1563-
}
1564-
_ => return base_expr,
1565-
}
1558+
let mut expr = self;
1559+
while let ExprKind::DropTemps(inner) = &expr.kind {
1560+
expr = inner;
15661561
}
1562+
expr
15671563
}
15681564
}
15691565

src/librustc_typeck/check/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
109109
allow_two_phase: AllowTwoPhase)
110110
-> (Ty<'tcx>, Option<DiagnosticBuilder<'tcx>>) {
111111
let expected = self.resolve_type_vars_with_obligations(expected);
112-
let expr = expr.peel_drop_temps();
113112

114113
let e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase) {
115114
Ok(ty) => return (ty, None),
116115
Err(e) => e
117116
};
118117

118+
let expr = expr.peel_drop_temps();
119119
let cause = self.misc(expr.span);
120120
let expr_ty = self.resolve_type_vars_with_obligations(checked_ty);
121121
let mut err = self.report_mismatched_types(&cause, expected, expr_ty, e);

0 commit comments

Comments
 (0)