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

Consider making expr_no_struct public #789

Closed
audunhalland opened this issue May 6, 2020 · 2 comments
Closed

Consider making expr_no_struct public #789

audunhalland opened this issue May 6, 2020 · 2 comments

Comments

@audunhalland
Copy link

audunhalland commented May 6, 2020

Hi, I'm working on a macro where I want to parse the basic structure of a match expression, but then I want to provide my own custom parser for the body of each match arm:

let match_token: syn::Token![match] = input.parse()?;
let expr: syn::Expr = input.parse()?; // <--- issue
let content;
let brace_token = syn::braced!(content in input);

let mut arms = Vec::new();
while !content.is_empty() {
    arms.push(content.call(MyMatchArm::parse)?);
}

match foo { pat => ... } is now incorrectly parsed, because expr: Expr consumes all of foo { pat => ... }. What I need is some way to invoke expr_no_struct, which I think will correctly parse this, but it's not exposed as a public API, and I'd like to avoid copy/pasting hundreds of lines :)

Perhaps a way to do this could be to introduce a public newtype like ExprNoStruct(Expr) and implement Parse for that?

@taiki-e
Copy link
Contributor

taiki-e commented May 21, 2020

Related: #515

@dtolnay
Copy link
Owner

dtolnay commented Jun 9, 2020

Closing as a duplicate of #515.

@dtolnay dtolnay closed this as completed Jun 9, 2020
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

No branches or pull requests

3 participants