]> git.lizzy.rs Git - rust.git/commitdiff
Reuse `Integer::from_attr`
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Fri, 23 Feb 2018 12:39:41 +0000 (13:39 +0100)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 8 Mar 2018 07:35:38 +0000 (08:35 +0100)
src/librustc_mir/hair/cx/mod.rs

index 28eef70679b95f70138463574a4bda10d767188a..57aa7bd4afeef178d4749d5741d9a0ded05ba2f9 100644 (file)
@@ -23,7 +23,7 @@
 use rustc::middle::region;
 use rustc::infer::InferCtxt;
 use rustc::ty::subst::Subst;
-use rustc::ty::{self, Ty, TyCtxt};
+use rustc::ty::{self, Ty, TyCtxt, layout};
 use rustc::ty::subst::Substs;
 use syntax::ast::{self, LitKind};
 use syntax::attr;
@@ -153,11 +153,12 @@ pub fn type_bit_size(
         &self,
         ty: Ty,
     ) -> u64 {
-        match ty.sty {
-            ty::TyInt(ity) => ity.bit_width(),
-            ty::TyUint(uty) => uty.bit_width(),
+        let ty = match ty.sty {
+            ty::TyInt(ity) => attr::IntType::SignedInt(ity),
+            ty::TyUint(uty) => attr::IntType::UnsignedInt(uty),
             _ => bug!("{} is not an integer", ty),
-        }.map_or(self.tcx.data_layout.pointer_size.bits(), |n| n as u64)
+        };
+        layout::Integer::from_attr(self.tcx, ty).size().bits()
     }
 
     pub fn const_eval_literal(