A non-default implementation was already made on this type so it cannot be
specialized further.
Erroneous code example:
#![allow(unused)]#![feature(specialization)]fnmain() {
traitSpaceLlama {
fnfly(&self);
}
// applies to all Timpl<T> SpaceLlama for T {
default fnfly(&self) {}
}
// non-default impl// applies to all `Clone` T and overrides the previous implimpl<T: Clone> SpaceLlama for T {
fnfly(&self) {}
}
// since `i32` is clone, this conflicts with the previous implementationimpl SpaceLlama fori32 {
default fnfly(&self) {}
// error: item `fly` is provided by an `impl` that specializes// another, but the item in the parent `impl` is not marked// `default` and so it cannot be specialized.
}
}
ⓘ
Specialization only allows you to override default functions in
implementations.
To fix this error, you need to mark all the parent implementations as default.
Example:
#![allow(unused)]#![feature(specialization)]fnmain() {
traitSpaceLlama {
fnfly(&self);
}
// applies to all Timpl<T> SpaceLlama for T {
default fnfly(&self) {} // This is a parent implementation.
}
// applies to all `Clone` T; overrides the previous implimpl<T: Clone> SpaceLlama for T {
default fnfly(&self) {} // This is a parent implementation but was// previously not a default one, causing the error
}
// applies to i32, overrides the previous two implsimpl SpaceLlama fori32 {
fnfly(&self) {} // And now that's ok!
}
}