E1003

E1003#

Unused type declaration.

This type is not used by any other part of your code, and it is private. Type declaration is by default abstract, which means it is publicly visible to users of this package, but they cannot see the implementation of the type, nor can create instances of it directly. Therefore, this warning is only shown if the type is marked with priv visibility, and is not used by any other part of this package.

Note that this warning might uncover other bugs in your code. For example, if there are two types in the package that has similar name, you might just use the other type by mistake.

Erroneous example#

priv struct Foo { // Warning: Unused type 'Foo'.
  bar : Int
}

fn main {
  struct Bar { // Warning: Unused type 'Bar'.
    foot : Int
  }
}

Suggestion#

There are multiple ways to fix this warning:

  • If the type is indeed useless, you can remove the definition of the type.

  • If this type is not local, and is part of the public API of your module, you can remove the priv visibility keyword from the type.

    struct Foo {
      bar : Int
    }
    
  • Check if you are referencing the type with a correct name.

It is rather rare to have a type that is private and unused at the same time; therefore, we suggest you remove the type if it is not used.