From 9599066dcbff6b78c97fed816cf183e1577acff2 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 4 Jan 2018 02:14:53 +0200 Subject: [PATCH] rustc: remove misleading `Ty::is_uint` method. --- src/librustc/ty/sty.rs | 7 ------- src/librustc_typeck/check/cast.rs | 2 +- src/test/ui/fat-ptr-cast.stderr | 6 ++++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 433c72f4b2c..e7e1a349bd8 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1478,13 +1478,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } } - pub fn is_uint(&self) -> bool { - match self.sty { - TyInfer(IntVar(_)) | TyUint(ast::UintTy::Us) => true, - _ => false - } - } - pub fn is_char(&self) -> bool { match self.sty { TyChar => true, diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 7c199587c98..201997a74b7 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -233,7 +233,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { CastError::NeedViaPtr => { let mut err = make_invalid_casting_error(fcx.tcx.sess, self.span, self.expr_ty, self.cast_ty, fcx); - if self.cast_ty.is_uint() { + if self.cast_ty.is_integral() { err.help(&format!("cast through {} first", match e { CastError::NeedViaPtr => "a raw pointer", diff --git a/src/test/ui/fat-ptr-cast.stderr b/src/test/ui/fat-ptr-cast.stderr index 35a97749e00..b3c2b23cd32 100644 --- a/src/test/ui/fat-ptr-cast.stderr +++ b/src/test/ui/fat-ptr-cast.stderr @@ -11,18 +11,24 @@ error[E0606]: casting `&[i32]` as `isize` is invalid | 21 | a as isize; //~ ERROR casting | ^^^^^^^^^^ + | + = help: cast through a raw pointer first error[E0606]: casting `&[i32]` as `i16` is invalid --> $DIR/fat-ptr-cast.rs:22:5 | 22 | a as i16; //~ ERROR casting `&[i32]` as `i16` is invalid | ^^^^^^^^ + | + = help: cast through a raw pointer first error[E0606]: casting `&[i32]` as `u32` is invalid --> $DIR/fat-ptr-cast.rs:23:5 | 23 | a as u32; //~ ERROR casting `&[i32]` as `u32` is invalid | ^^^^^^^^ + | + = help: cast through a raw pointer first error[E0605]: non-primitive cast: `std::boxed::Box<[i32]>` as `usize` --> $DIR/fat-ptr-cast.rs:24:5