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

When there are multiple extraneous semicolons, only one is deleted at a time #2791

Closed
ExpHP opened this issue Jun 16, 2018 · 3 comments
Closed
Labels
bug Panic, non-idempotency, invalid code, etc. p-high poor-formatting

Comments

@ExpHP
Copy link

ExpHP commented Jun 16, 2018

This is an example of non-idempotent formatting:

fn main() {
    let x = 2;;;;
}

is formatted to

fn main() {
    let x = 2;;;
}

which is formatted to

fn main() {
    let x = 2;;
}

etc.

@ExpHP ExpHP changed the title When there are extraneous semicolons, only one is deleted at a time When there are multiple extraneous semicolons, only one is deleted at a time Jun 16, 2018
@nrc nrc added bug Panic, non-idempotency, invalid code, etc. poor-formatting p-high labels Jun 18, 2018
@topecongiro
Copy link
Contributor

A simple println! debugging shows that the span for let in the above example includes the semicolon up to the second one (let x = 2;;). I do not know the exact specification of rust syntax, so I cannot tell whether this is a bug or not. However, in case of other statements like foo();;, the span does not include the second semicolon, so I assume that this is a bug which should be fixed in libsyntax side.

@topecongiro
Copy link
Contributor

Ugh, it's me...rust-lang/rust#45060.

@topecongiro
Copy link
Contributor

Ah, or maybe not. cc rust-lang/rust#51629.

kennytm added a commit to kennytm/rust that referenced this issue Jun 22, 2018
…ocal-span, r=petrochenkov

Do not consume semicolon twice while parsing local statement

The span for a `let` statement includes multiple semicolons. For example,

```rust
    let x = 2;;;
//  ^^^^^^^^^^^ The span for the above statement.
```

This PR fixes it.

cc rust-lang/rustfmt#2791.
@nrc nrc closed this as completed in fa19788 Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. p-high poor-formatting
Projects
None yet
Development

No branches or pull requests

3 participants