diff options
| author | bors <bors@rust-lang.org> | 2022-06-03 12:37:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-03 12:37:16 +0000 |
| commit | e40d5e83dc133d093c22c7ff016b10daa4f40dcf (patch) | |
| tree | dc2a28093b19836d6f14e25763b33904e9d12186 /src/test/ui/issues | |
| parent | 72f7e3144a386c820c188350092d2d93a74889b8 (diff) | |
| parent | b343a466c650cd43d81b7fc98d3571eda64fe35b (diff) | |
Auto merge of #89862 - lcnr:path-generics-diagnostics, r=estebank
rewrite error handling for unresolved inference vars Pretty much completely rewrites `fn emit_inference_failure_err`. This new setup should hopefully be easier to extend and is already a lot better when looking for generic arguments. Because this is a rewrite there are still some parts which are lacking, these are tracked in #94483 and will be fixed in later PRs. r? `@estebank` `@petrochenkov`
Diffstat (limited to 'src/test/ui/issues')
24 files changed, 170 insertions, 105 deletions
diff --git a/src/test/ui/issues/issue-12187-1.stderr b/src/test/ui/issues/issue-12187-1.stderr index 3ea15439df2..806b7f0ac05 100644 --- a/src/test/ui/issues/issue-12187-1.stderr +++ b/src/test/ui/issues/issue-12187-1.stderr @@ -1,11 +1,13 @@ error[E0282]: type annotations needed for `&T` - --> $DIR/issue-12187-1.rs:6:10 + --> $DIR/issue-12187-1.rs:6:9 | LL | let &v = new(); - | -^ - | || - | |cannot infer type - | consider giving this pattern the explicit type `&T`, with the type parameters specified + | ^^ + | +help: consider giving this pattern a type, where the placeholders `_` are specified + | +LL | let &v: &T = new(); + | ++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-12187-2.stderr b/src/test/ui/issues/issue-12187-2.stderr index a5e65c65beb..a1fa0a2b002 100644 --- a/src/test/ui/issues/issue-12187-2.stderr +++ b/src/test/ui/issues/issue-12187-2.stderr @@ -1,11 +1,13 @@ error[E0282]: type annotations needed for `&T` - --> $DIR/issue-12187-2.rs:6:10 + --> $DIR/issue-12187-2.rs:6:9 | LL | let &v = new(); - | -^ - | || - | |cannot infer type - | consider giving this pattern the explicit type `&T`, with the type parameters specified + | ^^ + | +help: consider giving this pattern a type, where the placeholders `_` are specified + | +LL | let &v: &T = new(); + | ++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-16966.stderr b/src/test/ui/issues/issue-16966.stderr index 09e20c0c777..6eb56ca5516 100644 --- a/src/test/ui/issues/issue-16966.stderr +++ b/src/test/ui/issues/issue-16966.stderr @@ -2,9 +2,14 @@ error[E0282]: type annotations needed --> $DIR/issue-16966.rs:2:5 | LL | panic!(std::default::Default::default()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `M` declared on the function `begin_panic` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `M` declared on the function `begin_panic` | = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider specifying the generic argument + --> $SRC_DIR/std/src/panic.rs:LL:COL + | +LL | $crate::rt::begin_panic::<M>($msg) + | +++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-17551.stderr b/src/test/ui/issues/issue-17551.stderr index 48405a292f3..5f45a2f8443 100644 --- a/src/test/ui/issues/issue-17551.stderr +++ b/src/test/ui/issues/issue-17551.stderr @@ -1,10 +1,13 @@ error[E0282]: type annotations needed for `B<T>` - --> $DIR/issue-17551.rs:6:15 + --> $DIR/issue-17551.rs:6:9 | LL | let foo = B(marker::PhantomData); - | --- ^ cannot infer type for type parameter `T` declared on the struct `B` - | | - | consider giving `foo` the explicit type `B<T>`, where the type parameter `T` is specified + | ^^^ + | +help: consider giving `foo` an explicit type, where the type for type parameter `T` is specified + | +LL | let foo: B<T> = B(marker::PhantomData); + | ++++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18159.stderr b/src/test/ui/issues/issue-18159.stderr index 9b890be3c78..605ff3829d1 100644 --- a/src/test/ui/issues/issue-18159.stderr +++ b/src/test/ui/issues/issue-18159.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/issue-18159.rs:2:9 | LL | let x; - | ^ consider giving `x` a type + | ^ + | +help: consider giving `x` an explicit type + | +LL | let x: _; + | +++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20261.stderr b/src/test/ui/issues/issue-20261.stderr index 6330364c92b..73468c7ca16 100644 --- a/src/test/ui/issues/issue-20261.stderr +++ b/src/test/ui/issues/issue-20261.stderr @@ -1,8 +1,6 @@ -error[E0282]: type annotations needed for `(_,)` +error[E0282]: type annotations needed --> $DIR/issue-20261.rs:4:11 | -LL | for (ref i,) in [].iter() { - | --------- this method call resolves to `std::slice::Iter<'_, T>` LL | i.clone(); | ^^^^^ cannot infer type | diff --git a/src/test/ui/issues/issue-2151.rs b/src/test/ui/issues/issue-2151.rs index 32fba4cb217..82cf49de822 100644 --- a/src/test/ui/issues/issue-2151.rs +++ b/src/test/ui/issues/issue-2151.rs @@ -1,4 +1,4 @@ fn main() { - let x = panic!(); - x.clone(); //~ ERROR type annotations needed + let x = panic!(); //~ ERROR type annotations needed + x.clone(); } diff --git a/src/test/ui/issues/issue-2151.stderr b/src/test/ui/issues/issue-2151.stderr index a2bcc8a8cea..e0d946205ad 100644 --- a/src/test/ui/issues/issue-2151.stderr +++ b/src/test/ui/issues/issue-2151.stderr @@ -1,12 +1,14 @@ error[E0282]: type annotations needed - --> $DIR/issue-2151.rs:3:5 + --> $DIR/issue-2151.rs:2:9 | LL | let x = panic!(); - | - consider giving `x` a type -LL | x.clone(); - | ^ cannot infer type + | ^ | = note: type must be known at this point +help: consider giving `x` an explicit type + | +LL | let x: _ = panic!(); + | +++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23046.stderr b/src/test/ui/issues/issue-23046.stderr index 12b2eb48e7e..1403ecbd92d 100644 --- a/src/test/ui/issues/issue-23046.stderr +++ b/src/test/ui/issues/issue-23046.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed for `Expr<'_, VAR>` --> $DIR/issue-23046.rs:17:15 | LL | let ex = |x| { - | ^ consider giving this closure parameter the explicit type `Expr<'_, VAR>`, where the type parameter `VAR` is specified + | ^ + | +help: consider giving this closure parameter an explicit type, where the type for type parameter `VAR` is specified + | +LL | let ex = |x: Expr<'_, VAR>| { + | +++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-24036.stderr b/src/test/ui/issues/issue-24036.stderr index e6b8367f74f..4622501f33e 100644 --- a/src/test/ui/issues/issue-24036.stderr +++ b/src/test/ui/issues/issue-24036.stderr @@ -15,7 +15,12 @@ error[E0282]: type annotations needed --> $DIR/issue-24036.rs:9:15 | LL | 1 => |c| c + 1, - | ^ consider giving this closure parameter a type + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | 1 => |c: _| c + 1, + | +++ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-25368.rs b/src/test/ui/issues/issue-25368.rs index 8b4dbb6e460..b7f0f613e80 100644 --- a/src/test/ui/issues/issue-25368.rs +++ b/src/test/ui/issues/issue-25368.rs @@ -5,9 +5,10 @@ use std::marker::PhantomData; struct Foo<T> {foo: PhantomData<T>} fn main() { - let (tx, rx) = channel(); - + let (tx, rx) = //~ ERROR type annotations needed + channel(); + // FIXME(#89862): Suggest adding a generic argument to `channel` instead spawn(move || { - tx.send(Foo{ foo: PhantomData }); //~ ERROR E0282 + tx.send(Foo{ foo: PhantomData }); }); } diff --git a/src/test/ui/issues/issue-25368.stderr b/src/test/ui/issues/issue-25368.stderr index 6a970bc0494..ffcb7384952 100644 --- a/src/test/ui/issues/issue-25368.stderr +++ b/src/test/ui/issues/issue-25368.stderr @@ -1,11 +1,13 @@ error[E0282]: type annotations needed for `(Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)` - --> $DIR/issue-25368.rs:11:17 + --> $DIR/issue-25368.rs:8:9 | -LL | let (tx, rx) = channel(); - | -------- consider giving this pattern the explicit type `(Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>)`, where the type parameter `T` is specified -... -LL | tx.send(Foo{ foo: PhantomData }); - | ^^^ cannot infer type for type parameter `T` declared on the struct `Foo` +LL | let (tx, rx) = + | ^^^^^^^^ + | +help: consider giving this pattern a type, where the type for type parameter `T` is specified + | +LL | let (tx, rx): (Sender<Foo<T>>, std::sync::mpsc::Receiver<Foo<T>>) = + | +++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-47486.stderr b/src/test/ui/issues/issue-47486.stderr index a029948ca3b..ca57b2d7e01 100644 --- a/src/test/ui/issues/issue-47486.stderr +++ b/src/test/ui/issues/issue-47486.stderr @@ -1,8 +1,13 @@ error[E0282]: type annotations needed - --> $DIR/issue-47486.rs:3:31 + --> $DIR/issue-47486.rs:3:11 | LL | [0u8; std::mem::size_of::<_>()]; - | ^ cannot infer type + | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `size_of` + | +help: consider specifying the generic argument + | +LL | [0u8; std::mem::size_of::<_>()]; + | ~~~~~ error[E0308]: mismatched types --> $DIR/issue-47486.rs:2:10 diff --git a/src/test/ui/issues/issue-5062.stderr b/src/test/ui/issues/issue-5062.stderr index 9fa15dc9679..3191bd3de32 100644 --- a/src/test/ui/issues/issue-5062.stderr +++ b/src/test/ui/issues/issue-5062.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/issue-5062.rs:1:29 | LL | fn main() { format!("{:?}", None); } - | ^^^^ cannot infer type for type parameter `T` declared on the enum `Option` + | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` + | +help: consider specifying the generic argument + | +LL | fn main() { format!("{:?}", None::<T>); } + | +++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-51116.rs b/src/test/ui/issues/issue-51116.rs index c0a74a679ef..c979c7b2cdd 100644 --- a/src/test/ui/issues/issue-51116.rs +++ b/src/test/ui/issues/issue-51116.rs @@ -2,7 +2,6 @@ fn main() { let tiles = Default::default(); for row in &mut tiles { for tile in row { - //~^ NOTE the element type for this iterator is not specified *tile = 0; //~^ ERROR type annotations needed //~| NOTE cannot infer type diff --git a/src/test/ui/issues/issue-51116.stderr b/src/test/ui/issues/issue-51116.stderr index 8501ae6a1d0..399b421ab16 100644 --- a/src/test/ui/issues/issue-51116.stderr +++ b/src/test/ui/issues/issue-51116.stderr @@ -1,9 +1,6 @@ error[E0282]: type annotations needed - --> $DIR/issue-51116.rs:6:13 + --> $DIR/issue-51116.rs:5:13 | -LL | for tile in row { - | --- the element type for this iterator is not specified -LL | LL | *tile = 0; | ^^^^^ cannot infer type | diff --git a/src/test/ui/issues/issue-6458-2.stderr b/src/test/ui/issues/issue-6458-2.stderr index da16f95dc3d..8dbdd9a2735 100644 --- a/src/test/ui/issues/issue-6458-2.stderr +++ b/src/test/ui/issues/issue-6458-2.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/issue-6458-2.rs:3:21 | LL | format!("{:?}", None); - | ^^^^ cannot infer type for type parameter `T` declared on the enum `Option` + | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` + | +help: consider specifying the generic argument + | +LL | format!("{:?}", None::<T>); + | +++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-6458-3.stderr b/src/test/ui/issues/issue-6458-3.stderr index a71c159db0b..2c3ec1a331f 100644 --- a/src/test/ui/issues/issue-6458-3.stderr +++ b/src/test/ui/issues/issue-6458-3.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/issue-6458-3.rs:4:5 | LL | mem::transmute(0); - | ^^^^^^^^^^^^^^ cannot infer type for type parameter `U` declared on the function `transmute` + | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `transmute` + | +help: consider specifying the generic arguments + | +LL | mem::transmute::<i32, U>(0); + | ++++++++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-6458.stderr b/src/test/ui/issues/issue-6458.stderr index f548692d785..2e93c13855f 100644 --- a/src/test/ui/issues/issue-6458.stderr +++ b/src/test/ui/issues/issue-6458.stderr @@ -1,14 +1,13 @@ error[E0282]: type annotations needed - --> $DIR/issue-6458.rs:9:4 + --> $DIR/issue-6458.rs:9:22 | LL | foo(TypeWithState(marker::PhantomData)); - | ^^^ cannot infer type for type parameter `State` declared on the function `foo` + | ^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `PhantomData` | -help: type parameter declared here - --> $DIR/issue-6458.rs:6:12 +help: consider specifying the generic argument | -LL | pub fn foo<State>(_: TypeWithState<State>) {} - | ^^^^^ +LL | foo(TypeWithState(marker::PhantomData::<T>)); + | +++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-66706.stderr b/src/test/ui/issues/issue-66706.stderr index e8cb18f5c1e..1c55560cb7c 100644 --- a/src/test/ui/issues/issue-66706.stderr +++ b/src/test/ui/issues/issue-66706.stderr @@ -30,7 +30,7 @@ error[E0282]: type annotations needed --> $DIR/issue-66706.rs:2:11 | LL | [0; [|_: _ &_| ()].len()] - | ^ consider giving this closure parameter a type + | ^ cannot infer type error[E0308]: mismatched types --> $DIR/issue-66706.rs:2:5 diff --git a/src/test/ui/issues/issue-69455.stderr b/src/test/ui/issues/issue-69455.stderr index 378fdc97dd3..6c4eafbc8b3 100644 --- a/src/test/ui/issues/issue-69455.stderr +++ b/src/test/ui/issues/issue-69455.stderr @@ -1,22 +1,20 @@ error[E0282]: type annotations needed --> $DIR/issue-69455.rs:29:20 | -LL | type Output; - | ------------ `<Self as Test<Rhs>>::Output` defined here -... LL | println!("{}", 23u64.test(xs.iter().sum())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | this method call resolves to `<Self as Test<Rhs>>::Output` - | cannot infer type for type parameter `T` declared on the associated function `new_display` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the associated function `new_display` | = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider specifying the generic argument + | +LL | println!("{}", 23u64.test(xs.iter().sum())::<T>); + | +++++ error[E0283]: type annotations needed - --> $DIR/issue-69455.rs:29:26 + --> $DIR/issue-69455.rs:29:41 | LL | println!("{}", 23u64.test(xs.iter().sum())); - | ^^^^ cannot infer type for type parameter `Rhs` declared on the trait `Test` + | ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum` | note: multiple `impl`s satisfying `u64: Test<_>` found --> $DIR/issue-69455.rs:11:1 @@ -26,7 +24,7 @@ LL | impl Test<u32> for u64 { ... LL | impl Test<u64> for u64 { | ^^^^^^^^^^^^^^^^^^^^^^ -help: consider specifying the type argument in the method call +help: consider specifying the generic argument | LL | println!("{}", 23u64.test(xs.iter().sum::<S>())); | +++++ diff --git a/src/test/ui/issues/issue-69683.stderr b/src/test/ui/issues/issue-69683.stderr index b53923eec1d..9c71ecffa26 100644 --- a/src/test/ui/issues/issue-69683.stderr +++ b/src/test/ui/issues/issue-69683.stderr @@ -8,7 +8,7 @@ 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 @@ -26,6 +26,10 @@ LL | u8: Element<I>, LL | { LL | fn foo(self, x: <u8 as Element<I>>::Array); | --- required by a bound in this +help: try using a fully qualified path to specify the expected types + | +LL | <u16 as Foo<I>>::foo(0u16, b); + | +++++++++++++++++++++ ~ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-72690.stderr b/src/test/ui/issues/issue-72690.stderr index f1ec678b201..9edf14ef291 100644 --- a/src/test/ui/issues/issue-72690.stderr +++ b/src/test/ui/issues/issue-72690.stderr @@ -12,51 +12,60 @@ 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; +help: try using a fully qualified path to specify the expected types + | +LL | String::from(<str as AsRef<T>>::as_ref("x")); + | ++++++++++++++++++++++++++ ~ error[E0282]: type annotations needed --> $DIR/issue-72690.rs:12:6 | LL | |x| String::from("x".as_ref()); - | ^ consider giving this closure parameter a type + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | |x: _| String::from("x".as_ref()); + | +++ 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; +help: try using a fully qualified path to specify the expected types + | +LL | |x| String::from(<str as AsRef<T>>::as_ref("x")); + | ++++++++++++++++++++++++++ ~ error[E0283]: type annotations needed for `&T` - --> $DIR/issue-72690.rs:17:17 + --> $DIR/issue-72690.rs:17:9 | 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: 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; +help: consider giving this pattern a type, where the type for type parameter `T` is specified + | +LL | let _: &T = "x".as_ref(); + | ++++ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:21:5 @@ -72,16 +81,17 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:21: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; +help: try using a fully qualified path to specify the expected types + | +LL | String::from(<str as AsRef<T>>::as_ref("x")); + | ++++++++++++++++++++++++++ ~ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:28:5 @@ -97,16 +107,17 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:28: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; +help: try using a fully qualified path to specify the expected types + | +LL | String::from(<str as AsRef<T>>::as_ref("x")); + | ++++++++++++++++++++++++++ ~ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:37:5 @@ -122,16 +133,17 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:37: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; +help: try using a fully qualified path to specify the expected types + | +LL | String::from(<str as AsRef<T>>::as_ref("x")); + | ++++++++++++++++++++++++++ ~ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:46:5 @@ -147,16 +159,17 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:46: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; +help: try using a fully qualified path to specify the expected types + | +LL | String::from(<str as AsRef<T>>::as_ref("x")); + | ++++++++++++++++++++++++++ ~ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:53:5 @@ -172,16 +185,17 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:53: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; +help: try using a fully qualified path to specify the expected types + | +LL | String::from(<str as AsRef<T>>::as_ref("x")); + | ++++++++++++++++++++++++++ ~ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:62:5 @@ -197,16 +211,17 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:62: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; +help: try using a fully qualified path to specify the expected types + | +LL | String::from(<str as AsRef<T>>::as_ref("x")); + | ++++++++++++++++++++++++++ ~ error: aborting due to 17 previous errors diff --git a/src/test/ui/issues/issue-7813.stderr b/src/test/ui/issues/issue-7813.stderr index 59be0f3be11..3aee61bd5a5 100644 --- a/src/test/ui/issues/issue-7813.stderr +++ b/src/test/ui/issues/issue-7813.stderr @@ -1,10 +1,13 @@ error[E0282]: type annotations needed for `&[_; 0]` - --> $DIR/issue-7813.rs:2:13 + --> $DIR/issue-7813.rs:2:9 | LL | let v = &[]; - | - ^^^ cannot infer type - | | - | consider giving `v` the explicit type `&[_; 0]`, with the type parameters specified + | ^ + | +help: consider giving `v` an explicit type, where the placeholders `_` are specified + | +LL | let v: &[_; 0] = &[]; + | +++++++++ error: aborting due to previous error |
