-
Notifications
You must be signed in to change notification settings - Fork 3
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
restore no_std after diman_lib was split out #77
Conversation
crates/diman_lib/src/magnitude.rs
Outdated
@@ -3,6 +3,8 @@ use core::{ | |||
ops::{Div, Mul}, | |||
}; | |||
|
|||
use crate::num_traits_reexport::*; // either Float or FloatCore |
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.
This is a stylistic choice that I have no attachment to. We could instead use Float
or FloatCore
depending on cfg.
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.
I think this needs to be
#[cfg(feature = "num-traits-libm")]
pub use num_traits::float::Float;
#[cfg(not(feature = "num-traits-libm"))]
pub use num_traits::float::FloatCore;
just to get rid of the warning.
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.
Ah, not testing no-std after diman_lib was my bad, sorry about that. I didn't realize that one could just use std in dependencies even if the crate is no_std
.
Thanks for the fix - from my side this looks good, except for the warning because of the glob import.
crates/diman_lib/src/magnitude.rs
Outdated
@@ -3,6 +3,8 @@ use core::{ | |||
ops::{Div, Mul}, | |||
}; | |||
|
|||
use crate::num_traits_reexport::*; // either Float or FloatCore |
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.
I think this needs to be
#[cfg(feature = "num-traits-libm")]
pub use num_traits::float::Float;
#[cfg(not(feature = "num-traits-libm"))]
pub use num_traits::float::FloatCore;
just to get rid of the warning.
When we added no_std (Tehforsch#60), crates/diman_lib did not yet exist. It's now missing the no_std annotation, which has allowed tests to pass (since the tests are all running for architectures that support std). Rust does not prevent no_std crates from calling crates that use std (this is confusing). Adding no_std to diman_lib moves the dependency on num-traits into diman_lib and we drop the ratio module when we don't have either std or num-traits-libm (since we need powf for it to work).
These methods are only available when one of these features is enabled.
I've fixed a few minor problems that came up and added a no_std build on |
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.
Looks good, thanks. And sorry about the issues in the first version and taking a while to circle back.
// For some reason, this use statement is never recognized as used | ||
// even when I build the crates with no std, where removing the use | ||
// statement means that powi below cannot be used. | ||
#[allow(unused)] | ||
#[cfg(not(any(feature = "std")))] | ||
use num_traits::float::FloatCore; |
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.
A minimized version of this issue: rust-lang/rust#127852 (comment)
No worries! |
When we added no_std (#60), crates/diman_lib did not yet exist. It's now missing the no_std annotation, which has allowed tests to pass (since the tests are all running for architectures that support std). Rust does not prevent no_std crates from calling crates that use std (this is confusing).
Adding no_std to diman_lib moves the dependency on num-traits into diman_lib and we drop the ratio module when we don't have either std or num-traits-libm (since we need powf for it to work).
I've tested this with
--target=nvptx64-nvidia-cuda
.