bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Prefer `core` and `alloc` over `std` where possible

Open alice-i-cecile opened this issue 3 years ago • 3 comments

What problem does this solve or what need does it fill?

Some less common platforms (e.g. Nintendo Switch, and likely other consoles), do not support the full Rust standard library. Bevy uses a number of features from the standard library, but it's unclear exactly which parts need to be disabled (or replaced) in order to achieve these ports.

What solution would you like?

Add and follow the three lints listed in https://github.com/rust-lang/rust-clippy/pull/9103.

This will have no effect on existing platforms (these are just re-exports), but will make it much clearer which crates (and features within crates) are no_std compatible.

We should enable these lints at the level of each crate in their lib.rs, in order to make the dev experience less frustrating due to desyncs with CI.

What alternative(s) have you considered?

Obviously, console devs can simply make these changes in their own fork. However, making this change comes at very little cost, and reduces the frustration of keeping forks synchronized.

Additional context

See this thread for discussion about no_std requirements for the official Switch target.

alice-i-cecile avatar Oct 26 '22 01:10 alice-i-cecile

I would add a O-Console label here, but we don't have one yet :P

alice-i-cecile avatar Oct 26 '22 01:10 alice-i-cecile

Real fast attempt applying this just to bevy_transform and bevy_time, found some quick blockers.

  • std::borrow::Cow only exists in std, no core equivalent exists
  • The lints fire on the PartialEq macro without no_std enabled

james7132 avatar Oct 26 '22 06:10 james7132

Cow seems to be available in alloc as alloc::borrow::Cow.

PatchMixolydic avatar Nov 13 '22 01:11 PatchMixolydic