-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add Support for Compact Enums #686
Add Support for Compact Enums #686
Conversation
src/validators/enums.rs
Outdated
}) | ||
.set_span(enum_def.span()) | ||
.add_note( | ||
"compact enums cannot also have underlying types\ntry removing either the 'compact' modifier, or the underlying type", |
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 we should try to avoid using newlines in these notes.
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.
Okay, I'll change them all to other punctuation.
What's the problem with newlines though?
The console output will already have newlines from snippets, and the json output is all string-escaped.
src/diagnostics/errors.rs
Outdated
CompactTypeCannotContainTaggedFields, | ||
format!("tagged fields are not supported in compact {kind}s\nconsider removing the tag, or making the {kind} non-compact"), | ||
kind |
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 agree with @externl on the new lines in the error descriptions. Do we do this anywhere else?
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.
There's a few scattered around notes and error messages.
Just whenever something seemed more readable on two lines.
This PR implements #681 by adding support for compact enums.
Compact enums work just like compact structs: we don't encode
TagEndMarker
, and tags cannot be used within the enum.A compact enum cannot have an underlying type (since they're already 'compact') nor can it be unchecked (since we already don't encode
TagEndMarker
then).