@@ -3405,6 +3405,37 @@ parameters. You can read more about it in the API documentation:
3405
3405
https://doc.rust-lang.org/std/marker/struct.PhantomData.html
3406
3406
"## ,
3407
3407
3408
+ E0393 : r##"
3409
+ A type parameter which references `Self` in its default value was not specified.
3410
+ Example of erroneous code:
3411
+
3412
+ ```compile_fail
3413
+ trait A<T=Self> {}
3414
+
3415
+ fn together_we_will_rule_the_galaxy(son: &A) {}
3416
+ // error: the type parameter `T` must be explicitly specified in an
3417
+ // object type because its default value `Self` references the
3418
+ // type `Self`
3419
+ ```
3420
+
3421
+ A trait object is defined over a single, fully-defined trait. With a regular
3422
+ default parameter, this parameter can just be substituted in. However, if the
3423
+ default parameter is `Self`, the trait changes for each concrete type; i.e.
3424
+ `i32` will be expected to implement `A<i32>`, `bool` will be expected to
3425
+ implement `A<bool>`, etc... These types will not share an implementation of a
3426
+ fully-defined trait; instead they share implementations of a trait with
3427
+ different parameters substituted in for each implementation. This is
3428
+ irreconcilable with what we need to make a trait object work, and is thus
3429
+ disallowed. Making the trait concrete by explicitly specifying the value of the
3430
+ defaulted parameter will fix this issue. Fixed example:
3431
+
3432
+ ```
3433
+ trait A<T=Self> {}
3434
+
3435
+ fn together_we_will_rule_the_galaxy(son: &A<i32>) {} // Ok!
3436
+ ```
3437
+ "## ,
3438
+
3408
3439
E0439 : r##"
3409
3440
The length of the platform-intrinsic function `simd_shuffle`
3410
3441
wasn't specified. Erroneous code example:
@@ -3755,8 +3786,6 @@ register_diagnostics! {
3755
3786
// between structures
3756
3787
E0377 , // the trait `CoerceUnsized` may only be implemented for a coercion
3757
3788
// between structures with the same definition
3758
- E0393 , // the type parameter `{}` must be explicitly specified in an object
3759
- // type because its default value `{}` references the type `Self`"
3760
3789
E0399 , // trait items need to be implemented because the associated
3761
3790
// type `{}` was overridden
3762
3791
E0436 , // functional record update requires a struct
0 commit comments