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

Bounds on trait objects and impl traits not parsing #384

Open
brasswood opened this issue Oct 9, 2024 · 0 comments · May be fixed by #385
Open

Bounds on trait objects and impl traits not parsing #384

brasswood opened this issue Oct 9, 2024 · 0 comments · May be fixed by #385

Comments

@brasswood
Copy link

brasswood commented Oct 9, 2024

The following will not parse:

rule operand() -> Box<dyn Operand + 'input>

The error:

error: expected one of "&", "(", "::", "<", "dyn", "impl"
  --> src\parse.rs:41:45
   |
41 |         rule operand() -> Box<dyn Operand + 'input>
   |                                             ^^^^^^

I believe the issue is in the rust_type() rule of grammar.rustpeg:

rule rust_type()
    = BRACKET_GROUP()
    / "&" LIFETIME()? "mut"? rust_type()
    / "dyn" rust_type() ++ "+" // here
    / "impl" rust_type() ++ "+" // and here
    / "(" (rust_type() ++ "," ","?)? ")"
    / ("<" rust_type() ("as" rust_ty_path())? ">")? rust_ty_path()

rust_type()s shouldn't follow "dyn" and "impl"; instead it should be something that parses type parameter bounds (which include rust types AND lifetimes) (ref) (ref). I think the rules to parse that might already be written as part of rust_where_clause() and could perhaps be factored out, but I don't have time at the moment to verify that.

@brasswood brasswood linked a pull request Oct 9, 2024 that will close this issue
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.

1 participant