E0425: cannot find value in this scope
Rust resolves every name at compile time. There is no global namespace you can fall back on, so a name has to be declared in scope or imported with `use`.
Blocks own their bindings: a `let` inside `{ ... }` disappears when the block ends. Declare the binding in the outer scope if you need it later.
Code that triggers it
fn main() {
{
let secret = 42;
}
println!("{secret}"); // error[E0425]
}Code that compiles
fn main() {
let secret = 42;
println!("{secret}");
}Declare the binding in the scope where you use it, check the spelling, and add the right `use` statement for items from other modules.
Try both versions
The broken version is loaded below so you can see the real compiler message, then fix it yourself.
Contrast AAA · 16.6:1
15px