diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-01-04 02:14:53 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-01-04 02:32:39 +0200 |
| commit | 9599066dcbff6b78c97fed816cf183e1577acff2 (patch) | |
| tree | 55d59e4d6645c21fc33d10cb7da0d6a54b10c1d6 /src | |
| parent | 0a3761e63e5961ddd6ae5b9923e7a3c0725541f8 (diff) | |
rustc: remove misleading `Ty::is_uint` method.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/sty.rs | 7 | ||||
| -rw-r--r-- | src/librustc_typeck/check/cast.rs | 2 | ||||
| -rw-r--r-- | 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 |
