Skip to content

Replace interpolate_idents with stable code #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ default = []
into_bits = []

[dev-dependencies]
interpolate_idents = "0.2"
paste = "^0.1.3"
arrayvec = { version = "^0.4", default-features = false }

[target.'cfg(target_arch = "x86_64")'.dependencies.sleef-sys]
Expand Down
2 changes: 1 addition & 1 deletion micro_benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"

[dev-dependencies]
packed_simd = { path = ".." }
interpolate_idents = "0.2"
paste = "0.1.3"
criterion = "0.2"

[profile.bench]
Expand Down
15 changes: 7 additions & 8 deletions micro_benchmarks/benches/mask_reductions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Benchmarks for the mask reductions `all`, `any`, and `none`.
#![deny(warnings, rust_2018_idioms)]
#![feature(plugin, test)]
#![plugin(interpolate_idents)]
#![feature(test)]

use test::black_box;
use packed_simd::*;
Expand All @@ -11,8 +10,8 @@ const NO_ITERATIONS: u32 = 1_000;

macro_rules! bench {
($id:ident) => {
interpolate_idents! {
fn [ $id _all ](c: &mut Criterion) {
paste::item! {
fn [<$id _all>](c: &mut Criterion) {
c.bench(
stringify!($id),
Benchmark::new("all", |b| b.iter(|| {
Expand All @@ -25,7 +24,7 @@ macro_rules! bench {
})).throughput(Throughput::Elements(NO_ITERATIONS))
);
}
fn [ $id _any ](c: &mut Criterion) {
fn [<$id _any>](c: &mut Criterion) {
c.bench(
stringify!($id),
Benchmark::new("any", |b| b.iter(|| {
Expand All @@ -38,7 +37,7 @@ macro_rules! bench {
})).throughput(Throughput::Elements(NO_ITERATIONS))
);
}
fn [ $id _none ](c: &mut Criterion) {
fn [<$id _none>](c: &mut Criterion) {
c.bench(
stringify!($id),
Benchmark::new("none", |b| b.iter(|| {
Expand All @@ -55,10 +54,10 @@ macro_rules! bench {
};
($($id:ident),*) => {
$( bench!($id); )*
interpolate_idents! {
paste::item! {
criterion_group!(
benches,
$([$id _all]),*, $([$id _any]),*, $([$id _none]),*
$([<$id _all>]),*, $([<$id _any>]),*, $([<$id _none>]),*
);
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/api/cast/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ macro_rules! impl_from_cast_ {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _from_cast_ $from_ty] {
paste::item! {
pub mod [<$id _from_cast_ $from_ty>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn test() {
Expand Down Expand Up @@ -47,8 +47,8 @@ macro_rules! impl_from_cast_mask_ {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _from_cast_ $from_ty] {
paste::item! {
pub mod [<$id _from_cast_ $from_ty>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn test() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ macro_rules! impl_cmp_eq {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _cmp_eq] {
paste::item! {
pub mod [<$id _cmp_eq>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn eq() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ macro_rules! impl_cmp_ord {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _cmp_ord] {
paste::item! {
pub mod [<$id _cmp_ord>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn eq() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/cmp/partial_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ macro_rules! impl_cmp_partial_eq {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _cmp_PartialEq] {
paste::item! {
pub mod [<$id _cmp_PartialEq>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn partial_eq() {
Expand Down
8 changes: 4 additions & 4 deletions src/api/cmp/partial_ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ macro_rules! test_cmp_partial_ord_int {
([$elem_ty:ident; $elem_count:expr]: $id:ident | $test_tt:tt) => {
test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _cmp_PartialOrd] {
paste::item! {
pub mod [<$id _cmp_PartialOrd>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn partial_lex_ord() {
Expand Down Expand Up @@ -156,8 +156,8 @@ macro_rules! test_cmp_partial_ord_mask {
([$elem_ty:ident; $elem_count:expr]: $id:ident | $test_tt:tt) => {
test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _cmp_PartialOrd] {
paste::item! {
pub mod [<$id _cmp_PartialOrd>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn partial_lex_ord() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/cmp/vertical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ macro_rules! impl_cmp_vertical {
}
test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _cmp_vertical] {
paste::item! {
pub mod [<$id _cmp_vertical>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn cmp() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ macro_rules! impl_default {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _default] {
paste::item! {
pub mod [<$id _default>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn default() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/fmt/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ macro_rules! impl_fmt_binary {
}
test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _fmt_binary] {
paste::item! {
pub mod [<$id _fmt_binary>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn binary() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/fmt/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ macro_rules! impl_fmt_debug_tests {
([$elem_ty:ty; $elem_count:expr]: $id:ident | $test_tt:tt) => {
test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _fmt_debug] {
paste::item! {
pub mod [<$id _fmt_debug>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn debug() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/fmt/lower_hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ macro_rules! impl_fmt_lower_hex {
}
test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _fmt_lower_hex] {
paste::item! {
pub mod [<$id _fmt_lower_hex>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn lower_hex() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/fmt/octal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ macro_rules! impl_fmt_octal {
}
test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _fmt_octal] {
paste::item! {
pub mod [<$id _fmt_octal>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn octal_hex() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/fmt/upper_hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ macro_rules! impl_fmt_upper_hex {
}
test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _fmt_upper_hex] {
paste::item! {
pub mod [<$id _fmt_upper_hex>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn upper_hex() {
Expand Down
8 changes: 4 additions & 4 deletions src/api/from/from_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ macro_rules! impl_from_array {

test_if!{
$test_tt:
interpolate_idents! {
mod [$id _from] {
paste::item! {
mod [<$id _from>] {
use super::*;
#[test]
fn array() {
Expand Down Expand Up @@ -89,15 +89,15 @@ macro_rules! impl_from_array {
let array_from_vec = <[$elem_ty; $elem_count]>::from(vec);
// FIXME: Workaround for arrays with more than 32 elements.
for i in 0..$elem_count {
assert_eq!(array_from_vec[[i]], array[[i]]);
assert_eq!(array_from_vec[i], array[i]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so great! Thank you!

}

let vec_from_into_array: $id = array.into();
assert_eq!(vec_from_into_array, vec);
let array_from_into_vec: [$elem_ty; $elem_count] = vec.into();
// FIXME: Workaround for arrays with more than 32 elements.
for i in 0..$elem_count {
assert_eq!(array_from_into_vec[[i]], array[[i]]);
assert_eq!(array_from_into_vec[i], array[i]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/from/from_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ macro_rules! impl_from_vector {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _from_ $source] {
paste::item! {
pub mod [<$id _from_ $source>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn from() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ macro_rules! impl_hash {

test_if! {
$test_tt:
interpolate_idents! {
pub mod [$id _hash] {
paste::item! {
pub mod [<$id _hash>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn hash() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/into_bits/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ macro_rules! impl_from_bits_ {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _from_bits_ $from_ty] {
paste::item! {
pub mod [<$id _from_bits_ $from_ty>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn test() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/abs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ macro_rules! impl_math_float_abs {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_abs] {
paste::item! {
pub mod [<$id _math_abs>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn abs() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/cos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ macro_rules! impl_math_float_cos {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_cos] {
paste::item! {
pub mod [<$id _math_cos>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn cos() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/exp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ macro_rules! impl_math_float_exp {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_exp] {
paste::item! {
pub mod [<$id _math_exp>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn exp() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/ln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ macro_rules! impl_math_float_ln {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_ln] {
paste::item! {
pub mod [<$id _math_ln>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn ln() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/mul_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ macro_rules! impl_math_float_mul_add {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_mul_add] {
paste::item! {
pub mod [<$id _math_mul_add>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn mul_add() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/mul_adde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ macro_rules! impl_math_float_mul_adde {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_mul_adde] {
paste::item! {
pub mod [<$id _math_mul_adde>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn mul_adde() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/powf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ macro_rules! impl_math_float_powf {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_powf] {
paste::item! {
pub mod [<$id _math_powf>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn powf() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/recpre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ macro_rules! impl_math_float_recpre {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_recpre] {
paste::item! {
pub mod [<$id _math_recpre>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn recpre() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/rsqrte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ macro_rules! impl_math_float_rsqrte {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_rsqrte] {
paste::item! {
pub mod [<$id _math_rsqrte>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn rsqrte() {
Expand Down
4 changes: 2 additions & 2 deletions src/api/math/float/sin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ macro_rules! impl_math_float_sin {

test_if!{
$test_tt:
interpolate_idents! {
pub mod [$id _math_sin] {
paste::item! {
pub mod [<$id _math_sin>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn sin() {
Expand Down
Loading