
# Objective Most of the impls derived for `#[derive(Reflect)]` have one set of type bounds per field, like so: ``` f32: ::bevy::reflect::FromReflect + ::bevy::reflect::TypePath + ::bevy::reflect::MaybeTyped + ::bevy::reflect::__macro_exports::RegisterForReflection, ``` If multiple fields have the same type, the bounds are repeated uselessly. This can only hurt compile time and clogs up the `cargo expand` output. Avoiding this will help with https://github.com/bevyengine/bevy/issues/19873. ## Solution Use a hashset when collecting the bounds to eliminate duplicates. ## Testing I used cargo expand to confirm the duplicate bounds are no longer produced. `-Zmacro-stats` outputs tells me this reduces the size of the `Reflect` code produced for `bevy_ui` from 1_544_696 bytes to 1_467_967 bytes, a 5% drop.
39 lines
1.1 KiB
TOML
39 lines
1.1 KiB
TOML
[package]
|
|
name = "bevy_reflect_derive"
|
|
version = "0.17.0-dev"
|
|
edition = "2024"
|
|
description = "Derive implementations for bevy_reflect"
|
|
homepage = "https://bevy.org"
|
|
repository = "https://github.com/bevyengine/bevy"
|
|
license = "MIT OR Apache-2.0"
|
|
keywords = ["bevy"]
|
|
|
|
[lib]
|
|
proc-macro = true
|
|
|
|
[features]
|
|
default = []
|
|
# When enabled, allows documentation comments to be processed by the reflection macros
|
|
documentation = []
|
|
# Enables macro logic related to function reflection
|
|
functions = []
|
|
|
|
[dependencies]
|
|
bevy_macro_utils = { path = "../../bevy_macro_utils", version = "0.17.0-dev" }
|
|
indexmap = "2.0"
|
|
proc-macro2 = "1.0"
|
|
quote = "1.0"
|
|
syn = { version = "2.0", features = ["full", "extra-traits"] }
|
|
uuid = { version = "1.13.1", features = ["v4"] }
|
|
|
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
|
# TODO: Assuming all wasm builds are for the browser. Require `no_std` support to break assumption.
|
|
uuid = { version = "1.13.1", default-features = false, features = ["js"] }
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[package.metadata.docs.rs]
|
|
rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"]
|
|
all-features = true
|