Closed
Description
I tried this code:
/// foo.rs
pub struct Foo(pub i32);
Build command: rustc --crate-type rlib foo.rs
/// bar.rs
extern crate foo;
pub struct Bar(pub i32);
Build command: rustc --crate-type rlib bar.rs --extern priv:foo=libfoo.rlib -Zunstable-options
/// baz.rs
extern crate bar;
extern crate foo;
pub fn baz() -> (Option<foo::Foo>, Option<bar::Bar>) {(None, None)}
Build command: `rustc --crate-type rlib baz.rs -L all=. '.
I expected to see this happen: no warning message
Instead, this happened:
warning: type'Foo' from private dependency'foo' in public interface
--> baz.rs:3:1
|
3 | pub fn baz() -> (Option<foo::Foo>, Option<bar::Bar>) {(None, None)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(exported_private_dependencies)]` on by default
warning: 1 warning emitted
But if you take rustc --crate-type rlib baz.rs -L all=. --extern foo
then there will be no warning message, or adjust the statement in baz.rs
as follows, and there will be no warning message
extern crate foo;
extern crate bar;
pub fn baz() -> (Option<foo::Foo>, Option<bar::Bar>) {(None, None)}
Meta
rustc --version --verbose
:
rustc 1.78.0-nightly (4a0cc881d 2024-03-11)
binary: rustc
commit-hash: 4a0cc881dcc4d800f10672747f61a94377ff6662
commit-date: 2024-03-11
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0
Backtrace