-
Notifications
You must be signed in to change notification settings - Fork 996
Closed
Labels
2x-port:pendingC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE
Description
Describe the bug
When specifying an impl trait type alias for a generic associated type with a lifetime bound on Self, rustfmt will remove the bound, causing a compiler error, i.e.:
impl SomeTrait for SomeType {
type SomeGAT<'a> where Self: 'a = impl SomeOtherTrait;
}will be changed to
impl SomeTrait for SomeType {
type SomeGAT<'a> = impl SomeOtherTrait;
}To Reproduce
The following code compiles, but when running rustfmt on it it will remove the Self bound where Self" 'a in the implementation for Foo leading to a compiler error:
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
#![feature(min_type_alias_impl_trait)]
struct Foo<'b>(&'b ());
trait Iterable {
type Iter<'a>
where
Self: 'a;
fn iter(&self) -> Self::Iter<'_>;
}
impl<'b> Iterable for Foo<'b> {
type Iter<'a> where Self: 'a = impl Iterator + 'a;
fn iter(&self) -> Self::Iter<'_> {
std::iter::once(self.0)
}
}Expected behavior
The above code compiles and should not be formatted so it doesn't compile.
Meta
- rustfmt 1.4.37-nightly (014026d 2021-07-19)
- From where did you install rustfmt?: rustup
- How do you run rustfmt: rustfmt, sublime RustFmt package
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
2x-port:pendingC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE