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

Const expressions break formatting #5273

Closed
DianaNites opened this issue Mar 20, 2022 · 1 comment · Fixed by #5274
Closed

Const expressions break formatting #5273

DianaNites opened this issue Mar 20, 2022 · 1 comment · Fixed by #5274

Comments

@DianaNites
Copy link

stable

rustc --version: rustc 1.59.0 (9d1b2106e 2022-02-23)
rustfmt --version: rustfmt 1.4.38-stable (9d1b210 2022-02-23)

nightly

rustc --version: rustc 1.61.0-nightly (8d60bf427 2022-03-19)
rustfmt --version: rustfmt 1.4.38-nightly (8d60bf4 2022-03-19)

Current stable and nightly rustfmts format the following code incorrectly

struct Example<const N: usize = { 1048576 }> {
    //
}

to

struct Example<const N: usize = { 1048576 }> {
    1048576 }> {
//
}

Or, with normalize_comments = true set

struct Example<const N: usize = { 1048576 }> {
    // 1048576 }> {
}

In this case there is a new // 1048576 }> { prepended on every format operation

@ytmimi
Copy link
Contributor

ytmimi commented Mar 20, 2022

Thanks for the report!

looks like the Span we're using is off. A similar issue was seen with #5011, so I imagine the fix should be similar to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants