Tried to access an item that isn't visible from the call site.
mod inner {
fn helper() { println!("inner"); }
}
fn main() { inner::helper(); } // E0603: helper is private
Items default to private. Without pub (or a more restrictive pub(crate) / pub(super)), only code inside the same module sees them.
- Add visibility: pub fn helper() {} or pub(crate) fn helper() {}.
- For items used only within the crate, prefer pub(crate) over pub — keeps the public API surface minimal.
- For struct fields, pub struct Foo { pub bar: i32 } exposes the field; otherwise add a pub getter.
- Re-export with pub use to flatten module structure for callers.