-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: Add semicolon for toggle_macro_delimiter #21522
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
fix: Add semicolon for toggle_macro_delimiter #21522
Conversation
| .parent() | ||
| .and_then(ast::MacroExpr::cast) | ||
| .and_then(|it| ast::StmtList::cast(it.syntax().parent()?)) | ||
| .is_some() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand the logic here. If this is a MacroExpr and the child of a StmtList, it does need semicolon, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For {m!{} n!{}}, it ast is StmtList { ExprStmt { MacroExpr }, MacroExpr }
m!ExprStmt does not require a value, it requires a semicolonn!MacroExpr requires a value, meaning no semicolons are needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what about things like foo!(m! {})? Even if this works, please add a test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been tested in test_nested_macros that currently does not support nested toggle delimiters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not nested macro calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant foo(m! {}) (foo is not a macro).
f0f0c2e to
9fbcc94
Compare
Example
---
```rust
macro_rules! sth {
() => {};
}
sth!$0{ }
```
(old test `sth!{};` is a syntax error in item place)
**Before this PR**
```rust
macro_rules! sth {
() => {};
}
sth![ ]
```
**After this PR**
```rust
macro_rules! sth {
() => {};
}
sth![ ];
```
9fbcc94 to
88595fe
Compare
ChayimFriedman2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also the problem of removing the semicolon in item lists when changing other brackets to {}, but that can be a different PR (not necessarily yours).
Thanks!
Is there a problem with this? If the delimiter is |
|
If the delimiter was |
|
But hasn't this already been implemented? |
|
Oops I thought it wasn't 😅 |
Example
(old test
sth!{};is a syntax error in item place)Before this PR
After this PR