-
Notifications
You must be signed in to change notification settings - Fork 928
stop to strip 'impl' from impl trait type alias #3816
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we should handle whether to add impl
by adding a wrapper GenericBounds
and implement Rewrite
trait against it:
struct GenericBounds<'a> {
generic_bounds: &'a ast::GenericBounds,
has_impl: bool,
}
impl<'a> Rewrite for GenericBounds<'a> {
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
self.generic_bounds.rewrite(context, shape)
.map(|s| if self.has_impl { format!("impl {}", s } else { s })
}
}
and use it inside rewrite_type_alias
and rewrite_opaque_type
.
I added the commit to remove has_impl in GenericBounds. I don't think it necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks for the update! The code looks good to me.
Thank you! |
fix: #3815