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

Trait bounds in parameters #279

Closed
GregBowyer opened this issue Dec 1, 2021 · 1 comment
Closed

Trait bounds in parameters #279

GregBowyer opened this issue Dec 1, 2021 · 1 comment

Comments

@GregBowyer
Copy link

Given this I get the following error:

error[E0277]: the trait bound `N: Spanned` is not satisfied
  --> janus/thesius/sql_parser/src/grammar.rs:46:68
   |
15 | fn spanned<N: Spanned>(n: N, start: usize, end: usize) -> N {
   |               ------- required by this bound in `grammar::spanned`
...
46 |             = start:position!() node:x() end:position!() { spanned(node, start, end) }
   |                                                                    ^^^^ the trait `Spanned` is not implemented for `N`
   |
help: consider restricting type parameter `N`
   |
45 |         rule SPAN<N: Spanned>(x: rule<N>) -> N
   |                    ^^^^^^^^^

but adding the bound is not valid for rust-peg

error: expected one of ",", ">"
  --> janus/thesius/sql_parser/src/grammar.rs:45:20
   |
45 |         rule SPAN<N: Spanned>(x: rule<N>) -> N
   |                    ^

Thoughts on this?

kevinmehall added a commit that referenced this issue Jan 1, 2022
Allow type bounds (#279), along with type arguments in the middle of
type paths.

This relies on type inference to pass type variables from `pub rule`
wrappers to the internal parse function. Normally when type variables
are used this works correctly, but may fail for unused type variables,
for example `pub rule ty_arg<T>() = ""`
@kevinmehall
Copy link
Owner

Fixed in 4b7dcaa

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

2 participants