Expand description

The exported_private_dependencies lint detects private dependencies that are exposed in a public interface.


pub fn foo() -> Option<some_private_dependency::Thing> {

This will produce:

warning: type `bar::Thing` from private dependency 'bar' in public interface
 --> src/
3 | pub fn foo() -> Option<bar::Thing> {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: `#[warn(exported_private_dependencies)]` on by default


Dependencies can be marked as “private” to indicate that they are not exposed in the public interface of a crate. This can be used by Cargo to independently resolve those dependencies because it can assume it does not need to unify them with other packages using that same dependency. This lint is an indication of a violation of that contract.

To fix this, avoid exposing the dependency in your public interface. Or, switch the dependency to a public dependency.

Note that support for this is only available on the nightly channel. See RFC 1977 for more details, as well as the Cargo documentation.