
# Objective Let `bevy_utils` build with no default features. `cargo build -p bevy_utils --no-default-features` currently fails with ``` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `alloc` --> crates\bevy_utils\src\debug_info.rs:1:5 | 1 | use alloc::{borrow::Cow, fmt, string::String}; | ^^^^^ use of unresolved module or unlinked crate `alloc` | = help: add `extern crate alloc` to use the `alloc` crate error[E0432]: unresolved import `alloc` --> crates\bevy_utils\src\debug_info.rs:1:5 | 1 | use alloc::{borrow::Cow, fmt, string::String}; | ^^^^^ help: a similar path exists: `core::alloc` ``` I would have expected CI to catch this earlier, but I have not investigated why it did not. ## Solution Wrap the parts of `DebugName` that use `Cow` and `String` in `cfg::alloc!`. If the `debug` feature is enabled, then `DebugName` itself stores a `Cow`, so make the `debug` feature require `bevy_platform/alloc`. That is, you can use `DebugName` in no-std contexts when it's just a ZST! (I bet it's even possible to support no-std `debug` by storing `&'static str` instead of `Cow<'static, str>`, but that seemed like too much complexity for now.)
41 lines
1.0 KiB
TOML
41 lines
1.0 KiB
TOML
[package]
|
|
name = "bevy_utils"
|
|
version = "0.17.0-dev"
|
|
edition = "2024"
|
|
description = "A collection of utils for Bevy Engine"
|
|
homepage = "https://bevy.org"
|
|
repository = "https://github.com/bevyengine/bevy"
|
|
license = "MIT OR Apache-2.0"
|
|
keywords = ["bevy"]
|
|
|
|
[features]
|
|
default = ["parallel"]
|
|
|
|
wgpu_wrapper = ["dep:send_wrapper"]
|
|
|
|
# Provides access to the `Parallel` type.
|
|
parallel = ["bevy_platform/std", "dep:thread_local"]
|
|
|
|
std = ["disqualified/alloc"]
|
|
|
|
debug = ["bevy_platform/alloc"]
|
|
|
|
[dependencies]
|
|
bevy_platform = { path = "../bevy_platform", version = "0.17.0-dev", default-features = false }
|
|
|
|
disqualified = { version = "1.0", default-features = false }
|
|
thread_local = { version = "1.0", optional = true }
|
|
|
|
[target.'cfg(all(target_arch = "wasm32", target_feature = "atomics"))'.dependencies]
|
|
send_wrapper = { version = "0.6.0", optional = true }
|
|
|
|
[dev-dependencies]
|
|
static_assertions = "1.1.0"
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[package.metadata.docs.rs]
|
|
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
|
|
all-features = true
|