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

rustfmt eating up my where clauses on generic associated types #4257

Closed
steffahn opened this issue Jun 14, 2020 · 1 comment
Closed

rustfmt eating up my where clauses on generic associated types #4257

steffahn opened this issue Jun 14, 2020 · 1 comment
Labels

Comments

@steffahn
Copy link
Member

steffahn commented Jun 14, 2020

#![feature(generic_associated_types)]
#![allow(incomplete_features)]

trait Trait<T> {
    type Type<'a> where T: 'a;
    fn foo(x: &T) -> Self::Type<'_>;
}
impl<T> Trait<T> for () {
    type Type<'a> where T: 'a = &'a T;
    fn foo(x: &T) -> Self::Type<'_> {
        x
    }
}

(Playground)

The result after applying rustfmt:

#![feature(generic_associated_types)]
#![allow(incomplete_features)]

trait Trait<T> {
    type Type<'a>;
    fn foo(x: &T) -> Self::Type<'_>;
}
impl<T> Trait<T> for () {
    type Type<'a> = &'a T;
    fn foo(x: &T) -> Self::Type<'_> {
        x
    }
}
@calebcartwright
Copy link
Member

Thank you for the report @steffahn. This has already been fixed within rustfmt, just not yet released. Accordingly I am going to go ahead and close this as there's no additional changes to be made within rustfmt.

In the meantime you may want to consider using #[rustfmt::skip] on your types to keep rustfmt from mangling them.

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

No branches or pull requests

2 participants