From 4ec991989af4662104fdbafc43b12232887fa0b4 Mon Sep 17 00:00:00 2001 From: xizheyin Date: Tue, 20 May 2025 14:10:17 +0800 Subject: [PATCH] Add println! test for sugg-field-in-format-string-issue-141136 Signed-off-by: xizheyin --- .../sugg-field-in-format-string-issue-141136.rs | 1 + .../sugg-field-in-format-string-issue-141136.stderr | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.rs b/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.rs index e0c2f4960461..d2aa61186bcd 100644 --- a/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.rs +++ b/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.rs @@ -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] } } diff --git a/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.stderr b/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.stderr index 795de38d0279..0a84848081d5 100644 --- a/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.stderr +++ b/tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.stderr @@ -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`.