Skip to content

Conversation

@TheIronBorn
Copy link

This matches things like this now:

struct Thing(u8, u8);

fn name(Thing(a, b): Thing) {
    do_something_with(a, b);
}

I don't know if this is the right way to solve it. Some more tests might also be in order

@jasonwilliams
Copy link

Some tests would be good @TheIronBorn

@jasonwilliams
Copy link

retry

@TheIronBorn
Copy link
Author

Sorry. I've been slow on this because I found it breaks impl Trait parameters.

@jasonwilliams
Copy link

@TheIronBorn whats the update on this PR?

@jasonwilliams
Copy link

retry

@TheIronBorn TheIronBorn changed the title add deconstructor in function parameter add deconstructor in function argument Apr 25, 2018
@TheIronBorn
Copy link
Author

I couldn't find a decent way to do this without just adding a lot of exceptions, or overhauling how we match function arguments.

Function arguments can be A LOT:

any pattern that is valid in a let binding is also valid as an argument

@TheIronBorn
Copy link
Author

TheIronBorn commented Apr 25, 2018

I suppose a place to start is a pattern binding syntax context.

@TheIronBorn
Copy link
Author

There's some formal grammer for it here https://doc.rust-lang.org/grammar.html#variable-declarations. So I guess I'll start working on that.

Talked myself into it lol

@ehuss
Copy link

ehuss commented Apr 25, 2018

That grammar is pretty old. The following might provide better information on the grammar.

@TheIronBorn
Copy link
Author

It would be really nice to reuse our other pattern matching code, but if we're going to be highlighting the parameter names as variable.parameter.rust I don't see how that's possible

@dten
Copy link

dten commented Apr 26, 2018

you can override things with a prototype, might work 😀

@TheIronBorn
Copy link
Author

Something like:

prototype:
  - match: '{{identifier}}(?=:)'
    scope: variable.parameter

Hmm might work.

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.

4 participants