diff options
| author | bors <bors@rust-lang.org> | 2015-08-30 14:15:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-08-30 14:15:42 +0000 |
| commit | 9a82594b8e3ecea019bb6b2045de6242ee2279ab (patch) | |
| tree | a9adc8299da7bfea92d8e0d0906b2a19ee6b20dd /src | |
| parent | 4bb90232daab451cf58359e0c5874bc905d2f101 (diff) | |
| parent | aad7ea66dac3dc6f133e90e6672a13cc5f71dd2f (diff) | |
| download | rust-9a82594b8e3ecea019bb6b2045de6242ee2279ab.tar.gz rust-9a82594b8e3ecea019bb6b2045de6242ee2279ab.zip | |
Auto merge of #28097 - tbu-:pr_macro_to_const_fn, r=eddyb
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_trans/trans/adt.rs | 21 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 2 |
2 files changed, 9 insertions, 14 deletions
diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index e425ffcaebf..de09e33ec14 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -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[..] { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 66faa1227e6..25a3540c743 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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, |
