-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Improve TypeUuid's derive macro error messages #9315
Merged
alice-i-cecile
merged 3 commits into
bevyengine:main
from
tguichaoua:refactorize_derive_type_uuid
Oct 2, 2023
Merged
Improve TypeUuid's derive macro error messages #9315
alice-i-cecile
merged 3 commits into
bevyengine:main
from
tguichaoua:refactorize_derive_type_uuid
Oct 2, 2023
Conversation
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
alice-i-cecile
added
C-Code-Quality
A section of code that is hard to understand or change
A-Reflection
Runtime information about types
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
labels
Jul 31, 2023
mockersf
reviewed
Aug 1, 2023
mockersf
approved these changes
Aug 2, 2023
james7132
changed the title
Refactorize derive TypeUuid
Improve TypeUuid's derive macro error messages
Oct 2, 2023
james7132
approved these changes
Oct 2, 2023
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.
LGTM. It'd be nice to have a UX test (like bevy_ecs_compile_fail_tests
) for TypeUuid, but I won't block on that.
james7132
added
the
S-Ready-For-Final-Review
This PR has been approved by the community. It's ready for a maintainer to consider merging it
label
Oct 2, 2023
ameknite
pushed a commit
to ameknite/bevy
that referenced
this pull request
Oct 3, 2023
# Objective - Better error message - More idiomatic code ## Solution Refactorize `TypeUuid` macros to use `syn::Result` instead of panic. ## Before/After error messages ### Missing `#[uuid]` attribtue #### Before ``` error: proc-macro derive panicked --> src\main.rs:1:10 | 1 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` attribute found. ``` #### After ``` error: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]` attribute found. --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = note: this error originates in the derive macro `TypeUuid` (in Nightly builds, run with -Z macro-backtrace for more info) ``` ### Malformed attribute #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`. ``` #### After ``` error: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]`. --> src\main.rs:4:1 | 4 | #[uuid = 42] | ^^^^^^^^^^^^ ``` ### UUID parse fail #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: Value specified to `#[uuid]` attribute is not a valid UUID.: Error(SimpleLength { len: 3 }) ``` #### After ``` error: Invalid UUID: invalid length: expected length 32 for simple format, found 3 --> src\main.rs:4:10 | 4 | #[uuid = "000"] | ^^^^^ ``` ### With [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens) #### Before ![image](https://github.com/bevyengine/bevy/assets/33934311/415247fa-ff5c-4513-8012-7a9ff77445fb) #### After ![image](https://github.com/bevyengine/bevy/assets/33934311/d124eeaa-9213-49e0-8860-539ad0218a40) --- ## Changelog - `#[derive(TypeUuid)]` provide better error messages.
ameknite
pushed a commit
to ameknite/bevy
that referenced
this pull request
Oct 3, 2023
# Objective - Better error message - More idiomatic code ## Solution Refactorize `TypeUuid` macros to use `syn::Result` instead of panic. ## Before/After error messages ### Missing `#[uuid]` attribtue #### Before ``` error: proc-macro derive panicked --> src\main.rs:1:10 | 1 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` attribute found. ``` #### After ``` error: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]` attribute found. --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = note: this error originates in the derive macro `TypeUuid` (in Nightly builds, run with -Z macro-backtrace for more info) ``` ### Malformed attribute #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`. ``` #### After ``` error: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]`. --> src\main.rs:4:1 | 4 | #[uuid = 42] | ^^^^^^^^^^^^ ``` ### UUID parse fail #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: Value specified to `#[uuid]` attribute is not a valid UUID.: Error(SimpleLength { len: 3 }) ``` #### After ``` error: Invalid UUID: invalid length: expected length 32 for simple format, found 3 --> src\main.rs:4:10 | 4 | #[uuid = "000"] | ^^^^^ ``` ### With [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens) #### Before ![image](https://github.com/bevyengine/bevy/assets/33934311/415247fa-ff5c-4513-8012-7a9ff77445fb) #### After ![image](https://github.com/bevyengine/bevy/assets/33934311/d124eeaa-9213-49e0-8860-539ad0218a40) --- ## Changelog - `#[derive(TypeUuid)]` provide better error messages.
ameknite
pushed a commit
to ameknite/bevy
that referenced
this pull request
Oct 3, 2023
# Objective - Better error message - More idiomatic code ## Solution Refactorize `TypeUuid` macros to use `syn::Result` instead of panic. ## Before/After error messages ### Missing `#[uuid]` attribtue #### Before ``` error: proc-macro derive panicked --> src\main.rs:1:10 | 1 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` attribute found. ``` #### After ``` error: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]` attribute found. --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = note: this error originates in the derive macro `TypeUuid` (in Nightly builds, run with -Z macro-backtrace for more info) ``` ### Malformed attribute #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`. ``` #### After ``` error: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]`. --> src\main.rs:4:1 | 4 | #[uuid = 42] | ^^^^^^^^^^^^ ``` ### UUID parse fail #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: Value specified to `#[uuid]` attribute is not a valid UUID.: Error(SimpleLength { len: 3 }) ``` #### After ``` error: Invalid UUID: invalid length: expected length 32 for simple format, found 3 --> src\main.rs:4:10 | 4 | #[uuid = "000"] | ^^^^^ ``` ### With [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens) #### Before ![image](https://github.com/bevyengine/bevy/assets/33934311/415247fa-ff5c-4513-8012-7a9ff77445fb) #### After ![image](https://github.com/bevyengine/bevy/assets/33934311/d124eeaa-9213-49e0-8860-539ad0218a40) --- ## Changelog - `#[derive(TypeUuid)]` provide better error messages.
regnarock
pushed a commit
to regnarock/bevy
that referenced
this pull request
Oct 13, 2023
# Objective - Better error message - More idiomatic code ## Solution Refactorize `TypeUuid` macros to use `syn::Result` instead of panic. ## Before/After error messages ### Missing `#[uuid]` attribtue #### Before ``` error: proc-macro derive panicked --> src\main.rs:1:10 | 1 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` attribute found. ``` #### After ``` error: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]` attribute found. --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = note: this error originates in the derive macro `TypeUuid` (in Nightly builds, run with -Z macro-backtrace for more info) ``` ### Malformed attribute #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`. ``` #### After ``` error: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]`. --> src\main.rs:4:1 | 4 | #[uuid = 42] | ^^^^^^^^^^^^ ``` ### UUID parse fail #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: Value specified to `#[uuid]` attribute is not a valid UUID.: Error(SimpleLength { len: 3 }) ``` #### After ``` error: Invalid UUID: invalid length: expected length 32 for simple format, found 3 --> src\main.rs:4:10 | 4 | #[uuid = "000"] | ^^^^^ ``` ### With [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens) #### Before ![image](https://github.com/bevyengine/bevy/assets/33934311/415247fa-ff5c-4513-8012-7a9ff77445fb) #### After ![image](https://github.com/bevyengine/bevy/assets/33934311/d124eeaa-9213-49e0-8860-539ad0218a40) --- ## Changelog - `#[derive(TypeUuid)]` provide better error messages.
rdrpenguin04
pushed a commit
to rdrpenguin04/bevy
that referenced
this pull request
Jan 9, 2024
# Objective - Better error message - More idiomatic code ## Solution Refactorize `TypeUuid` macros to use `syn::Result` instead of panic. ## Before/After error messages ### Missing `#[uuid]` attribtue #### Before ``` error: proc-macro derive panicked --> src\main.rs:1:10 | 1 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` attribute found. ``` #### After ``` error: No `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]` attribute found. --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = note: this error originates in the derive macro `TypeUuid` (in Nightly builds, run with -Z macro-backtrace for more info) ``` ### Malformed attribute #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`. ``` #### After ``` error: `uuid` attribute must take the form `#[uuid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]`. --> src\main.rs:4:1 | 4 | #[uuid = 42] | ^^^^^^^^^^^^ ``` ### UUID parse fail #### Before ``` error: proc-macro derive panicked --> src\main.rs:3:10 | 3 | #[derive(TypeUuid)] | ^^^^^^^^ | = help: message: Value specified to `#[uuid]` attribute is not a valid UUID.: Error(SimpleLength { len: 3 }) ``` #### After ``` error: Invalid UUID: invalid length: expected length 32 for simple format, found 3 --> src\main.rs:4:10 | 4 | #[uuid = "000"] | ^^^^^ ``` ### With [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens) #### Before ![image](https://github.com/bevyengine/bevy/assets/33934311/415247fa-ff5c-4513-8012-7a9ff77445fb) #### After ![image](https://github.com/bevyengine/bevy/assets/33934311/d124eeaa-9213-49e0-8860-539ad0218a40) --- ## Changelog - `#[derive(TypeUuid)]` provide better error messages.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Reflection
Runtime information about types
C-Code-Quality
A section of code that is hard to understand or change
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
S-Ready-For-Final-Review
This PR has been approved by the community. It's ready for a maintainer to consider merging it
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
Solution
Refactorize
TypeUuid
macros to usesyn::Result
instead of panic.Before/After error messages
Missing
#[uuid]
attribtueBefore
After
Malformed attribute
Before
After
UUID parse fail
Before
After
With Error Lens
Before
After
Changelog
#[derive(TypeUuid)]
provide better error messages.