-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix name conflicts caused by the
SystemParam
and WorldQuery
macros (
#8012) # Objective Fix #1727 Fix #8010 Meta types generated by the `SystemParam` and `WorldQuery` derive macros can conflict with user-defined types if they happen to have the same name. ## Solution In order to check if an identifier would conflict with user-defined types, we can just search the original `TokenStream` passed to the macro to see if it contains the identifier (since the meta types are defined in an anonymous scope, it's only possible for them to conflict with the struct definition itself). When generating an identifier for meta types, we can simply check if it would conflict, and then add additional characters to the name until it no longer conflicts with anything. The `WorldQuery` "Item" and read-only structs are a part of a module's public API, and thus it is intended for them to conflict with user-defined types.
- Loading branch information
Showing
6 changed files
with
111 additions
and
12 deletions.
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
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
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ keywords = ["bevy"] | |
toml_edit = "0.19" | ||
syn = "1.0" | ||
quote = "1.0" | ||
rustc-hash = "1.0" |
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