Add println! test for sugg-field-in-format-string-issue-141136

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
xizheyin 2025-05-20 14:10:17 +08:00
parent 9de7fff0d8
commit 4ec991989a
No known key found for this signature in database
GPG key ID: 0A0D90BE99CEDEAD
2 changed files with 10 additions and 1 deletions

View file

@ -8,6 +8,7 @@ impl Foo {
let _ = format!("{x }"); //~ ERROR cannot find value `x` in this scope [E0425]
let _ = format!("{ x}"); //~ ERROR invalid format string: expected `}`, found `x`
let _ = format!("{}", x); //~ ERROR cannot find value `x` in this scope [E0425]
println!("{x}"); //~ ERROR cannot find value `x` in this scope [E0425]
}
}

View file

@ -35,6 +35,14 @@ help: you might have meant to use the available field
LL | let _ = format!("{}", self.x);
| +++++
error: aborting due to 4 previous errors
error[E0425]: cannot find value `x` in this scope
--> $DIR/sugg-field-in-format-string-issue-141136.rs:11:20
|
LL | println!("{x}");
| ^
|
= help: you might have meant to use the available field in a format string: `"{}", self.x`
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0425`.