-
Notifications
You must be signed in to change notification settings - Fork 89
Add no_std Support
#216
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
base: main
Are you sure you want to change the base?
Add no_std Support
#216
Conversation
I'd rather this be explicit; either just have users get an error when they use the derive macro without std, or potentially have a default std feature that turns on the recursion counter. |
Allows the `derive` feature in `no_std`
I've added an explicitly named |
|
I'd also wantthe other maintainers to look at this |
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.
LGTM but if we are going to do a breaking change, then we should just bump the MSRV and avoid the cargo features for core::error::Error and all that, IMO.
We should also bundle any other breaking changes we might want at the same time.
Notably, this seems like an opportunity to clean up the size hint methods. (This PR is, ofc, not expected to do that, I'm just musing out loud.) |
Perfectly happy to update this PR to just bump the MSRV. Just wasn't sure how controversial that would be. Would an MSRV of 1.81 be challenging for any of the major consumers of this crate? I know WGPU is now on 1.82 with blessing from Mozilla, but not sure about the others. |
Filed #217 for this discussion. |
We can't do it often, so if we are doing a breaking change anyways, we should just take it all the way to the latest stable. |
n.b. splitting features whilst keeping them in default features is often not considered breaking since no-default-features users are not common and the ones that break can be fixed from afar. we may wish to consider doing that. though as a dev tool there's not really a huge downside to a new major release. and we can have |
|
IMO it would be fine to go all the way to the most recent version(s) too. If anybody has lower MSRVs they can hold off on updating The more significant issue with a breaking change is that arbitrary is similar in principle to a foundational crate, meaning that the ecosystem will have to migrate quickly & at a similar time in order to make upgrading not painful ( |
|
Since |
|
Interestingly, |
Agreed. Our ecosystem is obviously not as big as So I wouldn't say this is "just" a dev tool. (Where as That said, I don't think it is unreasonable to consider a breaking release since this PR is valuable, we have a few other things we'd like to do at the same time, and we aren't doing breaking changes frequently enough that we have used up all of our users patience and goodwill.
I personally would not do this work, but if someone else wanted to I'd be up for reviewing and merging it. |
As highlighted, these are not things the ecosystem has broad agreement on as being breaking, and with the latest cargo resolver the MSRV thing is basically non-breaking. (My position is that neither are breaking in a way that requires a major release) |
I think it is fuzzy and I don't necessarily disagree, but I think that since it already is a little fuzzy, and we have some API warts that we haven't otherwise had a chance to clean up, we might as well roll them all up together and do a breaking release. Are you against doing that? Or would you prefer landing this as a non-breaking change first, and then doing the definitely-breaking changes in a new breaking release afterwards? |
|
I am not against doing a breaking release, I just wanted us to fully consider our options. If we have a bunch of breaking changes to bundle, let's do that. |
Objective
no_stdcompilation (updated) #177Solution
#![no_std]unconditionally (to ensure a consistent implicit prelude)stdandallocfeatures to conditionally enable access to thestdandalloccrates respectively.check_no_stdwhich checks forno_stdcompatibility using a target which does not have access tostd(x86_64-unknown-noneis chosen arbitrarily, any appropriate target could be used instead).alloc_instead_of_core,std_instead_of_alloc, andstd_instead_of_coreClippy lints to help maintainno_stdcompatibility.extern crate std;statement, allowing compilation withinno_stdlibraries onstd-compatible targets.recursive_countfeature to the main and derive crates, which allows usingderiveon all platforms.allocandcoreoverstdwhere possible.Arcbehindtarget_has_atomic = "ptr", allowing compilation on atomically challenged platforms (typical for embedded).no_stdsupport.Migration Guide
MSRV Increased
The MSRV has increased from 1.63 to 1.81. If you are unable to upgrade your Rust compiler, consider pinning to an earlier version of
arbitrary.Existing Functionality Gated
If you have disabled default features but rely on functionality now gated behind the
stdand/orrecursive_countfeatures, enable them.Notes
I've been working on
no_stdsupport for the Bevy game engine and WGPU.arbitraryis used by WGPU and may become an issue forno_stdefforts in the future. In general, I believe it's good practice to remove reliance onstdwhen possible, even if it isn't strictly necessary (it has been noted that fuzzing requires substantially more effort without the standard library, so there is a reluctance to go to the trouble of maintaining this support). With the added lints, it is my experience that maintainingno_stdsupport is of minimal concern even for maintainers without previousno_stdexposure.