Simplify Debug display of DebugName#21870
Merged
mockersf merged 3 commits intobevyengine:mainfrom Nov 26, 2025
Merged
Conversation
crates/bevy_utils/src/debug_info.rs
Outdated
| #[cfg(feature = "debug")] | ||
| write!(f, "{:?}", self.name.as_ref())?; | ||
| #[cfg(not(feature = "debug"))] | ||
| f.debug_struct("DebugName").finish()?; |
Member
There was a problem hiding this comment.
Maybe tell the user they can enable the debug feature to read the actual name?
Contributor
Author
There was a problem hiding this comment.
Maybe tell the user they can enable the
debugfeature to read the actual name?
Yeah, that's a good idea! I had been trying to keep it consistent with the old version, but you're right that it's better to include the message. That also simplifies the implementation, since it can just use Deref.
ickshonpe
approved these changes
Nov 17, 2025
Contributor
ickshonpe
left a comment
There was a problem hiding this comment.
Looks good to me, maybe with the debug feature prompt suggested by janhohenheim.
janhohenheim
approved these changes
Nov 18, 2025
mockersf
approved these changes
Nov 26, 2025
beicause
pushed a commit
to beicause/bevy
that referenced
this pull request
Nov 26, 2025
# Objective As noted in bevyengine#21856, the `Debug` output of `DebugName` is too verbose. It is supposed to be a thin wrapper around a string, but it renders as a `struct`. ## Solution Manually `impl Debug for DebugName` and write the string directly. ## Showcase The following code ```rust #[derive(Debug)] struct TestStruct { debug_name: DebugName, } let test_struct = TestStruct { debug_name: DebugName::type_name::<TestStruct>(), }; println!("{test_struct:#?}"); ``` Prints the following before this change ``` TestStruct { debug_name: DebugName { name: "crate_name::TestStruct", }, } ``` And the following after it ``` TestStruct { debug_name: "crate_name::TestStruct", } ``` When the `debug` feature is disabled, it prints the following both before and after the change ``` TestStruct { debug_name: DebugName, } ``` --------- Co-authored-by: François Mockers <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
As noted in #21856, the
Debugoutput ofDebugNameis too verbose. It is supposed to be a thin wrapper around a string, but it renders as astruct.Solution
Manually
impl Debug for DebugNameand write the string directly.Showcase
The following code
Prints the following before this change
And the following after it
When the
debugfeature is disabled, it prints the following both before and after the change