Open
Description
Given the following code:
struct Foo {
value: i32
}
impl Foo {
fn f(&self) -> String {
format!("{value}")
}
}
The current output is:
error[E0425]: cannot find value `value` in this scope
--> src/lib.rs:7:19
|
7 | format!("{value}")
| ^^^^^ help: you might have meant to use the available field: `self.value`
Applying the suggestion doesn't work since format strings don't allow non-identifier expressions. Fortunately applying the suggestion and compiling again will lead to another suggestion with the correct syntax. Ideally the original diagnostic should provide the correct syntax of format!("{}", self.value)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: `core::fmt`Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: Name/path resolution done by `rustc_resolve` specificallyArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: A structured suggestion resulting in incorrect code.Relevant to the compiler team, which will review and decide on the PR/issue.