From ef212e7fb306626b4dc2c484aa3cf3b42a83e83a Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Fri, 1 Oct 2021 13:05:17 +0000 Subject: Point at overlapping impls when type annotations are needed --- .../method-ambig-one-trait-unknown-int-type.rs | 2 +- .../method-ambig-one-trait-unknown-int-type.stderr | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/test/ui/methods') 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`, 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 { + | ^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Foo for Vec { + | ^^^^^^^^^^^^^^^^^^^^^^^ + 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`. -- cgit 1.4.1-3-g733a5