Closed
Description
Code
struct Foo {
x: i32
}
impl Foo {
fn foo(&self) {
let _ = format!("{x}");
}
}
Current output
Checking test_ v0.1.0 (/home/lrne/Project/Rust/test_)
error[E0425]: cannot find value `x` in this scope
--> src/main.rs:6:27
|
6 | let _ = format!("{x}");
| ^
|
help: you might have meant to use the available field
|
6 | let _ = format!("{self.x}");
| +++++
For more information about this error, try `rustc --explain E0425`.
error: could not compile `test_` (bin "test_") due to 1 previous error
Desired output
Checking test_ v0.1.0 (/home/lrne/Project/Rust/test_)
error[E0425]: cannot find value `x` in this scope
--> src/main.rs:6:27
|
6 | let _ = format!("{x}");
| ^
|
help: you might have meant to use the available field
|
6 | let _ = format!("{}", self.x);
| ++++++
For more information about this error, try `rustc --explain E0425`.
error: could not compile `test_` (bin "test_") due to 1 previous error
Rationale and extra context
No response
Other cases
Rust Version
rustc 1.88.0-nightly (a15cce269 2025-04-17)
binary: rustc
commit-hash: a15cce2690e8fab72422515c9dc02c6fbc506733
commit-date: 2025-04-17
host: aarch64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Anything else?
No response