@@ -3645,55 +3645,63 @@ fn main() {
36453645"## ,
36463646
36473647E0520 : r##"
3648- A non-default implementation was already made on this type
3649- implementation so it cannot be specialized afterward. Erroneous
3650- code example:
3648+ A non-default implementation was already made on this type so it cannot be
3649+ specialized further. Erroneous code example:
36513650
36523651```compile_fail
36533652#![feature(specialization)]
36543653
3655- trait SpaceLama {
3654+ trait SpaceLlama {
36563655 fn fly(&self);
36573656}
36583657
3659- impl<T> SpaceLama for T {
3658+ // applies to all T
3659+ impl<T> SpaceLlama for T {
36603660 default fn fly(&self) {}
36613661}
36623662
3663- impl<T: Clone> SpaceLama for T {
3663+ // non-default impl
3664+ // applies to all `Clone` T and overrides the previous impl
3665+ impl<T: Clone> SpaceLlama for T {
36643666 fn fly(&self) {}
36653667}
36663668
3667- impl SpaceLama for i32 {
3669+ // since `i32` is clone, this conflicts with the previous implementation
3670+ impl SpaceLlama for i32 {
36683671 default fn fly(&self) {}
36693672 // error: item `fly` is provided by an `impl` that specializes
36703673 // another, but the item in the parent `impl` is not marked
36713674 // `default` and so it cannot be specialized.
36723675}
36733676```
36743677
3675- To fix this error, you need to specialize the implementation on the
3676- parent(s) implementation first. Example:
3678+ Specialization only allows you to override `default` functions in
3679+ implementations.
36773680
3678- ```compile_fail
3681+ To fix this error, you need to mark all the parent implementations as default.
3682+ Example:
3683+
3684+ ```
36793685#![feature(specialization)]
36803686
3681- trait SpaceLama {
3687+ trait SpaceLlama {
36823688 fn fly(&self);
36833689}
36843690
3685- impl<T> SpaceLama for T {
3691+ // applies to all T
3692+ impl<T> SpaceLlama for T {
36863693 default fn fly(&self) {} // This is a parent implementation.
36873694}
36883695
3689- impl<T: Clone> SpaceLama for T {
3690- default fn fly(&self) {} // This is a parent implementation but not
3691- // a default one so you need to add default
3692- // keyword.
3696+ // applies to all `Clone` T; overrides the previous impl
3697+ impl<T: Clone> SpaceLlama for T {
3698+ default fn fly(&self) {} // This is a parent implementation but was
3699+ // previously not a default one, causing the error
36933700}
36943701
3695- impl SpaceLama for i32 {
3696- default fn fly(&self) {} // And now that's ok!
3702+ // applies to i32, overrides the previous two impls
3703+ impl SpaceLlama for i32 {
3704+ fn fly(&self) {} // And now that's ok!
36973705}
36983706```
36993707"## ,
0 commit comments