-
Notifications
You must be signed in to change notification settings - Fork 82
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 generic_const_exprs
#368
Conversation
/// The length of the bitmask array. | ||
const BYTES: usize; | ||
/// The bitmask array. | ||
type BitMaskArray; |
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 should have some useful bounds, such as Copy + Unpin + Send + Sync + 'static + AsRef<[u8]> + AsMut<[u8]> + BorrowMut<[u8]>
and maybe more
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.
Would adding more bounds in the future be backwards compatible?
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.
No, bounds can only be relaxed backwards-compatibly, and only sometimes. They cannot be added, so forward-compatibility requires maximum bounds.
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.
Is that still true when the trait is sealed?
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.
...that does change things a bit, since the major compat hazard is people referencing the type generically.
crates/core_simd/src/to_bytes.rs
Outdated
/// Convert SIMD vectors to vectors of bytes | ||
pub trait ToBytes: Sealed { | ||
/// This type, reinterpreted as bytes. | ||
type Bytes; |
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.
could use some bounds here too.
Inspired by the errors in #367 (caused by rust-lang/rust#116320) I've removed all instances of
generic_const_exprs
.For
ToBitMaskArray
, this was straightforward, simply use an associated type instead of an associated const. For the variousto_bytes
functions, this was more complicated. I now implemented aToBytes
trait over every individual vector type. In the future when const generics are more powerful, I'd hope this can be implemented generically.This effectively upgrades these functions to nightly, as they're currently disabled on core.