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

Pretty-printer inserts an extra newline before the first match arm if it has a comment #37199

Open
petrochenkov opened this issue Oct 15, 2016 · 3 comments
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug.

Comments

@petrochenkov
Copy link
Contributor

Example:

fn main() {
    match 0u8 {
        // Comment
        0 => {}
        _ => {}
    }
}

=>

fn main() {
    match 0u8 {

        // Comment
        0 => {
        }
        _ => { }
    }
}

Affected tests:
[pretty] pretty\borrowck\borrowck-pat-enum.rs
[pretty] pretty\issue-11709.rs
[pretty] pretty\issue-28839.rs

eddyb added a commit to eddyb/rust that referenced this issue Oct 19, 2016
Fix some pretty printing tests

Many pretty-printing tests are un-ignored.
Some issues in classification of comments (trailing/isolated) and blank line counting are fixed.
Some comments are printed more carefully.
Some minor refactoring in pprust.rs
`no-pretty-expanded` annotations are removed because this is the default now.
`pretty-expanded` annotations are removed from compile-fail tests, they are not tested with pretty-printer.

Closes rust-lang#23623 in favor of more specific rust-lang#37201 and rust-lang#37199
r? @nrc
eddyb added a commit to eddyb/rust that referenced this issue Oct 19, 2016
Fix some pretty printing tests

Many pretty-printing tests are un-ignored.
Some issues in classification of comments (trailing/isolated) and blank line counting are fixed.
Some comments are printed more carefully.
Some minor refactoring in pprust.rs
`no-pretty-expanded` annotations are removed because this is the default now.
`pretty-expanded` annotations are removed from compile-fail tests, they are not tested with pretty-printer.

Closes rust-lang#23623 in favor of more specific rust-lang#37201 and rust-lang#37199
r? @nrc
@sanxiyn sanxiyn added the A-pretty Area: Pretty printing (including `-Z unpretty`) label Oct 29, 2016
@matklad
Copy link
Member

matklad commented Jul 18, 2017

[pretty] pretty/optional_comma_in_match_arm.rs

@wooster0
Copy link
Contributor

I believe this can be closed.

fn main() {
    match 0u8 {
        // Comment
        0 => {}
        _ => {}
    }
}

This code stays just the way it is after I format.

@petrochenkov
Copy link
Contributor Author

@r00ster91
This issue is about pretty-printing with AST pretty-printer in rustc, rather than about rustfmt.
It is available on https://play.rust-lang.org through "Tools > Expand macros", for example.
The issue still reproduces there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants