You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mod privmod {pubstructHiddenType;implHiddenType{pubfnhidden_method(&self){}}}pubmod pubmod {use privmod;pubfnexpose() -> privmod::HiddenType{
privmod::HiddenType}}pubuse pubmod::expose;
produces the warning:
warning: method is never used: hidden_method, #[warn(dead_code)] on by default
I think it's not correct, because hidden_method can be called from outside the crate by getting an instance of the type via pubmod::expose.
I'd expect Rust to either stop with an error that a private type (private due to being in a private module) is exposed, or figure out that the method is exposed indirectly and assume it's used.
This problem creates another when linking across crates. To reproduce the problem: take the example code above and put it in src/lib.rs of a crate called "library", and then create a crate "tool" with it as a dependency:
Compilation of:
produces the warning:
I think it's not correct, because
hidden_method
can be called from outside the crate by getting an instance of the type viapubmod::expose
.I'd expect Rust to either stop with an error that a private type (private due to being in a private module) is exposed, or figure out that the method is exposed indirectly and assume it's used.
This problem creates another when linking across crates. To reproduce the problem: take the example code above and put it in
src/lib.rs
of a crate called "library", and then create a crate "tool" with it as a dependency:tool/Cargo.toml
+=and
src/bin/tool.rs
as follows:cargo run --bin tool
will compile, but won't link:I'd prefer this to either work, or fail at compilation stage, because linker errors are scary.
rustc 1.4.0-nightly (8f1b0aa 2015-08-21); OS X 11.11
The text was updated successfully, but these errors were encountered: