-
Notifications
You must be signed in to change notification settings - Fork 183
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
Remove num_traits
dependency
#3373
Conversation
5d03255
to
5febab2
Compare
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not opposed to a patch release, also not in a position where I particularly need one here.
@@ -72,7 +72,7 @@ pub const EXTRA_EXPERIMENTAL_DEPS: &[&str] = &[ | |||
]; | |||
|
|||
/// Dependencies allowed when opting in to LSTM segmenter | |||
pub const EXTRA_LSTM_DEPS: &[&str] = &["libm", "num-traits"]; | |||
pub const EXTRA_LSTM_DEPS: &[&str] = &["libm"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: thanks for updating this.
(I have plans to make this file complain if an allowlisted dep goes completely unused after all of the checks, but it's not priority)
// let clients provide these functions. | ||
impl CoreFloat for f32 { | ||
fn exp(self) -> Self { | ||
libm::expf(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: before we introduced libm via num-traits, we had been using the f32::exp function. Now we're unconditionally using the libm version. Explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we? In std mode this would fall back to f32.exp()
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we were either using the inherent f32::exp
, or num_traits::Float::f32
, which is backed by libm
. This is doing the exact same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we introduced num_traits
we weren't no_std
. With std
, function resolution will use f32::exp
, without it will use CoreFloat::exp
.
Similar to #3369, the
num_traits
dependency doesn't add anything, and we only pull it in to getlibm
.Ideally we wouldn't need that dependency, but rust-lang/rfcs#2505 isn't moving. Currently Rust is in the unfortunate position that any
#[no_std]
build needs to use the Rustlibm
implementation, even if a more efficient native libm is available.