E0004#
Warning name: missing_priv
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.
This warning is not emitted inside main packages which are usually not
intended to be used by others anyway. Likewise, it is not emitted inside
whitebox test and blackbox test
files.
Erroneous example#
///|
struct Code(Int)
///|
fn Code::new(code : Int) -> Code {
Code(code)
}
///|
test {
let Code(_) = Code::new(42)
}
Suggestion#
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(Debug)
///|
pub fn Code2::new(value : Int) -> Code2 {
return value
}