Fn are never used

i'm using play.rust for testing. why does this says both functions are never used?

fn main() {
    let b = Box::new(0);
    let b2 = b.clone();
    println!("{}", b);
    move_a_box(b2);
}

fn move_a_box(x: Box<i32>) {
    println!("{x}");
}

if main() is the entry point then it was used!?

You should not get dead_code warnings for that code unless you are compiling the code in a way that means fn main() isn't called.

It looks like if you choose “Build” instead of “Run”, the Playground will compile your code as a library instead of a binary, which would cause that. Consider this a quirk of the Playground (which is trying to avoid presenting you with a “binary or library” menu to have to pick from), not something about Rust itself.

Does the upper-left red button say Build instead of Run? If so, you're building a library and not a binary, and other crates can't call your private functions, so they're unused. You could try:

pub fn move_a_box(x: Box<i32>) { ... }

But probably you actually want to select Run .

You can also cheat that and do build-only with pub fn main.