1 A non-default implementation was already made on this type so it cannot be
4 Erroneous code example:
7 #![feature(specialization)]
14 impl<T> SpaceLlama for T {
15 default fn fly(&self) {}
19 // applies to all `Clone` T and overrides the previous impl
20 impl<T: Clone> SpaceLlama for T {
24 // since `i32` is clone, this conflicts with the previous implementation
25 impl SpaceLlama for i32 {
26 default fn fly(&self) {}
27 // error: item `fly` is provided by an `impl` that specializes
28 // another, but the item in the parent `impl` is not marked
29 // `default` and so it cannot be specialized.
33 Specialization only allows you to override `default` functions in
36 To fix this error, you need to mark all the parent implementations as default.
40 #![feature(specialization)]
47 impl<T> SpaceLlama for T {
48 default fn fly(&self) {} // This is a parent implementation.
51 // applies to all `Clone` T; overrides the previous impl
52 impl<T: Clone> SpaceLlama for T {
53 default fn fly(&self) {} // This is a parent implementation but was
54 // previously not a default one, causing the error
57 // applies to i32, overrides the previous two impls
58 impl SpaceLlama for i32 {
59 fn fly(&self) {} // And now that's ok!