Skip to content

Commit 3e99309

Browse files
committed
make any_pat! and u64_from_be_bytes_bench_impl! macros hygienic
1 parent 0ba15c9 commit 3e99309

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/librustc/middle/trans/_match.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,9 @@ fn extract_vec_elems<'a>(
796796
// matches should fit that sort of pattern or NONE (however, some of the
797797
// matches may be wildcards like _ or identifiers).
798798
macro_rules! any_pat (
799-
($m:expr, $pattern:pat) => (
799+
($m:expr, $col:expr, $pattern:pat) => (
800800
($m).iter().any(|br| {
801-
match br.pats.get(col).node {
801+
match br.pats.get($col).node {
802802
$pattern => true,
803803
_ => false
804804
}
@@ -807,11 +807,11 @@ macro_rules! any_pat (
807807
)
808808

809809
fn any_uniq_pat(m: &[Match], col: uint) -> bool {
810-
any_pat!(m, ast::PatBox(_))
810+
any_pat!(m, col, ast::PatBox(_))
811811
}
812812

813813
fn any_region_pat(m: &[Match], col: uint) -> bool {
814-
any_pat!(m, ast::PatRegion(_))
814+
any_pat!(m, col, ast::PatRegion(_))
815815
}
816816

817817
fn any_irrefutable_adt_pat(bcx: &Block, m: &[Match], col: uint) -> bool {

src/libstd/io/extensions.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,15 @@ mod bench {
508508
use prelude::*;
509509
use self::test::Bencher;
510510

511+
// why is this a macro? wouldn't an inlined function work just as well?
511512
macro_rules! u64_from_be_bytes_bench_impl(
512-
($size:expr, $stride:expr, $start_index:expr) =>
513+
($b:expr, $size:expr, $stride:expr, $start_index:expr) =>
513514
({
514515
use super::u64_from_be_bytes;
515516

516517
let data = Vec::from_fn($stride*100+$start_index, |i| i as u8);
517518
let mut sum = 0u64;
518-
b.iter(|| {
519+
$b.iter(|| {
519520
let mut i = $start_index;
520521
while i < data.len() {
521522
sum += u64_from_be_bytes(data.as_slice(), i, $size);
@@ -527,31 +528,31 @@ mod bench {
527528

528529
#[bench]
529530
fn u64_from_be_bytes_4_aligned(b: &mut Bencher) {
530-
u64_from_be_bytes_bench_impl!(4, 4, 0);
531+
u64_from_be_bytes_bench_impl!(b, 4, 4, 0);
531532
}
532533

533534
#[bench]
534535
fn u64_from_be_bytes_4_unaligned(b: &mut Bencher) {
535-
u64_from_be_bytes_bench_impl!(4, 4, 1);
536+
u64_from_be_bytes_bench_impl!(b, 4, 4, 1);
536537
}
537538

538539
#[bench]
539540
fn u64_from_be_bytes_7_aligned(b: &mut Bencher) {
540-
u64_from_be_bytes_bench_impl!(7, 8, 0);
541+
u64_from_be_bytes_bench_impl!(b, 7, 8, 0);
541542
}
542543

543544
#[bench]
544545
fn u64_from_be_bytes_7_unaligned(b: &mut Bencher) {
545-
u64_from_be_bytes_bench_impl!(7, 8, 1);
546+
u64_from_be_bytes_bench_impl!(b, 7, 8, 1);
546547
}
547548

548549
#[bench]
549550
fn u64_from_be_bytes_8_aligned(b: &mut Bencher) {
550-
u64_from_be_bytes_bench_impl!(8, 8, 0);
551+
u64_from_be_bytes_bench_impl!(b, 8, 8, 0);
551552
}
552553

553554
#[bench]
554555
fn u64_from_be_bytes_8_unaligned(b: &mut Bencher) {
555-
u64_from_be_bytes_bench_impl!(8, 8, 1);
556+
u64_from_be_bytes_bench_impl!(b, 8, 8, 1);
556557
}
557558
}

0 commit comments

Comments
 (0)