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

Update where-clause position of generic associated types according to rust-lang issue #89122 #33

Merged
merged 3 commits into from Jan 5, 2023

Conversation

wada314
Copy link
Contributor

@wada314 wada314 commented Jan 4, 2023

Hello! 😀
When I'm using this formatter I noticed it's not yet supporting the recent rust's syntax update.
So I'm sending you a small patch to fix it. Thanks! 🙇

Sample diff from my code:
https://user-images.githubusercontent.com/1488411/210623996-300f6a29-f730-4e1d-a16f-d95133b66f91.png
(My test cases is not enough I think, I only tested the type alias in impl_item. But it's trivial so assume it's okay...)

src/item.rs Outdated
self.neverbreak();
self.ibox(-INDENT);
self.ty(&item.ty);
self.end();
self.word(";");
self.where_clause_oneline_semi(&item.generics.where_clause);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is correct. Where-clause is not allowed after the type on type aliases.

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=19a4e998272aede03ba0d8aae2938620

Copy link
Contributor Author

@wada314 wada314 Jan 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow that's true. Reverted the code here.

src/item.rs Outdated
self.neverbreak();
self.ty(default);
self.where_clause_oneline_semi(&trait_item.generics.where_clause);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this line out of the if block since it is identical to the other branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 88079f5 into dtolnay:master Jan 5, 2023
@dtolnay dtolnay changed the title Update the type alias's where clause position according to rust-lang issue #89122 Update where-clause position of generic associated types according to rust-lang issue #89122 Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants