rust-lang/rustfmt

Fail to format GAT with where clause

Closed this issue · 1 comments

Currently rustfmt on stable channel cannot handle the following case:

use std::borrow::Cow;

pub trait CloneS<'a> {
    type Output<'b: 'a>
    where
        Self: 'b;
    fn clone_s<'b: 'a>(&'b self) -> Self::Output<'b>;
}

impl<'a, T: ?Sized + ToOwned> CloneS<'a> for Cow<'a, T> {
    // fail to format below
    type Output<'b: 'a>
        = Cow<'b, T>
         where
        Self: 'b;

    fn clone_s<'b: 'a>(&'b self) -> Self::Output<'b> {
        Cow::Borrowed(&**self)
    }
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6fc6f63873211255d543eb9e4b8016ea

Formatting support was released in version 1.8.0, which is available on nightly. The current stable release is still v1.7.1, which doesn't support formatting for trailing where clauses.