Skip to content

Commit

Permalink
Make a macro a const fn and remove outdated NB
Browse files Browse the repository at this point in the history
  • Loading branch information
tbu- committed Aug 30, 2015
1 parent 4bb9023 commit aad7ea6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
21 changes: 9 additions & 12 deletions src/librustc_trans/trans/adt.rs
Expand Up @@ -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
Expand All @@ -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[..] {
Expand All @@ -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[..] {
Expand Down
2 changes: 0 additions & 2 deletions src/libsyntax/ast.rs
Expand Up @@ -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,
Expand Down

0 comments on commit aad7ea6

Please sign in to comment.