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

Formatting of Comment Inside Const #4508

Closed
davidBar-On opened this issue Nov 3, 2020 · 1 comment
Closed

Formatting of Comment Inside Const #4508

davidBar-On opened this issue Nov 3, 2020 · 1 comment

Comments

@davidBar-On
Copy link
Contributor

Input / Output
Test comment-inside-const.rs is now:

fn issue982() {
    const SOME_CONSTANT: u32 =
        // Explanation why SOME_CONSTANT needs FLAG_A to be set.
        FLAG_A |
        // Explanation why SOME_CONSTANT needs FLAG_B to be set.
        FLAG_B |
        // Explanation why SOME_CONSTANT needs FLAG_C to be set.
        FLAG_C;
}

Expected output
Should the desired output (and input) be:

fn issue982() {
    const SOME_CONSTANT: u32 =
        // Explanation why SOME_CONSTANT needs FLAG_A to be set.
        FLAG_A
            // Explanation why SOME_CONSTANT needs FLAG_B to be set.
            | FLAG_B
            // Explanation why SOME_CONSTANT needs FLAG_C to be set.
            | FLAG_C;
}

That is, the | is put at the beginning of the line as binop_separator = "Front" is used, and the lines past FLAG_A are indented to the right, based on the current formatting of the following example:

fn main() {
    const xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: u32 =
        yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
            | zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
            | uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;
}

The current test should probably be formatted as something like (with binop_separator = "Front"):

fn issue982() {
    const SOME_CONSTANT: u32 =
        // Explanation why SOME_CONSTANT needs FLAG_A to be set.
        FLAG_A
            |
            // Explanation why SOME_CONSTANT needs FLAG_B to be set.
            FLAG_B
            |
            // Explanation why SOME_CONSTANT needs FLAG_C to be set.
            FLAG_C;
}
@ytmimi
Copy link
Contributor

ytmimi commented Jul 26, 2022

Going to close as this is a duplicate of #3167. The reason we don't format here is that we don't yet handle comments between binary operators

@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants