create add_type_neq_err_label

This commit is contained in:
rchaser53 2019-04-09 20:49:17 +09:00
parent aeb1e39b2b
commit cbcbd2c3bb

View file

@ -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,