Repository navigation
Conversation
| // } | ||
| IDENT | POUND => { | ||
| let m = p.start(); | ||
| attributes::outer_attributes(p); |
There was a problem hiding this comment.
Let's maybe send this change as a separate PR, which can be r+ed immediately?
|
Hm, this |
|
I did that refactoring. Will update PR. |
|
@pcpthm would you mind rebasing this on a copule of cosmetic changes I am about to push? |
|
(basically, flattening this all a bit) |
18978df to
ef4dd4d
Compare
ef4dd4d to
646fa06
Compare
|
@matklad I rebased your commit. This PR is updated to include bigger change than first (a new AST syntax kind) to address issue on attributes on non- |
I don't think so, treating attrs as children of expressions seems better. Ie, we don't create "decorator" nodes, for things like modifiers or visibilty, we store them directly as children and introduce traits like "visibility owner". |
|
Whet we need here I think is an |
|
Actually, I couldn't come up with how to implement parsing without introducing an another node because each expression type start an own node and I can not inject children to such node. If there is a way to "meld" two nodes after parsing, it can be much simpler to implement, I think. |
|
@matklad The problem is |
We can do this ( Currently, at least two approaches are used simulateneosly:
And there's a third one:
My gut feeling is that the |
|
Another thing to keep in mind is that if we want to support parsing attributes "inside" expressions, like We'll need t teach |
|
Am I right to assume this also addresses #759? |
|
@killercup |
|
Ah, cool! Updated the issue to show the second case, attributes on blocks, don't work yet :) |
|
So, how about this plan:
I wouldn't worry too much about modularity here parser is nicely isolated from the rest of the analyzer, and this is what is most important. |
|
Okay, let me try that plan. My word about modularity was too much and actually I'm thinking that approach is not bad after thinking. |
987: Refactor maybe_item to use Marker argument r=pcpthm a=pcpthm As suggested at <#980 (comment)>. For expression paring functions, changing signature - from `fn(&mut Parser) -> Option<CompletedMarker>` to `fn(&mut Parser, Marker) -> Result<CompletedMarker, Marker>` - from `fn(&mut Parser) -> CompletedMarker` to `fn(&mut Parser, Marker) -> CompletedMarker` is my plan. Co-authored-by: pcpthm <pcpthm@gmail.com>
|
Another PR with suggested approach incoming. |
|
I just installed and enabled it, but it gives me "false" errors like this: In main.rs, I have Btw, renaming and finding all symbol references doesn't seem to work (the dialog for renaming opens but when i hit enter, it doesn't get renamed). I guess it's because it thinks that the source has syntax errors? |

This PR adds a new AST node
AttrExpr. This node is used when outer attributes are applied to an expression that is not an expression statement.It seems like stable rustc allows attributes on certain expressions when operator precedence is not confusing despite the unstable stmt_expr_attributes feature.
This PR currently isn't trying to produce parse errors and instead allowing attributes on arbitrary expression with the same precedence as lambda (this is suggested in the stmt_expr_attributes tracking issue). Probably errors can be reported on a validation pass.
This PR addresses #919's second and third case.