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

Don't require semicolon after macro usage with brackets #225

Closed
aochagavia opened this issue Nov 10, 2018 · 1 comment · Fixed by #273
Closed

Don't require semicolon after macro usage with brackets #225

aochagavia opened this issue Nov 10, 2018 · 1 comment · Fixed by #273

Comments

@aochagavia
Copy link
Contributor

The following code expects a semicolon at the cursor position:

fn test() {
    println! {
        "Hello world"
    }<|>
    return;
}

This might be caused by the fact that the macro call is being treated as a non-block expression, though I don't know for sure (I am not very familiar with the parser):

https://github.com/rust-analyzer/rust-analyzer/blob/477de790b0211196256a772befe4f577d1a8ba14/crates/ra_syntax/src/grammar/expressions/mod.rs#L204-L209

The problem is that some macros should be treated as blocks and other shouldn't, so determining whether the element is a block based on SyntaxKind is insufficient in this case (unless we introduce a special syntax kind for block-like macro calls)

@matklad
Copy link
Member

matklad commented Nov 15, 2018

Note that similar logic already works for macros in item position:

https://github.com/rust-analyzer/rust-analyzer/blob/923483e321acace3bbf38688bd70d4d38f49b35e/crates/ra_syntax/src/grammar/items/mod.rs#L346-L350

this function basically returns "does this macro use {}". We need to apply the same logic in expressions.

DJMcNab added a commit to DJMcNab/rust-analyzer that referenced this issue Dec 18, 2018
DJMcNab added a commit to DJMcNab/rust-analyzer that referenced this issue Dec 19, 2018
bors bot added a commit that referenced this issue Dec 19, 2018
273: Add a test to ensure that we can parse each file r=matklad a=DJMcNab

Note that this has a non-spurious failure in ra_analysis/src/mock_analysis.

Probably fixes #195.

If my understanding is correct, fixes #214 and fixes #225.

Co-authored-by: DJMcNab <[email protected]>
@bors bors bot closed this as completed in #273 Dec 19, 2018
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.

2 participants