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

Meta does not parse paths with leading double-colon #909

Closed
dbeckwith opened this issue Oct 21, 2020 · 1 comment · Fixed by #910
Closed

Meta does not parse paths with leading double-colon #909

dbeckwith opened this issue Oct 21, 2020 · 1 comment · Fixed by #910

Comments

@dbeckwith
Copy link

dbeckwith commented Oct 21, 2020

Minimal reproduction:

use syn;

fn main() {
    // correctly parses
    let attr: syn::Attribute = syn::parse_quote!(#[derive(serde::Serialize)]);
    let _ = dbg!(attr.parse_meta());
    
    // error, expected identifier or literal
    let attr: syn::Attribute = syn::parse_quote!(#[derive(::serde::Serialize)]);
    let _ = dbg!(attr.parse_meta());
}

I would expect the second example to parse since it's a valid path. I think the meta parsing code does a lookahead expecting only a literal or an identifier, but paths can start with the non-identifier ::.

I read the previous discussion about not wanting Meta to have to cover all possible attribute syntaxes, but I think this fits solidly within the current expectations of what Meta should parse. Given that it stores Paths, it should be able to parse any kind of Path.

@dtolnay
Copy link
Owner

dtolnay commented Oct 21, 2020

Fixed in 1.0.46.

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 a pull request may close this issue.

2 participants