about summary refs log tree commit diff
diff options
context:
space:
mode:
authorxizheyin <xizheyin@smail.nju.edu.cn>2025-05-20 14:10:17 +0800
committerxizheyin <xizheyin@smail.nju.edu.cn>2025-05-20 14:10:17 +0800
commit4ec991989af4662104fdbafc43b12232887fa0b4 (patch)
tree07bc136830cd0704834c8cabb6c3c5f20a6c78e0
parent9de7fff0d8ab72fb57dea6255fc10fe35219db72 (diff)
downloadrust-4ec991989af4662104fdbafc43b12232887fa0b4.tar.gz
rust-4ec991989af4662104fdbafc43b12232887fa0b4.zip
Add println! test for sugg-field-in-format-string-issue-141136
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
-rw-r--r--tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.rs1
-rw-r--r--tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.stderr10
2 files changed, 10 insertions, 1 deletions
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 e0c2f496046..d2aa61186bc 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 795de38d027..0a84848081d 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`.