about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorxizheyin <xizheyin@smail.nju.edu.cn>2025-05-18 16:14:48 +0800
committerxizheyin <xizheyin@smail.nju.edu.cn>2025-05-18 16:14:48 +0800
commit9de7fff0d8ab72fb57dea6255fc10fe35219db72 (patch)
tree6de558e92852753c10ce9256d7c196f855144b28 /tests
parentfe0663c33d24c903812ec0fe58b94d68aa275b98 (diff)
downloadrust-9de7fff0d8ab72fb57dea6255fc10fe35219db72.tar.gz
rust-9de7fff0d8ab72fb57dea6255fc10fe35219db72.zip
Suggest use `"{}", self.x` instead of `{self.x}` when resolve `x` as field of `self`
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/resolve/suggestions/sugg-field-in-format-string-issue-141136.stderr10
-rw-r--r--tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr12
2 files changed, 4 insertions, 18 deletions
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 4bdefa70a00..795de38d027 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
@@ -14,10 +14,7 @@ error[E0425]: cannot find value `x` in this scope
 LL |         let _ = format!("{x}");
    |                           ^
    |
-help: you might have meant to use the available field
-   |
-LL |         let _ = format!("{self.x}");
-   |                           +++++
+   = help: you might have meant to use the available field in a format string: `"{}", self.x`
 
 error[E0425]: cannot find value `x` in this scope
   --> $DIR/sugg-field-in-format-string-issue-141136.rs:8:27
@@ -25,10 +22,7 @@ error[E0425]: cannot find value `x` in this scope
 LL |         let _ = format!("{x }");
    |                           ^^
    |
-help: you might have meant to use the available field
-   |
-LL |         let _ = format!("{self.x }");
-   |                           +++++
+   = help: you might have meant to use the available field in a format string: `"{}", self.x`
 
 error[E0425]: cannot find value `x` in this scope
   --> $DIR/sugg-field-in-format-string-issue-141136.rs:10:31
diff --git a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
index 5832cb69a3d..1ecbfee17bc 100644
--- a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
+++ b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
@@ -20,17 +20,9 @@ error[E0425]: cannot find value `config` in this scope
   --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:15:20
    |
 LL |         println!("{config}");
-   |                    ^^^^^^
-   |
-help: you might have meant to use the available field
-   |
-LL |         println!("{self.config}");
-   |                    +++++
-help: a local variable with a similar name exists
-   |
-LL -         println!("{config}");
-LL +         println!("{cofig}");
+   |                    ^^^^^^ help: a local variable with a similar name exists: `cofig`
    |
+   = help: you might have meant to use the available field in a format string: `"{}", self.config`
 
 error[E0425]: cannot find value `bah` in this scope
   --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:33:9