Make a macro a const fn and remove outdated NB

This commit is contained in:
Tobias Bucher 2015-08-30 14:32:17 +02:00
parent 4bb90232da
commit aad7ea66da
2 changed files with 9 additions and 14 deletions

View file

@ -177,15 +177,12 @@ pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
repr
}
macro_rules! repeat_u8_as_u32 {
($name:expr) => { (($name as u32) << 24 |
($name as u32) << 16 |
($name as u32) << 8 |
($name as u32)) }
const fn repeat_u8_as_u32(val: u8) -> u32 {
(val as u32) << 24 | (val as u32) << 16 | (val as u32) << 8 | val as u32
}
macro_rules! repeat_u8_as_u64 {
($name:expr) => { ((repeat_u8_as_u32!($name) as u64) << 32 |
(repeat_u8_as_u32!($name) as u64)) }
const fn repeat_u8_as_u64(val: u8) -> u64 {
(repeat_u8_as_u32(val) as u64) << 32 | repeat_u8_as_u32(val) as u64
}
/// `DTOR_NEEDED_HINT` is a stack-local hint that just means
@ -203,8 +200,8 @@ pub const DTOR_NEEDED_HINT: u8 = 0x3d;
pub const DTOR_MOVED_HINT: u8 = 0x2d;
pub const DTOR_NEEDED: u8 = 0xd4;
pub const DTOR_NEEDED_U32: u32 = repeat_u8_as_u32!(DTOR_NEEDED);
pub const DTOR_NEEDED_U64: u64 = repeat_u8_as_u64!(DTOR_NEEDED);
pub const DTOR_NEEDED_U32: u32 = repeat_u8_as_u32(DTOR_NEEDED);
pub const DTOR_NEEDED_U64: u64 = repeat_u8_as_u64(DTOR_NEEDED);
#[allow(dead_code)]
pub fn dtor_needed_usize(ccx: &CrateContext) -> usize {
match &ccx.tcx().sess.target.target.target_pointer_width[..] {
@ -215,8 +212,8 @@ pub fn dtor_needed_usize(ccx: &CrateContext) -> usize {
}
pub const DTOR_DONE: u8 = 0x1d;
pub const DTOR_DONE_U32: u32 = repeat_u8_as_u32!(DTOR_DONE);
pub const DTOR_DONE_U64: u64 = repeat_u8_as_u64!(DTOR_DONE);
pub const DTOR_DONE_U32: u32 = repeat_u8_as_u32(DTOR_DONE);
pub const DTOR_DONE_U64: u64 = repeat_u8_as_u64(DTOR_DONE);
#[allow(dead_code)]
pub fn dtor_done_usize(ccx: &CrateContext) -> usize {
match &ccx.tcx().sess.target.target.target_pointer_width[..] {

View file

@ -1372,8 +1372,6 @@ pub struct TypeBinding {
pub span: Span,
}
// NB PartialEq method appears below.
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
pub struct Ty {
pub id: NodeId,