-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Descriptive error message for circular required components recursion #16648
Merged
alice-i-cecile
merged 6 commits into
bevyengine:main
from
SpecificProtagonist:recursive-required-components-error
Dec 11, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0b35eb7
Descriptive error message
SpecificProtagonist f8edcca
add help message
SpecificProtagonist e800e41
use ShortName
SpecificProtagonist bc40d61
Use Iter::position
SpecificProtagonist 3e88789
Update test
SpecificProtagonist 29bf588
Merge branch 'main' into recursive-required-components-error
SpecificProtagonist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,6 +227,7 @@ unsafe impl<C: Component> Bundle for C { | |
storages, | ||
required_components, | ||
0, | ||
&mut Vec::new(), | ||
); | ||
} | ||
|
||
|
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
I think doing this check before the
push
means you have one more level of recursion than is necessary.Like, if you register a component that requires itself, then the first time this is called the stack will be empty, and the second time it will have one element that it binds to
requiree
but an emptycheck
list. So it will pass on the second call, even though it had enough information to detect the error!The simplest thing to do might be to pass
self_id
toenforce_no_required_components_recursion
so that it doesn't need to dosplit_last()
.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.
Performance wise the extra recursion doesn't matter, as it's only in the panic case (unless I've misunderstood something).
Wouldn't make the code simpler either, as I would then have to append the
self_id
if the check fails so the full cycle is printed.