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

Wrong shape used when rewriting inner attributes in match expression #6147

Closed
ytmimi opened this issue Apr 12, 2024 · 0 comments · Fixed by #6148
Closed

Wrong shape used when rewriting inner attributes in match expression #6147

ytmimi opened this issue Apr 12, 2024 · 0 comments · Fixed by #6148
Labels
a-matches match arms, patterns, blocks, etc good first issue Issues up for grabs, also good candidates for new rustfmt contributors poor-formatting

Comments

@ytmimi
Copy link
Contributor

ytmimi commented Apr 12, 2024

The indentation of the second inner attribute isn't correct.

version: rustfmt 1.7.0-nightly (72893919 2024-04-07) -- built from rust-lang/rustfmt source.
commit: 7289391
configs used: defaults

Input

pub fn main() {
    match a {
        #![attr1]
        #![attr2]
        _ => None,
    }
}

output

pub fn main() {
    match a {
        #![attr1]
    #![attr2]
        _ => None,
    }
}

The fix will likely involve pass an indented shape when calling inner_attrs.rewrite().

.rewrite(context, shape)

@ytmimi ytmimi added good first issue Issues up for grabs, also good candidates for new rustfmt contributors poor-formatting a-matches match arms, patterns, blocks, etc labels Apr 12, 2024
@ytmimi ytmimi changed the title Wrong Shape used for inner attributes in match expression Wrong shape used when rewriting inner attributes in match expression Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-matches match arms, patterns, blocks, etc good first issue Issues up for grabs, also good candidates for new rustfmt contributors poor-formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant