diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..998b4ef --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,6 @@ +[build] +rustflags = ["-Clinker-plugin-lto", "-Clinker=clang-13", "-Clink-arg=-fuse-ld=lld-13"] +rustdocflags = ["--cfg", "docsrs"] + +[env] +CC = "clang-13" diff --git a/Cargo.toml b/Cargo.toml index 927888b..f95f9c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,10 +65,9 @@ cc = "1" criterion = { version = "0.3", features = ["html_reports"] } rand = "0.8" -[profile.test] -# run tests at high optimization to exercise typical codegen -opt-level = 3 - [profile.release] lto="thin" codegen-units=1 + +[package.metadata.docs.rs] +all-features = true diff --git a/rust-toolchain b/rust-toolchain index eb726a2..43c989b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2021-11-03 +1.56.1 diff --git a/src/lib.rs b/src/lib.rs index cbbefff..145728a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ #![doc = include_str!("../README.md")] -#![feature(doc_cfg)] +#![cfg_attr(docsrs, feature(doc_cfg))] use core::{ cmp, fmt, diff --git a/src/nalgebra.rs b/src/nalgebra.rs index 998f0b2..c988495 100644 --- a/src/nalgebra.rs +++ b/src/nalgebra.rs @@ -1,15 +1,4 @@ -#![cfg(any(feature = "nalgebra-v021"))] -macro_rules! forward_fn_const { - ($fast_ty:ident, $base_ty:ident - $(fn $fn_name:ident () -> Self ;)*) => { - $( - fn $fn_name () -> $fast_ty { - <$fast_ty>::new(<$base_ty>::$fn_name()) - } - )* - } -} - +#[cfg(any(feature = "nalgebra-v021", feature = "nalgebra-v029"))] macro_rules! impl_nalgebra { ($($fast_ty:ident, $base_ty:ident),* ; $nalgebra_version:path, $simba_version:path, $approx_version:path ; @@ -226,8 +215,8 @@ macro_rules! impl_nalgebra { fn min(self, other: Self) -> Self; } - forward_fn_const! { - $fast_ty, $base_ty + impl_nalgebra! { + @fn_consts $fast_ty, $base_ty fn pi() -> Self ; fn two_pi() -> Self ; fn frac_pi_2() -> Self ; @@ -366,10 +355,20 @@ macro_rules! impl_nalgebra { } )* }; + + (@fn_consts $fast_ty: ident, $base_ty: ident + $(fn $fn_name:ident () -> Self ;)* + ) => { + $( + fn $fn_name () -> $fast_ty { + <$fast_ty>::new(<$base_ty>::$fn_name()) + } + )* + }; } #[cfg(feature = "nalgebra-v021")] -#[doc(cfg(feature = "nalgebra-v021"))] +#[cfg_attr(docsrs, doc(cfg(feature = "nalgebra-v021")))] mod nalgebra_v021 { macro_rules! real_field { ($fast_ty:ident, $base_ty:ident) => { @@ -393,7 +392,7 @@ mod nalgebra_v021 { } #[cfg(feature = "nalgebra-v029")] -#[doc(cfg(feature = "nalgebra-v029"))] +#[cfg_attr(docsrs, doc(cfg(feature = "nalgebra-v029")))] mod nalgebra_v029 { macro_rules! real_field { ($fast_ty:ident, $base_ty:ident) => { diff --git a/src/num_traits.rs b/src/num_traits.rs index 796dd82..5cfa6c8 100644 --- a/src/num_traits.rs +++ b/src/num_traits.rs @@ -1,5 +1,5 @@ #![cfg(feature = "num-traits")] -#![doc(cfg(feature = "num-traits"))] +#![cfg_attr(docsrs, doc(cfg(feature = "num-traits")))] use crate::{FF32, FF64}; use core::num::FpCategory;