Issue #1119: A struct named Box with a function field fails in rustc: the lowered closure’s Box::pin resolves to the program’s Box

Open and answer this issue on GitHub.

ready · opened 2026-11-01 · updated 2026-11-01 · 0 comments

Part I names a struct Box[T] in its own example, so Box is a free name for a program. When such a struct holds a function value, the lowered Rust wraps the lambda in Box::pin(..), which resolves to the program’s struct, and rustc’s error comes back to the user.

Probe (0.0.1335):

struct Box {
    run: fn(i64) -> i64,
}

fn main() {
    let b = Box { run: fn(x) { x + 1 } }
    print(b.run(1))
}
error: No associated function or constant named `pin` found for struct `Box` in the current scope.
 --> b.nika:6:5

Renamed to Holder, the program prints 2.

To build

Back to Open Issues