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

Fix/Visual IndentStyle is broken on impl with where clause #5460

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

jmj0502
Copy link
Contributor

@jmj0502 jmj0502 commented Jul 21, 2022

Fixes #3071

@jmj0502 jmj0502 marked this pull request as draft July 21, 2022 01:57
@jmj0502 jmj0502 marked this pull request as ready for review July 21, 2022 18:39
@ytmimi
Copy link
Contributor

ytmimi commented Jul 22, 2022

@jmj0502 Thank you for your second contribution now! I want to let you know that I've seen this but likely won't get around to reviewing it until later next week.

@ytmimi ytmimi self-assigned this Jul 22, 2022
@jmj0502
Copy link
Contributor Author

jmj0502 commented Jul 22, 2022

@ytmimi Thanks for all the guidance! Looking forward to keep on contributing and getting to know the project better, in order to tackle tougher issues in the future. In regards to the review process; no worries, I'll keep an eye around in case changes are required, so don't hesitate to reach out 👍 .

@ytmimi ytmimi added the p-low label Jul 28, 2022
@jmj0502
Copy link
Contributor Author

jmj0502 commented Aug 6, 2022

@ytmimi Hey! Hope you're doing great! c:
Will this PR land? 😢

@ytmimi
Copy link
Contributor

ytmimi commented Aug 8, 2022

@jmj0502 Don't worry, I haven't forgotten about this, I just haven't had as much time as I'd like for reviews recently. Apologies for the delay and I'll look to provide you with some feedback on this soon

@ytmimi
Copy link
Contributor

ytmimi commented Aug 17, 2022

@jmj0502 thanks for looking into this. I have two asks before moving forward

  1. Could we update the Where predicates section of the indent_style docs in Configurations.md to add a short code snippet that shows the formatting of where predicates in impl block for both the Block and Visual case.
  2. Could we add a test where where_single_line=true. I want to make sure that these changes don't affect that option. I'm actually not sure if that option has any affect on impl blocks, but just want to check the behavior when the option is set to true and indent_style=Visual.

@jmj0502
Copy link
Contributor Author

jmj0502 commented Aug 17, 2022

@ytmimi Cool! I'll add the changes as soon as I have some free time ✌️

…der. Additional test cases for the issue-3071 were added; in order to check if the the where_single_line config still has the expected behaviour. Additional examples were added to Configurations.md.
@jmj0502
Copy link
Contributor Author

jmj0502 commented Aug 17, 2022

@ytmimi Done! I added the additional tests and some code snippets that illustrate how the format of the where clauses differ based on the value provided to indent_style.

@jmj0502
Copy link
Contributor Author

jmj0502 commented Aug 17, 2022

@ytmimi I'm getting format errors each time I run the tests for Configurations.md file. I think I missed something. Any clues?

@ytmimi
Copy link
Contributor

ytmimi commented Aug 18, 2022

hmmm 🤔 not sure either, but I'm looking into it!

@ytmimi
Copy link
Contributor

ytmimi commented Aug 18, 2022

It looks like these are the snippets rustfmt accepts. I took each one and ran rustfmt on it with the indent_style config. What I find odd is that both struct cases want to keep the opening brace on the same line as the bounds, which seems inconsistent but not something we should tackle right now. Personally I'd recommend removing that example right now

For your info Each code snippet should represent what the code would look like after rustfmt has been applied to it. So basically the snippets need to be idempotent.

Here's the Block formatting snippet

fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
where
    Ipsum: Eq,
    Dolor: Eq,
    Sit: Eq,
    Amet: Eq,
{
    // body
}

struct Foo<T>
where
    T: Eq, {
    // body
}

impl<T> Foo<T>
where
    T: Eq,
{
    // body
}

Here's the Visual formatting snippet.

fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
    where Ipsum: Eq,
          Dolor: Eq,
          Sit: Eq,
          Amet: Eq
{
    // body
}

struct Foo<T>
    where T: Eq {
    // body
}

impl<T> Foo<T>
    where T: Eq
{
    // body
}

@ytmimi
Copy link
Contributor

ytmimi commented Aug 18, 2022

@jmj0502 I opened up a new issue for this odd struct behavior in #5507

@jmj0502
Copy link
Contributor Author

jmj0502 commented Aug 18, 2022

@ytmimi Okok, I'll proceed to remove the examples 👍

@ytmimi
Copy link
Contributor

ytmimi commented Aug 18, 2022

@ytmimi Okok, I'll proceed to remove the examples 👍

To be clear, I'd like to keep the impl example since that's what this PR focused on, but we can remove the struct example for now until we sort out what's going on in the odd case of an empty body + where clause.

@jmj0502
Copy link
Contributor Author

jmj0502 commented Aug 18, 2022

@ytmimi Okok, no worries! Looking forward to eventually re-introduce such examples (possibly in the PR that solves #5507).

@jmj0502
Copy link
Contributor Author

jmj0502 commented Aug 18, 2022

@ytmimi Donee!

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

Successfully merging this pull request may close these issues.

Visual IndentStyle is broken on impl with where clause
2 participants