error: type parameters with a default must be trailing
--> tests/test.rs:987:17
|
987 | trait Trait<T = ()> {
| ^
error: could not compile `async-trait`.
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions.
--> tests/test.rs:987:17
|
987 | trait Trait<T = ()> {
| ^
|
= note: `#[deny(invalid_type_param_default)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
Solution
Filter out defaults when reusing trait generics for function definition.
Synopsis
At the moment, if trait has type/const parameters with default values and also has a default method implementation, like the following:
The expanded code is:
And
rustc
complains with the error:Solution
Filter out defaults when reusing trait generics for function definition.