-
Notifications
You must be signed in to change notification settings - Fork 249
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
Implemented syn::Error::combine for ItemImplInfo and ItemTraitInfo #1065
Implemented syn::Error::combine for ItemImplInfo and ItemTraitInfo #1065
Conversation
What you have is a good start and exactly what we want here!
Good question. Take a look at
It should be possible to add a test that's supposed to fail compilation and produce multiple errors, and have To run just the compilation tests, try this inside the
Yeah. I'd review all functions in the If such a function returns errors at multiple points, I'd attempt to collect and combine them like you've done for For example, here's one more fn I found. At a glance, it has 4 points where it might return an error and they look like they can all be combined.
I think you've figured it all out. Implementation + tests is what we need. Then if all checks pass and there's an approving review, we're good to merge. |
Hi @uint, I started working on the arg_info.rs function that you mentioned. I could use some advice here:
|
The code is correct, but at this point the whole
I looked at why My approach here would be to first collect all the data behind The linked snippets are broad strokes, not a complete solution. Hope this helps! |
…ferent outcomes later, wrote compilation test for combined errors for arg_info too.
Hi @uint, thanks for you suggestions and the code snippets, They were really helpful. In my latest commit 5eca06c, I did a refactor accordingly. Collecting all results and matching them against possible Ok or Error outcomes and returning the errors if any. |
original: original.clone(), | ||
}), | ||
_ => { | ||
more_errors.extend(pat_info.err()); |
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.
Clever and succinct!
| | ||
12 | pub fn insert(&mut self, (a, b): (u8, u32)) {} | ||
| ^^^^^^ | ||
16 | pub fn faulty_method1(&mut self, #[serializer(SomeNonExistentSerializer)] (a, b): (u8, u32)) {} |
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.
Alright, this is a possible regression. Previously, the tuple was highlighted here. Now it's the the #
of the attribute.
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.
It's looking good overall. Just small things, particularly around what code tokens get highlighted in those error messages.
| | ||
12 | pub fn insert(&mut self, (a, b): (u8, u32)) {} | ||
| ^^^^^^ | ||
16 | pub fn faulty_method1(&mut self, #[serializer(SomeNonExistentSerializer)] (a, b): (u8, u32)) {} |
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.
Alright, this is a possible regression. Previously, (a, b)
was highlighted here. Now it's the the #
of the attribute.
error: Unsupported contract API type. | ||
--> compilation_tests/invalid_arg_pat.rs:15:37 | ||
| | ||
15 | pub fn faulty_method(&mut self, #[serializer(SomeNonExistentSerializer)] _a: *mut u32) {} |
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.
Ideally, this would highlight SomeNonExistentSerializer
. The error would be much more helpful then.
@@ -1,5 +1,8 @@ | |||
//! Method with non-deserializable argument type. | |||
|
|||
// //! Method with non-deserializable argument 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.
// //! Method with non-deserializable argument type. | |
//! Method with non-deserializable argument type. |
@uint Thanks for pointing out the error span problems. I actually ended up reading more about it and used syn::new_spanned which gives better error spans and now the errors are more accurate. Maybe we should use it across the whole project. Let me know if you have more suggestions. |
…into info_extractor-error_combine
@jaswinder6991 Please, make sure CI passes and mark this PR ready for review once you believe it is ready (make sure you do a review pass yourself before pinging maintainers) |
This PR was superseded by #1097 |
This is wip PR which addresses #1006
This initial commit it to get feedback on how to proceed further with this.