E0004

E0004#

The abstract type does not occur in public signature of current package, consider marking it as priv.

If an abstract type is not used elsewhere in the public interface of a package, then it is not possible for user to interact with the value of that type in any way. Therefore, it is highly probable that the type is part of the private implementation of the package. In this case, it is better to mark the type as priv to indicate that it is not part of the public interface of the package.

It is also possible that, this abstract type is part of the public interface of the package, but relevant functions, methods, or types are not marked as pub.

这个警告不会在 main 包中发出,因为它们通常不打算被其他人使用。同样地,它也不会在 白盒测试和黑盒测试 文件中发出。

错误示例#

///|
struct Code(Int)

///|
fn Code::new(code : Int) -> Code {
  Code(code)
}

///|
test {
  let Code(_) = Code::new(42)

}

建议#

If the abstract type is not part of the public interface of the package, then it should be marked as priv:

///|
priv struct Code(Int)

Or, if the abstract type is part of the public interface of the package, then make relevant definitions pub:

///|
struct Code2(Int) derive(Show)

///|
pub fn Code2::new(value : Int) -> Code2 {
  return value
}