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

Allow parsing MetaNameValue if the path part contains a keyword #1413

Closed
wants to merge 2 commits into from
Closed

Allow parsing MetaNameValue if the path part contains a keyword #1413

wants to merge 2 commits into from

Conversation

jonasbb
Copy link

@jonasbb jonasbb commented Mar 20, 2023

This allows this to be parsed:

let attr: syn::MetaNameValue = syn::parse_quote!{
    as = "FooBar"
};

This aligns the code with parse_meta_path which already uses
input.peek(Ident::peek_any).

syn/src/meta.rs

Line 401 in 25def51

if input.peek(Ident::peek_any) {

This allows parsing the #[serde_as(as = "FooBar")] attributes which
are used as part of the serde_with crate.

Thanks to @matthias-stemmler for finding the cause.
#1408 (comment)

This allows this to be parsed:

```rust
let attr: syn::MetaNameValue = syn::parse_quote!{
    as = "FooBar"
};
```

This aligns the code with `parse_meta_path` which already uses
`input.peek(Ident::peek_any)`.
https://github.com/dtolnay/syn/blob/25def51081b68538547f34a3494744a807be4203/src/meta.rs#L401

This allows parsing the `#[serde_as(as = "FooBar")]` attributes which
are used as part of the `serde_with` crate.

Thanks to @matthias-stemmler for finding the cause.
#1408 (comment)
@jonasbb jonasbb marked this pull request as draft March 20, 2023 20:02
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.

None yet

1 participant