about summary refs log tree commit diff
path: root/src/test/ui/methods
diff options
context:
space:
mode:
authorEsteban Kuber <esteban@kuber.com.ar>2021-10-01 13:05:17 +0000
committerEsteban Kuber <esteban@kuber.com.ar>2021-10-24 18:33:04 +0000
commitef212e7fb306626b4dc2c484aa3cf3b42a83e83a (patch)
treebf69c7d6ae4d297c255d52b2832700e560199eb3 /src/test/ui/methods
parented08a67566d7d1d9dd2ad928ff21c23e841a4345 (diff)
downloadrust-ef212e7fb306626b4dc2c484aa3cf3b42a83e83a.tar.gz
rust-ef212e7fb306626b4dc2c484aa3cf3b42a83e83a.zip
Point at overlapping impls when type annotations are needed
Diffstat (limited to 'src/test/ui/methods')
-rw-r--r--src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs2
-rw-r--r--src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr19
2 files changed, 18 insertions, 3 deletions
diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs
index 49fe7d1324c..7b2fc34e1af 100644
--- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs
+++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.rs
@@ -23,7 +23,7 @@ fn m1() {
     // we couldn't infer the type of the vector just based on calling foo()...
     let mut x = Vec::new();
     //~^ ERROR type annotations needed
-    x.foo();
+    x.foo(); //~ ERROR type annotations needed
 }
 
 fn m2() {
diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
index 4b494c96115..f33672433de 100644
--- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
+++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
@@ -6,6 +6,21 @@ LL |     let mut x = Vec::new();
    |         |
    |         consider giving `x` the explicit type `Vec<T>`, where the type parameter `T` is specified
 
+error[E0283]: type annotations needed
+  --> $DIR/method-ambig-one-trait-unknown-int-type.rs:26:7
+   |
+LL |     x.foo();
+   |       ^^^ cannot infer type for struct `Vec<_>`
+   |
+note: multiple `impl`s satisfying `Vec<_>: Foo` found
+  --> $DIR/method-ambig-one-trait-unknown-int-type.rs:9:1
+   |
+LL | impl Foo for Vec<usize> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | impl Foo for Vec<isize> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^
+
 error[E0308]: mismatched types
   --> $DIR/method-ambig-one-trait-unknown-int-type.rs:33:20
    |
@@ -19,7 +34,7 @@ help: you can convert an `isize` to a `usize` and panic if the converted value d
 LL |     let y: usize = x.foo().try_into().unwrap();
    |                           ++++++++++++++++++++
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0282, E0308.
+Some errors have detailed explanations: E0282, E0283, E0308.
 For more information about an error, try `rustc --explain E0282`.