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

Misaligned indentation of formatted string literal lines #4323

Open
ayazhafiz opened this issue Jul 12, 2020 · 1 comment · May be fixed by #5605
Open

Misaligned indentation of formatted string literal lines #4323

ayazhafiz opened this issue Jul 12, 2020 · 1 comment · May be fixed by #5605
Assignees
Labels
help wanted only-with-option requires a non-default option value to reproduce poor-formatting

Comments

@ayazhafiz
Copy link
Contributor

ayazhafiz commented Jul 12, 2020

Only with option format_string true.

re #4321 (comment)

Input

fn bench_contains_short_long(b: &mut Bencher) {
    let haystack = "\
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem sit amet dolor \
ultricies condimentum. Praesent iaculis purus elit, ac malesuada quam malesuada in. Duis sed orci \
eros. Suspendisse sit amet magna mollis, mollis nunc luctus, imperdiet mi. Integer fringilla non \
sem ut lacinia. Fusce varius tortor a risus porttitor hendrerit. Morbi mauris dui, ultricies nec \
tempus vel, gravida nec quam.

Nam lectus enim, dapibus non nisi tempor, consectetur convallis massa. Maecenas eleifend dictum \
feugiat. Etiam quis mauris vel risus luctus mattis a a nunc. Nullam orci quam, imperdiet id \
vehicula in, porttitor ut nibh. Duis sagittis adipiscing nisl vitae congue. Donec mollis risus eu \
leo suscipit, varius porttitor nulla porta. Pellentesque ut sem nec nisi euismod vehicula. Nulla \
malesuada sollicitudin quam eu fermentum.";
}

and

fn bench_contains_short_long(b: &mut Bencher) {
    let haystack = "\
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem sit amet dolor \
ultricies condimentum. Praesent iaculis purus elit, ac malesuada quam malesuada in. Duis sed orci \
eros. Suspendisse sit amet magna mollis, mollis nunc luctus, imperdiet mi. Integer fringilla non \
sem ut lacinia. Fusce varius tortor a risus porttitor hendrerit. Morbi mauris dui, ultricies nec \
tempus vel, gravida nec quam.";
}

Output

fn bench_contains_short_long(b: &mut Bencher) {
    let haystack =
        "\
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem sit amet dolor \
         ultricies condimentum. Praesent iaculis purus elit, ac malesuada quam malesuada in. Duis \
         sed orci eros. Suspendisse sit amet magna mollis, mollis nunc luctus, imperdiet mi. \
         Integer fringilla non sem ut lacinia. Fusce varius tortor a risus porttitor hendrerit. \
         Morbi mauris dui, ultricies nec tempus vel, gravida nec quam.

Nam lectus enim, dapibus non nisi tempor, consectetur convallis massa. Maecenas eleifend dictum \
         feugiat. Etiam quis mauris vel risus luctus mattis a a nunc. Nullam orci quam, imperdiet \
         id vehicula in, porttitor ut nibh. Duis sagittis adipiscing nisl vitae congue. Donec \
         mollis risus eu leo suscipit, varius porttitor nulla porta. Pellentesque ut sem nec nisi \
         euismod vehicula. Nulla malesuada sollicitudin quam eu fermentum.";
}

and

fn bench_contains_short_long(b: &mut Bencher) {
    let haystack = "\
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem sit amet dolor \
                    ultricies condimentum. Praesent iaculis purus elit, ac malesuada quam \
                    malesuada in. Duis sed orci eros. Suspendisse sit amet magna mollis, mollis \
                    nunc luctus, imperdiet mi. Integer fringilla non sem ut lacinia. Fusce varius \
                    tortor a risus porttitor hendrerit. Morbi mauris dui, ultricies nec tempus \
                    vel, gravida nec quam.";
}

Respectively

Expected output

Better and consistent indentation of lines in the string. In particular, the first example should not change or be

fn bench_contains_short_long(b: &mut Bencher) {
    let haystack =
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem sit amet dolor \
         ultricies condimentum. Praesent iaculis purus elit, ac malesuada quam malesuada in. Duis \
         sed orci eros. Suspendisse sit amet magna mollis, mollis nunc luctus, imperdiet mi. \
         Integer fringilla non sem ut lacinia. Fusce varius tortor a risus porttitor hendrerit. \
         Morbi mauris dui, ultricies nec tempus vel, gravida nec quam.

Nam lectus enim, dapibus non nisi tempor, consectetur convallis massa. Maecenas eleifend dictum \
         feugiat. Etiam quis mauris vel risus luctus mattis a a nunc. Nullam orci quam, imperdiet \
         id vehicula in, porttitor ut nibh. Duis sagittis adipiscing nisl vitae congue. Donec \
         mollis risus eu leo suscipit, varius porttitor nulla porta. Pellentesque ut sem nec nisi \
         euismod vehicula. Nulla malesuada sollicitudin quam eu fermentum.";
}

and the second example could be

fn bench_contains_short_long(b: &mut Bencher) {
    let haystack = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem sit amet dolor \
                    ultricies condimentum. Praesent iaculis purus elit, ac malesuada quam \
                    malesuada in. Duis sed orci eros. Suspendisse sit amet magna mollis, mollis \
                    nunc luctus, imperdiet mi. Integer fringilla non sem ut lacinia. Fusce varius \
                    tortor a risus porttitor hendrerit. Morbi mauris dui, ultricies nec tempus \
                    vel, gravida nec quam.";
}

Meta

  • rustfmt version: 98efebd
  • From where did you install rustfmt?: from source
@ytmimi
Copy link
Contributor

ytmimi commented Jul 26, 2022

confirming this is reproducible with rustfmt 1.5.1-nightly (a451a39d 2022-07-25)

davidBar-On added a commit to davidBar-On/rustfmt that referenced this issue Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted only-with-option requires a non-default option value to reproduce poor-formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants