Skip to content
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

Handle nested syn::Type:::Group #79

Merged
merged 2 commits into from
Jun 1, 2020

Conversation

Aaron1011
Copy link
Contributor

Currently, rustc does not pass the exact original TokenStream to
proc-macros in several cases. This has many undesirable effects, such as
losing correct location information in error message.
See rust-lang/rust#43081 for more details

In the future, rustc will begin passing the correct TokenStream to
proc-macros. As a result, syn may wrap a type in one or more
syn::Type::Groups (if the proc-macro input came from a macro_rules! expansion).

I've determined that this can cause yaserde-derive to fail to match
a Type::Path. This PR should properly handle nested groups, allowing
your crate to work with both old and new input.

If you have any questions, feel free to ask me. See rust-lang/rust#72622
for more details.

Currently, rustc does not pass the exact original TokenStream to
proc-macros in several cases. This has many undesirable effects, such as
losing correct location information in error message.
See rust-lang/rust#43081 for more details

In the future, rustc will begin passing the correct TokenStream to
proc-macros. As a result, `syn` may wrap a type in one or more
`syn::Type::Group`s (if the proc-macro input came from a `macro_rules!` expansion).

I've determined that this can cause `yaserde-derive` to fail to match
a `Type::Path`. This PR should properly handle nested groups, allowing
your crate to work with both old and new input.

If you have any questions, feel free to ask me. See rust-lang/rust#72622
for more details.
@coveralls
Copy link

coveralls commented May 31, 2020

Pull Request Test Coverage Report for Build 202

  • 5 of 9 (55.56%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 53.963%

Changes Missing Coverage Covered Lines Changed/Added Lines %
yaserde_derive/src/common/field.rs 0 4 0.0%
Totals Coverage Status
Change from base Build 198: 0.05%
Covered Lines: 817
Relevant Lines: 1514

💛 - Coveralls

@Aaron1011
Copy link
Contributor Author

I'm not sure how to write a test that increases the coverage, given that syn doesn't currently emit Type::Group in this way.

@MarcAntoine-Arnaud
Copy link
Contributor

Can you cherry-pick that ?

@Aaron1011
Copy link
Contributor Author

@MarcAntoine-Arnaud: Updated

@MarcAntoine-Arnaud MarcAntoine-Arnaud merged commit 429c2db into media-io:master Jun 1, 2020
@Aaron1011 Aaron1011 deleted the fix/type-group branch June 1, 2020 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants