about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-02-09 20:54:26 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-02-22 18:04:55 +0000
commitd30dfb0af72ab71ee267eecef26a6270cee8822b (patch)
tree5d061bd3c1a6759d0c58d45214aa631cbe478e15 /tests
parente13d4521113a32ec3aaabf659fc045874acb91c9 (diff)
downloadrust-d30dfb0af72ab71ee267eecef26a6270cee8822b.tar.gz
rust-d30dfb0af72ab71ee267eecef26a6270cee8822b.zip
Provide more and more accurate suggestions when calling the wrong method
```
error[E0308]: mismatched types
  --> $DIR/rustc_confusables_std_cases.rs:20:14
   |
LL |     x.append(42);
   |       ------ ^^ expected `&mut Vec<{integer}>`, found integer
   |       |
   |       arguments to this method are incorrect
   |
   = note: expected mutable reference `&mut Vec<{integer}>`
                           found type `{integer}`
note: method defined here
  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
help: you might have meant to use `push`
   |
LL |     x.push(42);
   |       ~~~~
```
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/attributes/rustc_confusables_std_cases.rs2
-rw-r--r--tests/ui/attributes/rustc_confusables_std_cases.stderr23
2 files changed, 22 insertions, 3 deletions
diff --git a/tests/ui/attributes/rustc_confusables_std_cases.rs b/tests/ui/attributes/rustc_confusables_std_cases.rs
index eda35e4b633..95093f5e72c 100644
--- a/tests/ui/attributes/rustc_confusables_std_cases.rs
+++ b/tests/ui/attributes/rustc_confusables_std_cases.rs
@@ -17,6 +17,8 @@ fn main() {
     x.size(); //~ ERROR E0599
     //~^ HELP you might have meant to use `len`
     //~| HELP there is a method with a similar name
+    x.append(42); //~ ERROR E0308
+    //~^ HELP you might have meant to use `push`
     String::new().push(""); //~ ERROR E0308
     //~^ HELP you might have meant to use `push_str`
     String::new().append(""); //~ ERROR E0599
diff --git a/tests/ui/attributes/rustc_confusables_std_cases.stderr b/tests/ui/attributes/rustc_confusables_std_cases.stderr
index f69b79b4028..7d2410bb0ef 100644
--- a/tests/ui/attributes/rustc_confusables_std_cases.stderr
+++ b/tests/ui/attributes/rustc_confusables_std_cases.stderr
@@ -58,7 +58,24 @@ LL |     x.resize();
    |       ~~~~~~
 
 error[E0308]: mismatched types
-  --> $DIR/rustc_confusables_std_cases.rs:20:24
+  --> $DIR/rustc_confusables_std_cases.rs:20:14
+   |
+LL |     x.append(42);
+   |       ------ ^^ expected `&mut Vec<{integer}>`, found integer
+   |       |
+   |       arguments to this method are incorrect
+   |
+   = note: expected mutable reference `&mut Vec<{integer}>`
+                           found type `{integer}`
+note: method defined here
+  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+help: you might have meant to use `push`
+   |
+LL |     x.push(42);
+   |       ~~~~
+
+error[E0308]: mismatched types
+  --> $DIR/rustc_confusables_std_cases.rs:22:24
    |
 LL |     String::new().push("");
    |                   ---- ^^ expected `char`, found `&str`
@@ -73,7 +90,7 @@ LL |     String::new().push_str("");
    |                   ~~~~~~~~
 
 error[E0599]: no method named `append` found for struct `String` in the current scope
-  --> $DIR/rustc_confusables_std_cases.rs:22:19
+  --> $DIR/rustc_confusables_std_cases.rs:24:19
    |
 LL |     String::new().append("");
    |                   ^^^^^^ method not found in `String`
@@ -83,7 +100,7 @@ help: you might have meant to use `push_str`
 LL |     String::new().push_str("");
    |                   ~~~~~~~~
 
-error: aborting due to 7 previous errors
+error: aborting due to 8 previous errors
 
 Some errors have detailed explanations: E0308, E0599.
 For more information about an error, try `rustc --explain E0308`.