Add detailed diagnostics for Rust-style enums
Description
Adds detailed error messages when detected Rust-style enums
close #5403
Changes:
- Modified enum variant parsing in
sway-parse/src/item/mod.rsto detect Rust-like tuple (Variant(T)), unit (Variant), and struct (Variant { field: T }) syntax, generating errors. - Updated
ParseErrorKind::MissingColonInEnumTypeFieldinsway-error/src/parser_error.rsto storevariant_nameand optionaltuple_contentsspan for diagnostic purposes. - Added diagnostic generation in
sway-error/src/error.rsto output error messages and syntax suggestions (e.g.,Did you mean 'Variant: (T)'?) for incorrect enum definitions. - Updated the
enum_rust_liketest (main.swandtest.toml) with new test cases for these syntax errors and adjusted expectations for the new diagnostic output.
All error messages match the spec defined in the issue description.
Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have requested support from the DevRel team
- [x] I have added tests that prove my fix is effective or that my feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
Breaking*orNew Featurelabels where relevant. - [x] I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
- [x] I have requested a review from the relevant team or maintainers.
Thanks for the contribution! Before we can merge this, we need @kfastov to sign the Fuel Labs Contributor License Agreement.
@IGI-111 @ironcev Hi, sorry for the long delay, I've fixed all the error messages now. About updating docs: I don't think I change any APIs, and affected error messages are not mentioned in the documentation, so I skipped this part. Please tell me if I need to document anything. It also doesn't seem like a breaking change to me
@IGI-111 Hi, sorry for bothering you, should I do something else for this PR to be reviewed?
@ironcev @IGI-111
@IGI-111 From my side this PR is approved quite some time ago. Can we get a second review and approval?