E0460: Private unqualified access
| Code | Category | Stability |
|---|---|---|
E0460 | Struct and enum | Permanent |
Explanation
A comptime type constructor reached through a module binding was applied in a type annotation from outside its defining directory, but the constructor is private. Applying a constructor is the one privacy violation with its own code: it is checked at the application site and names the constructor and its defining file. Every other private access — naming a private fn, const, struct, or enum through a module, in any position, and reaching one through a private module binding on the way — is E0706. The metadata name PRIVATE_UNQUALIFIED_ACCESS is historical and describes nothing E0460 reports.
Likely cause
A type annotation names a module-qualified function returning type, such as lib.Secret(i32), but that function lacks pub and the referencing file is in another directory. Mark the constructor pub when it is part of the module's interface, or keep the use within the constructor's defining directory.
Examples
Apply a private type constructor across directories
// --- main.rue
const lib = @import("sub/lib.rue");
fn main() -> i32 {
let value: lib.Secret(i32) = lib.make();
value.item
}
// --- sub/lib.rue
fn Secret(comptime T: type) -> type { struct { item: T } }
pub fn make() -> Secret(i32) {
let S = Secret(i32);
S { item: 42 }
}
Export the type constructor
// --- main.rue
const lib = @import("sub/lib.rue");
fn main() -> i32 {
let value: lib.Secret(i32) = lib.make();
value.item
}
// --- sub/lib.rue
pub fn Secret(comptime T: type) -> type { struct { item: T } }
pub fn make() -> Secret(i32) {
let S = Secret(i32);
S { item: 42 }
}