Use new macro instead

This commit is contained in:
Guillaume Gomez 2017-06-12 18:58:11 +02:00
parent deb1eb6134
commit 9137153e47

View File

@ -120,10 +120,10 @@ fn make_invalid_casting_error<'a, 'gcx, 'tcx>(sess: &'a Session,
cast_ty: Ty<'tcx>, cast_ty: Ty<'tcx>,
fcx: &FnCtxt<'a, 'gcx, 'tcx>) fcx: &FnCtxt<'a, 'gcx, 'tcx>)
-> DiagnosticBuilder<'a> { -> DiagnosticBuilder<'a> {
struct_span_err!(sess, span, E0606, type_error_struct!(sess, span, expr_ty, E0606,
"casting `{}` as `{}` is invalid", "casting `{}` as `{}` is invalid",
fcx.ty_to_string(expr_ty), fcx.ty_to_string(expr_ty),
fcx.ty_to_string(cast_ty)) fcx.ty_to_string(cast_ty))
} }
impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
@ -212,11 +212,11 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
.emit(); .emit();
} }
CastError::CastToChar => { CastError::CastToChar => {
struct_span_err!(fcx.tcx.sess, self.span, E0604, type_error_struct!(fcx.tcx.sess, self.span, self.expr_ty, E0604,
"only `u8` can be cast as `char`, not `{}`", self.expr_ty).emit(); "only `u8` can be cast as `char`, not `{}`", self.expr_ty).emit();
} }
CastError::NonScalar => { CastError::NonScalar => {
struct_span_err!(fcx.tcx.sess, self.span, E0605, type_error_struct!(fcx.tcx.sess, self.span, self.expr_ty, E0605,
"non-primitive cast: `{}` as `{}`", "non-primitive cast: `{}` as `{}`",
self.expr_ty, self.expr_ty,
fcx.ty_to_string(self.cast_ty)) fcx.ty_to_string(self.cast_ty))
@ -225,7 +225,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
.emit(); .emit();
} }
CastError::SizedUnsizedCast => { CastError::SizedUnsizedCast => {
struct_span_err!(fcx.tcx.sess, self.span, E0607, type_error_struct!(fcx.tcx.sess, self.span, self.expr_ty, E0607,
"cannot cast thin pointer `{}` to fat pointer `{}`", "cannot cast thin pointer `{}` to fat pointer `{}`",
self.expr_ty, self.expr_ty,
fcx.ty_to_string(self.cast_ty)).emit(); fcx.ty_to_string(self.cast_ty)).emit();