Repository navigation
Closed
Description
This issue tracks breaking changes for rand_core v0.10 and other potential changes for v1.0.
Breaking changes scheduled for v0.10:
- Bump MSRV and Edition for
rand_corerand#1668 - Move rand_core::impls::* to le rand#1667
- Move fn read_adapter out of trait TryRngCore rand#1669
- Move OsRng down to rand rand#1674
- Simplify trait BlockRngCore and rename to Generator #26
- Remove optional feature serde #28
- Reduce block code #34
- Replace mod
lewithutils#38 - Revise index / reset / skip methods #44
- Let
RngCore: TryRngCore<Error = Infallible>#45 - Support
?Sizedtypes inRng*: TryRng*blanket impls #51 - Remove fn unwrap_mut #53
- Rename
(Try)RngCoreto(Try)Rng#54 - Use
core::error::Errorbound forTryRng::Error#58
Problematic/blocked changes (more likely to hit v2.0 than v1.0):
- Can we merge
BlockRng64andBlockRngwithimpl<R: BlockRngCore<Item = u64>> RngCore for BlockRng<R>?No; firstly because Rust does not yet recognise thatSee Reduce block code #34.R: BlockRngCore<Item = u32>is distinct fromR: BlockRngCore<Item = u64>and secondly becauseBlockRng64has ahalf_usedfield. - Can we replace usages of
UnwrapMutwithUnwrapErr<&mut Self>?It appears not since we don't haveSee Letimpl<R: TryRngCore> TryRngCore for &mut R(see next item).RngCore: TryRngCore<Error = Infallible>#45, Remove fn unwrap_mut #53. - Can we have
impl<R: RngCore> RngCore for &mut R?No; it conflicts withSee Letimpl<R: RngCore + ?Sized> TryRngCore for Rsince Rust does not yet support overlapping blanket impls (e.g. specialisation).RngCore: TryRngCore<Error = Infallible>#45.
Other possible changes:
- Rename Rng -> RngExt, RngCore -> Rng rand#1288
- rand_core: introduce
Seedtrait rand#1670 - Further
blockmodule revisions. Little motivation in my opinion. - Tracker: proposed RngCore changes rand#1261
Reacted by Alexander Medvedev
Metadata
Metadata
Assignees
Labels
No labels
Activity
dhardy commentedon Oct 20, 2025
Non-API-breaking changes:
Default. This limitation may be fixed soon; see Use const generics for arrayDefaultimpl rust-lang/rust#61415.dhardy commentedon Nov 6, 2025
A pre-release of v0.10.0 is out now.
dhardy commentedon Nov 10, 2025
Everything on my to-do list for the next release is done so I opened a PR for v0.10: #22 (date: next Sunday).
If no issues crop up, I'd like to re-release the same code as v1.0 six weeks after
randv0.10 is published.rand_corev0.10.x would then become a compatibility shim over v1.0.newpavlov commentedon Nov 10, 2025
As I wrote previously, I would prefer to have a larger "cool down" period (1-2 years). Assuming that we will promote v0.10 to v1.0 without any changes, migration with the semver trick should be relatively transparent for downstream users. But it's not a strong opinion, so if others disagree, I would be fine with the six weeks plan.
tarcieri commentedon Nov 10, 2025
It’s difficult to bump all of the RustCrypto crates and requires a lot of coordination. I’m still not done, as it were. I’d personally prefer we do what newpavlov suggests.
dhardy commentedon Nov 14, 2025
The release of 0.10.0 will have to be delayed due to #24; we'll need a new pre-release and validation phase.
We can extend the 1.0 validation phase beyond six weeks, though 1-2 years is rather long in my opinion.
tarcieri commentedon Nov 22, 2025
If it's going to be longer than 6 weeks, I'd rather it be a year or longer. We don't want to be immediately cutting a bunch of breaking releases after bumping everything to
rand_corev0.10.That said, if it's only an additional 6 weeks after
rand_corev0.10, I can wait that long if it means we getrand_corev1 out of the deal.dhardy commentedon Nov 22, 2025
We seem to be making more extensive changes to
rand_corethan I had expected, so a long validation phase makes sense now.dhardy commentedon Nov 30, 2025
I'm considering a split stabilisation strategy: we keep only stable items (I think just traits
RngCore,CryptoRng) inrand_core, and move everything else to a new craterand_core_extraswhich pub-reexports everything fromrand_core. That way:rand_corev1.0 soonrand_corev0.9 torand_core_extras(or whatever we name it) v0.10rand_core_extrasversions, though seeding-support andReseedingRngsupport will take timerand_corein a patch releasenewpavlov commentedon Dec 15, 2025
There is one alternative design which I believe should be considered and explicitly rejected or approved before v1.0:
It should allow us to remove
UnwrapMutand to resolve the issue with overlapping impls. The main disadvantage (and why the approach was not used in the first place) is that infallible RNGs (i.e. most of RNG types in the wild) would have to implement theTryRngCore/TryCryptoRngtraits withError = Infallible, which is mildly annoying.newpavlov commentedon Dec 15, 2025
Also, while writing the previous comment, I noticed that we use
type Error: fmt::Debug + fmt::Display;. Maybe it's worth to replace it withtype Error: core::error::Error;?dhardy commentedon Dec 15, 2025
Thanks for the suggestion. Essentially it would mean that every
RngCorewould get a larger vtable (unless those methods areSelf: Sizedor optimised out). I guess this isn't a big deal, though it suggestsRngCoreneed not exist (except as an extension trait, i.e. with aSizedbound). But...... the reason
UnwrapMutexists is to allow a something fallible likeSysRngto implementRngCore(but panicking on error). I don't believe that works with this design.Aside from that, I don't believe you ever commented on my split-stabilisation strategy (above).
RngCorehas not changed since 0.9.0 so appears stable (and I had no plans to change it further) — though obviously this is incompatible with your new suggestion.newpavlov commentedon Dec 15, 2025
Yes, it's another drawback of the suggestion. I guess we could make
RngCorea sealed trait with blanket impl forTryRngCore<Error=!>, but such design looks IMO uglier and less transparent for users.On the first glance,
fn unwrap_mut(&mut) -> UnwrapErr<&mut Self>works since the proposal resolve the blanket impl conflicts. I did not implement the suggestion fully, so there may be some corner cases which I missed.As I wrote above, I would prefer to release rand_core v0.10 first and wait for a year or two before releasing v1.0.
Additionally, as I wrote in the previous discussions, I am not happy with the
Generatortrait, so it could be moved out ofrand_core. The block code is also may be moved with it, but it would be really unfortunate to have +1 dependency forchacha20andrandwith enabledThreadRng.tarcieri commentedon Dec 15, 2025
Having the associated
Errortype bound oncore::error::Errorseems good to me.Boiling
rand_coredown to just the traits sounds good enough for most of @RustCrypto's needs, though we are continuing to delay shipping a release that's probably at least a couple years in the making for v0.10. I would really, really, really like to be able to ship everything after v0.10, and not be further waiting for v1.0 after that.2 remaining items
tarcieri commentedon Dec 28, 2025
An alternative to this is to feature-gate functionality which isn't fully stable, and exempt it from SemVer.
You can give it a different versioning policy, e.g. it's stable at the minor version level.
The main drawback is feature unification might mean someone calls into such functionality without realizing it's unstable, because one of their dependencies implicitly activated the feature.
A separate crate is more explicit but is "yet another crate" and more incidental complexity.
If you just want to reserve the option to make breaking changes to some minor, not-commonly-used functionality in a v1 crate, I think putting it under something like an
unstablefeature which carries an explicit SemVer policy is enough to make such changes permissible while also allowing the 95%+ users who only care about the non-unstableAPI to enjoy a v1 crate.dhardy commentedon Dec 28, 2025
Agreed.
This sounds like a recipe for problems. Direct users of the feature-gated non-stable functionality may understand the issue, but downstream users of those crates may well not. E.g. if
rand_core::blockwere marked unstable we wouldn't be able to use it inchacha20orrandwithout certain risk of breaking people's builds shouldrand_core::blockever get API-breaking changes in a patch release (put another way, we would be unable to changerand_core::blockeven though it was marked as unstable).If we moved
utilsandblockto a new crate, thenrandand RNG crates would need to depend on it but nearly all downstream users would not. The new crate could be made obsolete in the future also.The bigger question is whether we are happy with the existing
RngCore/TryRngCoretraits, because if not we have nothing to stabilise. Theimplrelationship between them certainly isn't ideal.coltfred commentedon Jan 9, 2026
@dhardy I'm curious about the state of the 0.10.x release. I've spent a reasonable amount of time looking around and rand, getrandom, rand_core and the tracking issue on core about having getrandom essentially moved into std and I can't figure out where the lines for 0.10 (or maybe 1.0) are being drawn. We have various crates that are doing crypto operations and as such we depend heavily on rand (and the dalek-ed25519 crate).
I'm just trying to understand if we're looking at weeks, months or years for 0.10 (or 1.0).
I appreciate all your (and the other contributors) hard work on the rand ecosystem. It's always been a great ecosystem to work with for us and I know OSS can be a thankless job sometimes. 🙏
dhardy commentedon Jan 10, 2026
@coltfred the primary line being drawn for 0.10 is that we want to make it the last minor release and the last time we make significant changes before 1.0. I had hoped it would be unnecessary, but there has been a push to make various changes.
If you wish to help speed things along, feedback on open PRs like #41 and the current state of the
masterbranch would be very useful. Feedback on user requirements is very helpful to determining the direction we take for the core traits.coolreader18 commentedon Jan 20, 2026
I was going to suggest a way to improve the current situation wrt
RngCore/TryRngCore, but I ended up disagreeing with most of my own ideas. But hopefully this is useful as a summary of possible paths from this point onmaster?RngCoreaswhere Self: Sized, even if vtable size isn't a concern? It's not like there's any way the vtable version ofRngCore::next_u32could be faster than the generic version, since there's only ever thematch self.try_next_u32() { Ok(x) => x }implementation of the function.fn<R: RngCore + ?Sized>(r: &mut R) { r.next_u32(); }would no longer work.TryRngCorebut with awhere Self: RngCorebound? (AllowsRngCoreto be a pure trait alias)final fnis stabilized soon), and that doesn't solve the aboveSelf: Sizedproblem.RngCoreExttrait? (AllowsRngCoreto be a pure trait alias)rand::Rngandrand_core::RngCoreExt.rand::Rng? I think that was discussed already, but I do feel like calling those methods is probably not that common in crates that only depend onrand_core. That would be a removal of functionality from this crate, though.)dhardy commentedon Jan 20, 2026
I'm not sure there's much point using
?Sizedwhen passing&mut R(unless you really need to make the generics work here). More seriously,&mut dyn RngCorewould no longer have access to infallible methods.I tried that. Viable for us, though annoying since a bunch of RNG tests need adjusting.
I think the current approach (virtualisable methods on trait
RngCore) is good enough (unless someone can demonstrate a real issue with it).The intention is to release v0.10 "soon", then, if no significant issues come up, v1.0 around a year later. If something requiring significant breaking changes comes up then we'll consider a v0.11 but hopefully that won't be necessary.
tarcieri commentedon Jan 20, 2026
@dhardy the reason to use
&mut RwhereR: RngCore + ?Sizedis:newpavlov commentedon Jan 23, 2026
Another idea to consider for v1.0:
Unfortunately, it requires mutually exclusive traits which are unlikely to be stabilized in the mid-term.
dhardy commentedon Jan 23, 2026
@newpavlov this is supposed to be a tracker on progress towards 1.0, not an ideas list.
Interesting proposal but it is slightly leaky; e.g. replacing a 32-bit word RNG using
TryRngU32with a 64-bit word RNG would be API-breaking. (But it would also be value-breaking, so this is not really an issue.)newpavlov commentedon Jan 23, 2026
I think it's worth to have a list of ideas which may be potentially adapted by v1.0. Even if we decide against it (either by fully rejecting or postponing until potential v2.0), it will be useful to link in future.
BTW the issue description is outdated and probably should be updated.
Snowiiii commentedon Jan 27, 2026
When 0.10 is planned to release ?
[-]Tracker: rand_core v1.0[/-][+]Tracker: rand_core v0.10[/+]newpavlov commentedon Jan 27, 2026
I renamed the issue to track v0.10 since almost all items in the OP are about it. I think we should create a separate issue for v1.0 after v0.10 is released.
dhardy commentedon Feb 2, 2026
rand_corev0.10 is released now. Arandrelease should follow soon.