1 A type parameter which references `Self` in its default value was not specified.
2 Example of erroneous code:
7 fn together_we_will_rule_the_galaxy(son: &A) {}
8 // error: the type parameter `T` must be explicitly specified in an
9 // object type because its default value `Self` references the
13 A trait object is defined over a single, fully-defined trait. With a regular
14 default parameter, this parameter can just be substituted in. However, if the
15 default parameter is `Self`, the trait changes for each concrete type; i.e.
16 `i32` will be expected to implement `A<i32>`, `bool` will be expected to
17 implement `A<bool>`, etc... These types will not share an implementation of a
18 fully-defined trait; instead they share implementations of a trait with
19 different parameters substituted in for each implementation. This is
20 irreconcilable with what we need to make a trait object work, and is thus
21 disallowed. Making the trait concrete by explicitly specifying the value of the
22 defaulted parameter will fix this issue. Fixed example:
27 fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok!