diff options
| author | rchaser53 <tayoshizawa29@gmail.com> | 2019-04-09 20:49:17 +0900 |
|---|---|---|
| committer | rchaser53 <tayoshizawa29@gmail.com> | 2019-04-09 20:49:17 +0900 |
| commit | cbcbd2c3bb52cd6c53c45a6a2476d510c892d2cc (patch) | |
| tree | 6691357b526c2d47d1fe341b6dc846ed9b8456cc | |
| parent | aeb1e39b2bc0745ef7550367ce7b50d2c3f84acf (diff) | |
create add_type_neq_err_label
| -rw-r--r-- | src/librustc_typeck/check/op.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 70c9d9ddee3..501d117db70 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -333,18 +333,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { lhs_ty); if !lhs_expr.span.eq(&rhs_expr.span) { - err.span_label(lhs_expr.span, lhs_ty.to_string()); - if let FnDef(..) = lhs_ty.sty { - err.span_label(lhs_expr.span, "did you forget `()`?"); - } - - err.span_label(rhs_expr.span, rhs_ty.to_string()); - if let FnDef(..) = rhs_ty.sty { - err.span_label(rhs_expr.span, "did you forget `()`?"); - } + self.add_type_neq_err_label(&mut err, lhs_expr.span, lhs_ty); + self.add_type_neq_err_label(&mut err, rhs_expr.span, rhs_ty); } - let mut suggested_deref = false; if let Ref(_, mut rty, _) = lhs_ty.sty { if { @@ -423,6 +415,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { (lhs_ty, rhs_ty, return_ty) } + fn add_type_neq_err_label( + &self, + err: &mut errors::DiagnosticBuilder<'_>, + span: Span, + ty: Ty<'tcx>, + ) { + err.span_label(span, ty.to_string()); + if let FnDef(..) = ty.sty { + err.span_label(span, "did you forget `()`?"); + } + } + fn check_str_addition( &self, expr: &'gcx hir::Expr, |
