1 A non-default implementation was already made on this type so it cannot be
2 specialized further. Erroneous code example:
5 #![feature(specialization)]
12 impl<T> SpaceLlama for T {
13 default fn fly(&self) {}
17 // applies to all `Clone` T and overrides the previous impl
18 impl<T: Clone> SpaceLlama for T {
22 // since `i32` is clone, this conflicts with the previous implementation
23 impl SpaceLlama for i32 {
24 default fn fly(&self) {}
25 // error: item `fly` is provided by an `impl` that specializes
26 // another, but the item in the parent `impl` is not marked
27 // `default` and so it cannot be specialized.
31 Specialization only allows you to override `default` functions in
34 To fix this error, you need to mark all the parent implementations as default.
38 #![feature(specialization)]
45 impl<T> SpaceLlama for T {
46 default fn fly(&self) {} // This is a parent implementation.
49 // applies to all `Clone` T; overrides the previous impl
50 impl<T: Clone> SpaceLlama for T {
51 default fn fly(&self) {} // This is a parent implementation but was
52 // previously not a default one, causing the error
55 // applies to i32, overrides the previous two impls
56 impl SpaceLlama for i32 {
57 fn fly(&self) {} // And now that's ok!