E4078

E4078#

Cannot derive trait for type.

MoonBit allows you to derive implementation of some traits for your types. However, not all types can be automatically derived. For example, you cannot derive a trait for an abstract type.

Erroneous example#

type T derive(Hash) // Error: Cannot derive trait Hash for type T: target type is abstract

Suggestion#

You can implement the trait manually:

type T

impl Hash for T with hash_combine(self : T, hasher: Hasher) {
  // ...
}