Skip to content

Commit

Permalink
Remove single use helper function.
Browse files Browse the repository at this point in the history
  • Loading branch information
leoyvens committed Apr 3, 2018
1 parent 21641d6 commit ba5a5cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
14 changes: 1 addition & 13 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2833,19 +2833,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
fn check_expr_coercable_to_type(&self,
expr: &'gcx hir::Expr,
expected: Ty<'tcx>) -> Ty<'tcx> {
self.check_expr_coercable_to_type_with_needs(expr, expected, Needs::None)
}

fn check_expr_coercable_to_type_with_needs(&self,
expr: &'gcx hir::Expr,
expected: Ty<'tcx>,
needs: Needs)
-> Ty<'tcx> {
let ty = self.check_expr_with_expectation_and_needs(
expr,
ExpectHasType(expected),
needs);
// checks don't need two phase
let ty = self.check_expr_with_hint(expr, expected);
self.demand_coerce(expr, ty, expected, AllowTwoPhase::No)
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_typeck/check/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// trait matching creating lifetime constraints that are too strict.
// E.g. adding `&'a T` and `&'b T`, given `&'x T: Add<&'x T>`, will result
// in `&'a T <: &'x T` and `&'b T <: &'x T`, instead of `'a = 'b = 'x`.
let lhs_ty = self.check_expr_coercable_to_type_with_needs(lhs_expr,
self.next_ty_var(TypeVariableOrigin::MiscVariable(lhs_expr.span)),
lhs_needs);
let lhs_ty = self.check_expr_with_needs(lhs_expr, lhs_needs);
let fresh_var = self.next_ty_var(TypeVariableOrigin::MiscVariable(lhs_expr.span));
let lhs_ty = self.demand_coerce(lhs_expr, lhs_ty, fresh_var, AllowTwoPhase::No);
let lhs_ty = self.resolve_type_vars_with_obligations(lhs_ty);

// NB: As we have not yet type-checked the RHS, we don't have the
Expand Down

0 comments on commit ba5a5cf

Please sign in to comment.