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

if-else condition trailing comments #5651

Closed
estk opened this issue Jan 5, 2023 · 4 comments
Closed

if-else condition trailing comments #5651

estk opened this issue Jan 5, 2023 · 4 comments

Comments

@estk
Copy link

estk commented Jan 5, 2023

Hi!

I am curious why trailing comments on if-else conditions are not allowed with rustfmt.
Fwiw I searched the manual and gh issues to no avail.

As an example, the following code is reformatted.

if days_expired < 0 {           // Has yet to expire.
  Status::Valid
} else if grace_days_left > 0 { // In grace period.
  Status::Grace
} else {                        // Expired and outside of grace period.
  Status::Expired
}
if days_expired < 0 {                
  // has yet to expire
  Status::Valid
} else if grace_days_left > 0 {
  // in grace period
  Status::Grace
} else {                                      
  // Expired and outside of grace period
  Status::Expired
}
@ytmimi
Copy link
Contributor

ytmimi commented Jan 5, 2023

By trailing comments do you mean comments after the opening brace { like you've demonstrated in your example?

@estk
Copy link
Author

estk commented Jan 5, 2023

@ytmimi yessir

@ytmimi
Copy link
Contributor

ytmimi commented Jan 8, 2023

Thanks for filing the issue! I did some digging and it turns out this is a duplicate of #3255

@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2023
@estk
Copy link
Author

estk commented Jan 8, 2023

Amazing, thanks so much!

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

2 participants