-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 Implicit std
Prelude from no_std
Crates
#17086
Remove Implicit std
Prelude from no_std
Crates
#17086
Conversation
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.
Very reasonable diff: I like that this is more explicit and less likely to cause weird CI problems for contributors. Ping me when CI is behaving :)
Ooh, you've unlocked the next, harder level of CI. |
Patch relied on `ToString` which was not already imported anymore. Using `ToOwned` (which is imported) is equivalent. Expectation on `unsafe_code` fails now, so I've moved it closer to the unsafe-sites and now it seems fine?
Ok @alice-i-cecile I'm ready for the next attempt at merging this thing! |
Ok one last CI action is failing in the merge queue. Back to the IDE... |
The `run-examples-on-wasm` timeout appears unrelated to my PR, but this commit includes a fix for a warning noticed when running that action. Hoping it solves everything...somehow
Marking as ready again. I believe I have resolved all CI issues, but the |
Background
In
no_std
compatible crates, there is often anstd
feature which will allow access to the standard library. Currently, with thestd
feature enabled, thestd::prelude
is implicitly imported in all modules. With the feature disabled, instead thecore::prelude
is implicitly imported. This creates a subtle and pervasive issue wherealloc
items may be implicitly included (ifstd
is enabled), or must be explicitly included (ifstd
is not enabled).Objective
no_std
crates consistent regardless of what features are/not enabled.Solution
cfg_attr
"double negative"no_std
attribute with conditional compilation to includestd
as an external crate.Testing
Notes
I had previously used the "double negative" version of
no_std
based on general consensus that it was "cleaner" within the Rust embedded community. However, this implicit prelude issue likely was considered when forming this consensus. I believe the reason why is the items most affected by this issue are provided by thealloc
crate, which is rarely used within embedded but extensively used within Bevy.