-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Describe the bug
When constraining a generic associated type, rustfmt will remove any parameters for that type. I.e.:
struct MyType<'a, A: MyApi<Assoc<'a> = ()>> {}
will be reformatted to
struct MyType<'a, A: MyApi<Assoc = ()>> {}
To Reproduce
The following code compiles and runs, but when running rustfmt on it it will remove the generics for the associated type:
#![feature(generic_associated_types)]
trait MyApi {
type Assoc<'a>;
}
struct MyImpl {}
impl MyApi for MyImpl {
type Assoc<'a> = ();
}
// NOTE: "Assoc<'a> = ()" gets reformatted as "Assoc = ()" when running rustfmt
struct MyType<'a, A: MyApi<Assoc<'a> = ()>> {
a: A,
_m: core::marker::PhantomData<&'a A>,
}
fn main() {
let s = MyImpl {};
let t = MyType {
a: s,
_m: core::marker::PhantomData,
};
}
Expected behavior
The above code compiles and should not be formatted so it doesn't compile.
Meta
- rustfmt version: 1.4.37-nightly (0bd2b19 2021-04-03)
- From where did you install rustfmt?: rustup
- How do you run rustfmt: rustfmt, cargo fmt
memoryruins and wada314