Skip to content

Commit 7c8f545

Browse files
committed
Undo unnecessary bookkeeping from last commit
1 parent 180534f commit 7c8f545

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

Diff for: src/librustc_typeck/check/_match.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
420420
_ => result_ty
421421
};
422422

423-
let mut arm_tys = Vec::new();
424423
for (i, arm) in arms.iter().enumerate() {
425424
if let Some(ref e) = arm.guard {
426425
self.check_expr_has_type(e, tcx.types.bool);
427426
}
428427
let arm_ty = self.check_expr_with_expectation(&arm.body, expected);
429-
arm_tys.push(arm_ty);
430428

431429
if result_ty.references_error() || arm_ty.references_error() {
432430
result_ty = tcx.types.err;
@@ -458,8 +456,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
458456
// Special-case the first arm, as it has no "previous expressions".
459457
self.try_coerce(&arm.body, arm_ty, coerce_first)
460458
} else {
461-
let prev_arms = || arms[..i].iter().map(|arm| &*arm.body)
462-
.zip(arm_tys.iter().cloned());
459+
let prev_arms = || arms[..i].iter().map(|arm| &*arm.body);
463460
self.try_find_coercion_lub(origin, prev_arms, result_ty, &arm.body, arm_ty)
464461
};
465462

Diff for: src/librustc_typeck/check/coercion.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
664664
-> RelateResult<'tcx, Ty<'tcx>>
665665
// FIXME(eddyb) use copyable iterators when that becomes ergonomic.
666666
where E: Fn() -> I,
667-
I: IntoIterator<Item=(&'b hir::Expr, Ty<'tcx>)> {
667+
I: IntoIterator<Item=&'b hir::Expr> {
668668

669669
let prev_ty = self.resolve_type_vars_with_obligations(prev_ty);
670670
let new_ty = self.resolve_type_vars_with_obligations(new_ty);
@@ -703,7 +703,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
703703
}
704704

705705
// Reify both sides and return the reified fn pointer type.
706-
for (expr, _) in exprs().into_iter().chain(Some((new, new_ty))) {
706+
for expr in exprs().into_iter().chain(Some(new)) {
707707
// No adjustments can produce a fn item, so this should never trip.
708708
assert!(!self.tables.borrow().adjustments.contains_key(&expr.id));
709709
self.write_adjustment(expr.id, AdjustReifyFnPointer);
@@ -737,13 +737,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
737737
// Then try to coerce the previous expressions to the type of the new one.
738738
// This requires ensuring there are no coercions applied to *any* of the
739739
// previous expressions, other than noop reborrows (ignoring lifetimes).
740-
for (expr, expr_ty) in exprs() {
740+
for expr in exprs() {
741741
let noop = match self.tables.borrow().adjustments.get(&expr.id) {
742742
Some(&AdjustDerefRef(AutoDerefRef {
743743
autoderefs: 1,
744744
autoref: Some(AutoPtr(_, mutbl_adj)),
745745
unsize: None
746-
})) => match expr_ty.sty {
746+
})) => match self.node_ty(expr.id).sty {
747747
ty::TyRef(_, mt_orig) => {
748748
// Reborrow that we can safely ignore.
749749
mutbl_adj == mt_orig.mutbl
@@ -767,9 +767,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
767767
}
768768
}
769769

770-
match self.commit_if_ok(|_| apply(&mut coerce,
771-
&|| exprs().into_iter().map(|(e, _)| e),
772-
prev_ty, new_ty)) {
770+
match self.commit_if_ok(|_| apply(&mut coerce, &exprs, prev_ty, new_ty)) {
773771
Err(_) => {
774772
// Avoid giving strange errors on failed attempts.
775773
if let Some(e) = first_error {
@@ -787,7 +785,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
787785
}
788786
Ok((ty, adjustment)) => {
789787
if !adjustment.is_identity() {
790-
for (expr, _) in exprs() {
788+
for expr in exprs() {
791789
let previous = self.tables.borrow().adjustments.get(&expr.id).cloned();
792790
if let Some(AdjustNeverToAny(_)) = previous {
793791
self.write_adjustment(expr.id, AdjustNeverToAny(ty));

Diff for: src/librustc_typeck/check/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
28612861
// Only try to coerce-unify if we have a then expression
28622862
// to assign coercions to, otherwise it's () or diverging.
28632863
let result = if let Some(ref then) = then_blk.expr {
2864-
let res = self.try_find_coercion_lub(origin, || Some((&**then, then_ty)),
2864+
let res = self.try_find_coercion_lub(origin, || Some(&**then),
28652865
then_ty, else_expr, else_ty);
28662866

28672867
// In case we did perform an adjustment, we have to update
@@ -3594,18 +3594,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
35943594
let mut unified = self.next_ty_var();
35953595
let coerce_to = uty.unwrap_or(unified);
35963596

3597-
let mut arg_tys = Vec::new();
35983597
for (i, e) in args.iter().enumerate() {
35993598
let e_ty = self.check_expr_with_hint(e, coerce_to);
3600-
arg_tys.push(e_ty);
36013599
let origin = TypeOrigin::Misc(e.span);
36023600

36033601
// Special-case the first element, as it has no "previous expressions".
36043602
let result = if i == 0 {
36053603
self.try_coerce(e, e_ty, coerce_to)
36063604
} else {
3607-
let prev_elems = || args[..i].iter().map(|e| &**e)
3608-
.zip(arg_tys.iter().cloned());
3605+
let prev_elems = || args[..i].iter().map(|e| &**e);
36093606
self.try_find_coercion_lub(origin, prev_elems, unified, e, e_ty)
36103607
};
36113608

0 commit comments

Comments
 (0)