diff options
| author | Esteban Kuber <esteban@kuber.com.ar> | 2021-10-01 13:05:17 +0000 |
|---|---|---|
| committer | Esteban Kuber <esteban@kuber.com.ar> | 2021-10-24 18:33:04 +0000 |
| commit | ef212e7fb306626b4dc2c484aa3cf3b42a83e83a (patch) | |
| tree | bf69c7d6ae4d297c255d52b2832700e560199eb3 /src/test/ui/issues | |
| parent | ed08a67566d7d1d9dd2ad928ff21c23e841a4345 (diff) | |
| download | rust-ef212e7fb306626b4dc2c484aa3cf3b42a83e83a.tar.gz rust-ef212e7fb306626b4dc2c484aa3cf3b42a83e83a.zip | |
Point at overlapping impls when type annotations are needed
Diffstat (limited to 'src/test/ui/issues')
| -rw-r--r-- | src/test/ui/issues/issue-29147.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-69455.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-69455.stderr | 24 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-69683.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-69683.stderr | 20 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-72690.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-72690.stderr | 187 |
7 files changed, 228 insertions, 22 deletions
diff --git a/src/test/ui/issues/issue-29147.stderr b/src/test/ui/issues/issue-29147.stderr index f00d5d32bbf..3b011f58b25 100644 --- a/src/test/ui/issues/issue-29147.stderr +++ b/src/test/ui/issues/issue-29147.stderr @@ -4,7 +4,13 @@ error[E0283]: type annotations needed LL | let _ = <S5<_>>::xxx; | ^^^^^^^^^^^^ cannot infer type for struct `S5<_>` | - = note: cannot satisfy `S5<_>: Foo` +note: multiple `impl`s satisfying `S5<_>: Foo` found + --> $DIR/issue-29147.rs:17:1 + | +LL | impl Foo for S5<u32> { fn xxx(&self) {} } + | ^^^^^^^^^^^^^^^^^^^^ +LL | impl Foo for S5<u64> { fn xxx(&self) {} } + | ^^^^^^^^^^^^^^^^^^^^ note: required by `Foo::xxx` --> $DIR/issue-29147.rs:10:13 | diff --git a/src/test/ui/issues/issue-69455.rs b/src/test/ui/issues/issue-69455.rs index f1935ae2534..a53aadcfad0 100644 --- a/src/test/ui/issues/issue-69455.rs +++ b/src/test/ui/issues/issue-69455.rs @@ -27,4 +27,5 @@ impl Test<u64> for u64 { fn main() { let xs: Vec<u64> = vec![1, 2, 3]; println!("{}", 23u64.test(xs.iter().sum())); //~ ERROR: type annotations needed + //~^ ERROR type annotations needed } diff --git a/src/test/ui/issues/issue-69455.stderr b/src/test/ui/issues/issue-69455.stderr index 430bbcabf83..da84a6b52da 100644 --- a/src/test/ui/issues/issue-69455.stderr +++ b/src/test/ui/issues/issue-69455.stderr @@ -4,6 +4,26 @@ error[E0284]: type annotations needed: cannot satisfy `<u64 as Test<_>>::Output LL | println!("{}", 23u64.test(xs.iter().sum())); | ^^^^ cannot satisfy `<u64 as Test<_>>::Output == _` -error: aborting due to previous error +error[E0283]: type annotations needed + --> $DIR/issue-69455.rs:29:26 + | +LL | println!("{}", 23u64.test(xs.iter().sum())); + | ^^^^ cannot infer type for type parameter `Rhs` declared on the trait `Test` + | +note: multiple `impl`s satisfying `u64: Test<_>` found + --> $DIR/issue-69455.rs:11:1 + | +LL | impl Test<u32> for u64 { + | ^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Test<u64> for u64 { + | ^^^^^^^^^^^^^^^^^^^^^^ +help: consider specifying the type argument in the method call + | +LL | println!("{}", 23u64.test(xs.iter().sum::<S>())); + | +++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0284`. +Some errors have detailed explanations: E0283, E0284. +For more information about an error, try `rustc --explain E0283`. diff --git a/src/test/ui/issues/issue-69683.rs b/src/test/ui/issues/issue-69683.rs index cc7f1fa0f55..7a76e9ef205 100644 --- a/src/test/ui/issues/issue-69683.rs +++ b/src/test/ui/issues/issue-69683.rs @@ -28,5 +28,6 @@ fn main() { let b: [u8; 3] = [0u8; 3]; 0u16.foo(b); //~ ERROR type annotations needed + //~^ ERROR type annotations needed //<u16 as Foo<[(); 3]>>::foo(0u16, b); } diff --git a/src/test/ui/issues/issue-69683.stderr b/src/test/ui/issues/issue-69683.stderr index 776370331a4..ecf78e48e0e 100644 --- a/src/test/ui/issues/issue-69683.stderr +++ b/src/test/ui/issues/issue-69683.stderr @@ -4,6 +4,22 @@ error[E0284]: type annotations needed: cannot satisfy `<u8 as Element<_>>::Array LL | 0u16.foo(b); | ^^^ cannot satisfy `<u8 as Element<_>>::Array == [u8; 3]` -error: aborting due to previous error +error[E0283]: type annotations needed + --> $DIR/issue-69683.rs:30:10 + | +LL | 0u16.foo(b); + | ^^^ cannot infer type for type parameter `I` declared on the trait `Foo` + | +note: multiple `impl`s satisfying `u8: Element<_>` found + --> $DIR/issue-69683.rs:5:1 + | +LL | impl<T> Element<()> for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl<T: Element<S>, S> Element<[S; 3]> for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0284`. +Some errors have detailed explanations: E0283, E0284. +For more information about an error, try `rustc --explain E0283`. diff --git a/src/test/ui/issues/issue-72690.rs b/src/test/ui/issues/issue-72690.rs index 4edbd9ca15d..916a7832c68 100644 --- a/src/test/ui/issues/issue-72690.rs +++ b/src/test/ui/issues/issue-72690.rs @@ -5,10 +5,13 @@ fn no_err() { fn err() { String::from("x".as_ref()); //~ ERROR type annotations needed + //~^ ERROR type annotations needed } fn arg_pat_closure_err() { |x| String::from("x".as_ref()); //~ ERROR type annotations needed + //~^ ERROR type annotations needed + //~| ERROR type annotations needed } fn local_pat_closure_err() { @@ -17,12 +20,14 @@ fn local_pat_closure_err() { fn err_first_arg_pat() { String::from("x".as_ref()); //~ ERROR type annotations needed + //~^ ERROR type annotations needed |x: String| x; } fn err_second_arg_pat() { |x: String| x; String::from("x".as_ref()); //~ ERROR type annotations needed + //~^ ERROR type annotations needed } fn err_mid_arg_pat() { @@ -31,6 +36,7 @@ fn err_mid_arg_pat() { |x: String| x; |x: String| x; String::from("x".as_ref()); //~ ERROR type annotations needed + //~^ ERROR type annotations needed |x: String| x; |x: String| x; |x: String| x; @@ -39,12 +45,14 @@ fn err_mid_arg_pat() { fn err_first_local_pat() { String::from("x".as_ref()); //~ ERROR type annotations needed + //~^ ERROR type annotations needed let _ = String::from("x"); } fn err_second_local_pat() { let _ = String::from("x"); String::from("x".as_ref()); //~ ERROR type annotations needed + //~^ ERROR type annotations needed } fn err_mid_local_pat() { @@ -53,6 +61,7 @@ fn err_mid_local_pat() { let _ = String::from("x"); let _ = String::from("x"); String::from("x".as_ref()); //~ ERROR type annotations needed + //~^ ERROR type annotations needed let _ = String::from("x"); let _ = String::from("x"); let _ = String::from("x"); diff --git a/src/test/ui/issues/issue-72690.stderr b/src/test/ui/issues/issue-72690.stderr index af3459a7d2d..1747ca5bb04 100644 --- a/src/test/ui/issues/issue-72690.stderr +++ b/src/test/ui/issues/issue-72690.stderr @@ -4,36 +4,89 @@ error[E0283]: type annotations needed LL | String::from("x".as_ref()); | ^^^^^^^^^^^^ cannot infer type for reference `&_` | - = note: cannot satisfy `String: From<&_>` + = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: + - impl<> From<&String> for String; + - impl<> From<&str> for String; note: required by `from` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL | LL | fn from(_: T) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^ +error[E0283]: type annotations needed + --> $DIR/issue-72690.rs:7:22 + | +LL | String::from("x".as_ref()); + | ----^^^^^^-- + | | | + | | cannot infer type for type parameter `T` declared on the trait `AsRef` + | this method call resolves to `&T` + | + = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: + - impl AsRef<OsStr> for str; + - impl AsRef<Path> for str; + - impl AsRef<[u8]> for str; + - impl AsRef<str> for str; + error[E0282]: type annotations needed - --> $DIR/issue-72690.rs:11:6 + --> $DIR/issue-72690.rs:12:6 | LL | |x| String::from("x".as_ref()); | ^ consider giving this closure parameter a type +error[E0283]: type annotations needed + --> $DIR/issue-72690.rs:12:9 + | +LL | |x| String::from("x".as_ref()); + | ^^^^^^^^^^^^ cannot infer type for reference `&_` + | + = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: + - impl<> From<&String> for String; + - impl<> From<&str> for String; +note: required by `from` + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL + | +LL | fn from(_: T) -> Self; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0283]: type annotations needed + --> $DIR/issue-72690.rs:12:26 + | +LL | |x| String::from("x".as_ref()); + | ----^^^^^^-- + | | | + | | cannot infer type for type parameter `T` declared on the trait `AsRef` + | this method call resolves to `&T` + | + = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: + - impl AsRef<OsStr> for str; + - impl AsRef<Path> for str; + - impl AsRef<[u8]> for str; + - impl AsRef<str> for str; + error[E0283]: type annotations needed for `&T` - --> $DIR/issue-72690.rs:15:17 + --> $DIR/issue-72690.rs:18:17 | LL | let _ = "x".as_ref(); | - ^^^^^^ cannot infer type for type parameter `T` declared on the trait `AsRef` | | | consider giving this pattern the explicit type `&T`, where the type parameter `T` is specified | - = note: cannot satisfy `str: AsRef<_>` + = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: + - impl AsRef<OsStr> for str; + - impl AsRef<Path> for str; + - impl AsRef<[u8]> for str; + - impl AsRef<str> for str; error[E0283]: type annotations needed - --> $DIR/issue-72690.rs:19:5 + --> $DIR/issue-72690.rs:22:5 | LL | String::from("x".as_ref()); | ^^^^^^^^^^^^ cannot infer type for reference `&_` | - = note: cannot satisfy `String: From<&_>` + = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: + - impl<> From<&String> for String; + - impl<> From<&str> for String; note: required by `from` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL | @@ -41,12 +94,29 @@ LL | fn from(_: T) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^ error[E0283]: type annotations needed - --> $DIR/issue-72690.rs:25:5 + --> $DIR/issue-72690.rs:22:22 + | +LL | String::from("x".as_ref()); + | ----^^^^^^-- + | | | + | | cannot infer type for type parameter `T` declared on the trait `AsRef` + | this method call resolves to `&T` + | + = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: + - impl AsRef<OsStr> for str; + - impl AsRef<Path> for str; + - impl AsRef<[u8]> for str; + - impl AsRef<str> for str; + +error[E0283]: type annotations needed + --> $DIR/issue-72690.rs:29:5 | LL | String::from("x".as_ref()); | ^^^^^^^^^^^^ cannot infer type for reference `&_` | - = note: cannot satisfy `String: From<&_>` + = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: + - impl<> From<&String> for String; + - impl<> From<&str> for String; note: required by `from` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL | @@ -54,12 +124,29 @@ LL | fn from(_: T) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^ error[E0283]: type annotations needed - --> $DIR/issue-72690.rs:33:5 + --> $DIR/issue-72690.rs:29:22 + | +LL | String::from("x".as_ref()); + | ----^^^^^^-- + | | | + | | cannot infer type for type parameter `T` declared on the trait `AsRef` + | this method call resolves to `&T` + | + = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: + - impl AsRef<OsStr> for str; + - impl AsRef<Path> for str; + - impl AsRef<[u8]> for str; + - impl AsRef<str> for str; + +error[E0283]: type annotations needed + --> $DIR/issue-72690.rs:38:5 | LL | String::from("x".as_ref()); | ^^^^^^^^^^^^ cannot infer type for reference `&_` | - = note: cannot satisfy `String: From<&_>` + = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: + - impl<> From<&String> for String; + - impl<> From<&str> for String; note: required by `from` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL | @@ -67,12 +154,29 @@ LL | fn from(_: T) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^ error[E0283]: type annotations needed - --> $DIR/issue-72690.rs:41:5 + --> $DIR/issue-72690.rs:38:22 + | +LL | String::from("x".as_ref()); + | ----^^^^^^-- + | | | + | | cannot infer type for type parameter `T` declared on the trait `AsRef` + | this method call resolves to `&T` + | + = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: + - impl AsRef<OsStr> for str; + - impl AsRef<Path> for str; + - impl AsRef<[u8]> for str; + - impl AsRef<str> for str; + +error[E0283]: type annotations needed + --> $DIR/issue-72690.rs:47:5 | LL | String::from("x".as_ref()); | ^^^^^^^^^^^^ cannot infer type for reference `&_` | - = note: cannot satisfy `String: From<&_>` + = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: + - impl<> From<&String> for String; + - impl<> From<&str> for String; note: required by `from` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL | @@ -80,12 +184,29 @@ LL | fn from(_: T) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^ error[E0283]: type annotations needed - --> $DIR/issue-72690.rs:47:5 + --> $DIR/issue-72690.rs:47:22 + | +LL | String::from("x".as_ref()); + | ----^^^^^^-- + | | | + | | cannot infer type for type parameter `T` declared on the trait `AsRef` + | this method call resolves to `&T` + | + = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: + - impl AsRef<OsStr> for str; + - impl AsRef<Path> for str; + - impl AsRef<[u8]> for str; + - impl AsRef<str> for str; + +error[E0283]: type annotations needed + --> $DIR/issue-72690.rs:54:5 | LL | String::from("x".as_ref()); | ^^^^^^^^^^^^ cannot infer type for reference `&_` | - = note: cannot satisfy `String: From<&_>` + = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: + - impl<> From<&String> for String; + - impl<> From<&str> for String; note: required by `from` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL | @@ -93,19 +214,51 @@ LL | fn from(_: T) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^ error[E0283]: type annotations needed - --> $DIR/issue-72690.rs:55:5 + --> $DIR/issue-72690.rs:54:22 + | +LL | String::from("x".as_ref()); + | ----^^^^^^-- + | | | + | | cannot infer type for type parameter `T` declared on the trait `AsRef` + | this method call resolves to `&T` + | + = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: + - impl AsRef<OsStr> for str; + - impl AsRef<Path> for str; + - impl AsRef<[u8]> for str; + - impl AsRef<str> for str; + +error[E0283]: type annotations needed + --> $DIR/issue-72690.rs:63:5 | LL | String::from("x".as_ref()); | ^^^^^^^^^^^^ cannot infer type for reference `&_` | - = note: cannot satisfy `String: From<&_>` + = note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate: + - impl<> From<&String> for String; + - impl<> From<&str> for String; note: required by `from` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL | LL | fn from(_: T) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 9 previous errors +error[E0283]: type annotations needed + --> $DIR/issue-72690.rs:63:22 + | +LL | String::from("x".as_ref()); + | ----^^^^^^-- + | | | + | | cannot infer type for type parameter `T` declared on the trait `AsRef` + | this method call resolves to `&T` + | + = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: + - impl AsRef<OsStr> for str; + - impl AsRef<Path> for str; + - impl AsRef<[u8]> for str; + - impl AsRef<str> for str; + +error: aborting due to 18 previous errors Some errors have detailed explanations: E0282, E0283. For more information about an error, try `rustc --explain E0282`. |
