Reuse Integer::from_attr
This commit is contained in:
parent
273025675d
commit
eb18d39a04
1 changed files with 6 additions and 5 deletions
|
@ -23,7 +23,7 @@ use rustc::hir::map::blocks::FnLikeNode;
|
||||||
use rustc::middle::region;
|
use rustc::middle::region;
|
||||||
use rustc::infer::InferCtxt;
|
use rustc::infer::InferCtxt;
|
||||||
use rustc::ty::subst::Subst;
|
use rustc::ty::subst::Subst;
|
||||||
use rustc::ty::{self, Ty, TyCtxt};
|
use rustc::ty::{self, Ty, TyCtxt, layout};
|
||||||
use rustc::ty::subst::Substs;
|
use rustc::ty::subst::Substs;
|
||||||
use syntax::ast::{self, LitKind};
|
use syntax::ast::{self, LitKind};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
|
@ -153,11 +153,12 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
||||||
&self,
|
&self,
|
||||||
ty: Ty,
|
ty: Ty,
|
||||||
) -> u64 {
|
) -> u64 {
|
||||||
match ty.sty {
|
let ty = match ty.sty {
|
||||||
ty::TyInt(ity) => ity.bit_width(),
|
ty::TyInt(ity) => attr::IntType::SignedInt(ity),
|
||||||
ty::TyUint(uty) => uty.bit_width(),
|
ty::TyUint(uty) => attr::IntType::UnsignedInt(uty),
|
||||||
_ => bug!("{} is not an integer", ty),
|
_ => 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(
|
pub fn const_eval_literal(
|
||||||
|
|
Loading…
Reference in a new issue