Enable rustc_pass_by_value for Span
This commit is contained in:
parent
22c3a71de1
commit
76b13c9eea
8 changed files with 28 additions and 22 deletions
|
@ -271,7 +271,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
ExprKind::Box(subexpr) => self.check_expr_box(subexpr, expected),
|
||||
ExprKind::Lit(ref lit) => self.check_lit(&lit, expected),
|
||||
ExprKind::Binary(op, lhs, rhs) => self.check_binop(expr, op, lhs, rhs),
|
||||
ExprKind::Assign(lhs, rhs, ref span) => {
|
||||
ExprKind::Assign(lhs, rhs, span) => {
|
||||
self.check_expr_assign(expr, expected, lhs, rhs, span)
|
||||
}
|
||||
ExprKind::AssignOp(op, lhs, rhs) => self.check_binop_assign(expr, op, lhs, rhs),
|
||||
|
@ -982,7 +982,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
expected: Expectation<'tcx>,
|
||||
lhs: &'tcx hir::Expr<'tcx>,
|
||||
rhs: &'tcx hir::Expr<'tcx>,
|
||||
span: &Span,
|
||||
span: Span,
|
||||
) -> Ty<'tcx> {
|
||||
let expected_ty = expected.coercion_target_type(self, expr.span);
|
||||
if expected_ty == self.tcx.types.bool {
|
||||
|
@ -1014,7 +1014,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
if eq {
|
||||
err.span_suggestion_verbose(
|
||||
*span,
|
||||
span,
|
||||
"you might have meant to compare for equality",
|
||||
"==".to_string(),
|
||||
applicability,
|
||||
|
@ -1031,7 +1031,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
return self.tcx.ty_error();
|
||||
}
|
||||
|
||||
self.check_lhs_assignable(lhs, "E0070", *span);
|
||||
self.check_lhs_assignable(lhs, "E0070", span);
|
||||
|
||||
let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace);
|
||||
let rhs_ty = self.check_expr_coercable_to_type(&rhs, lhs_ty, Some(lhs));
|
||||
|
|
|
@ -36,7 +36,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
let ty =
|
||||
if !lhs_ty.is_ty_var() && !rhs_ty.is_ty_var() && is_builtin_binop(lhs_ty, rhs_ty, op) {
|
||||
self.enforce_builtin_binop_types(&lhs.span, lhs_ty, &rhs.span, rhs_ty, op);
|
||||
self.enforce_builtin_binop_types(lhs.span, lhs_ty, rhs.span, rhs_ty, op);
|
||||
self.tcx.mk_unit()
|
||||
} else {
|
||||
return_ty
|
||||
|
@ -98,9 +98,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&& is_builtin_binop(lhs_ty, rhs_ty, op)
|
||||
{
|
||||
let builtin_return_ty = self.enforce_builtin_binop_types(
|
||||
&lhs_expr.span,
|
||||
lhs_expr.span,
|
||||
lhs_ty,
|
||||
&rhs_expr.span,
|
||||
rhs_expr.span,
|
||||
rhs_ty,
|
||||
op,
|
||||
);
|
||||
|
@ -114,9 +114,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
fn enforce_builtin_binop_types(
|
||||
&self,
|
||||
lhs_span: &Span,
|
||||
lhs_span: Span,
|
||||
lhs_ty: Ty<'tcx>,
|
||||
rhs_span: &Span,
|
||||
rhs_span: Span,
|
||||
rhs_ty: Ty<'tcx>,
|
||||
op: hir::BinOp,
|
||||
) -> Ty<'tcx> {
|
||||
|
@ -129,8 +129,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let tcx = self.tcx;
|
||||
match BinOpCategory::from(op) {
|
||||
BinOpCategory::Shortcircuit => {
|
||||
self.demand_suptype(*lhs_span, tcx.types.bool, lhs_ty);
|
||||
self.demand_suptype(*rhs_span, tcx.types.bool, rhs_ty);
|
||||
self.demand_suptype(lhs_span, tcx.types.bool, lhs_ty);
|
||||
self.demand_suptype(rhs_span, tcx.types.bool, rhs_ty);
|
||||
tcx.types.bool
|
||||
}
|
||||
|
||||
|
@ -141,13 +141,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
BinOpCategory::Math | BinOpCategory::Bitwise => {
|
||||
// both LHS and RHS and result will have the same type
|
||||
self.demand_suptype(*rhs_span, lhs_ty, rhs_ty);
|
||||
self.demand_suptype(rhs_span, lhs_ty, rhs_ty);
|
||||
lhs_ty
|
||||
}
|
||||
|
||||
BinOpCategory::Comparison => {
|
||||
// both LHS and RHS and result will have the same type
|
||||
self.demand_suptype(*rhs_span, lhs_ty, rhs_ty);
|
||||
self.demand_suptype(rhs_span, lhs_ty, rhs_ty);
|
||||
tcx.types.bool
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue