Skip to content
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

Merged
merged 2 commits into from
Apr 24, 2023
Merged

Conversation

robertbastian
Copy link
Member

@robertbastian robertbastian commented Apr 21, 2023

Similar to #3369, the num_traits dependency doesn't add anything, and we only pull it in to get libm.

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 Rust libm implementation, even if a more efficient native libm is available.

@jira-pull-request-webhook

This comment was marked as spam.

@robertbastian robertbastian changed the title libm Remove num_traits dependency Apr 24, 2023
@robertbastian robertbastian marked this pull request as ready for review April 24, 2023 12:33
@robertbastian robertbastian requested review from a team, sffc, aethanyc and makotokato as code owners April 24, 2023 12:33
@robertbastian robertbastian removed request for a team, aethanyc, makotokato and sffc April 24, 2023 12:34
Copy link
Member

@Manishearth Manishearth left a 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"];
Copy link
Member

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)

@robertbastian robertbastian merged commit 15fb5d0 into unicode-org:main Apr 24, 2023
// let clients provide these functions.
impl CoreFloat for f32 {
fn exp(self) -> Self {
libm::expf(self)
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

@robertbastian robertbastian deleted the num_traits branch April 24, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants