]> git.lizzy.rs Git - rust.git/commitdiff
rustc: remove misleading `Ty::is_uint` method.
authorEduard-Mihai Burtescu <edy.burt@gmail.com>
Thu, 4 Jan 2018 00:14:53 +0000 (02:14 +0200)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Thu, 4 Jan 2018 00:32:39 +0000 (02:32 +0200)
src/librustc/ty/sty.rs
src/librustc_typeck/check/cast.rs
src/test/ui/fat-ptr-cast.stderr

index 433c72f4b2ca67c503ccbb82974896d474c1f152..e7e1a349bd8739a1be841cfbf80670f61e4879ab 100644 (file)
@@ -1478,13 +1478,6 @@ pub fn is_fresh(&self) -> bool {
         }
     }
 
-    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,
index 7c199587c98981d385600b3154726469e501ca6c..201997a74b73f3b6e4561645d2dfc84630137678 100644 (file)
@@ -233,7 +233,7 @@ fn report_cast_error(&self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, e: CastError) {
             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",
index 35a97749e0024f3a23c7b8b4f6fff7ede41ce593..b3c2b23cd3272fdca6b4a38c14f1523fa1bc2869 100644 (file)
@@ -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