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 | |
| parent | 72f7e3144a386c820c188350092d2d93a74889b8 (diff) | |
| parent | b343a466c650cd43d81b7fc98d3571eda64fe35b (diff) | |
| download | rust-e40d5e83dc133d093c22c7ff016b10daa4f40dcf.tar.gz rust-e40d5e83dc133d093c22c7ff016b10daa4f40dcf.zip | |
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')
120 files changed, 1268 insertions, 594 deletions
diff --git a/src/test/ui/array-slice-vec/infer_array_len.stderr b/src/test/ui/array-slice-vec/infer_array_len.stderr index 6eed4ce4f0c..8da6d97251b 100644 --- a/src/test/ui/array-slice-vec/infer_array_len.stderr +++ b/src/test/ui/array-slice-vec/infer_array_len.stderr @@ -2,9 +2,13 @@ error[E0282]: type annotations needed --> $DIR/infer_array_len.rs:19:9 | LL | let [_, _] = a.into(); - | ^^^^^^ consider giving this pattern a type + | ^^^^^^ | = note: type must be known at this point +help: consider giving this pattern a type + | +LL | let [_, _]: _ = a.into(); + | +++ error: aborting due to previous error diff --git a/src/test/ui/array-slice-vec/vector-no-ann.stderr b/src/test/ui/array-slice-vec/vector-no-ann.stderr index 8a7b8d22760..d2ea08aa474 100644 --- a/src/test/ui/array-slice-vec/vector-no-ann.stderr +++ b/src/test/ui/array-slice-vec/vector-no-ann.stderr @@ -1,10 +1,13 @@ error[E0282]: type annotations needed for `Vec<T>` - --> $DIR/vector-no-ann.rs:2:16 + --> $DIR/vector-no-ann.rs:2:9 | LL | let _foo = Vec::new(); - | ---- ^^^^^^^^ cannot infer type for type parameter `T` - | | - | consider giving `_foo` the explicit type `Vec<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: Vec<T> = Vec::new(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr b/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr index 2005bd4dd5c..db7586bee49 100644 --- a/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr +++ b/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/expect-two-infer-vars-supply-ty-with-bound-region.rs:8:27 | LL | with_closure(|x: u32, y| {}); - | ^ consider giving this closure parameter a type + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | with_closure(|x: u32, y: B| {}); + | +++ error: aborting due to previous error diff --git a/src/test/ui/closures/issue-52437.stderr b/src/test/ui/closures/issue-52437.stderr index 54825cb746d..38d9d08ce36 100644 --- a/src/test/ui/closures/issue-52437.stderr +++ b/src/test/ui/closures/issue-52437.stderr @@ -8,7 +8,12 @@ error[E0282]: type annotations needed --> $DIR/issue-52437.rs:2:30 | LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] - | ^ consider giving this closure parameter a type + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | [(); &(&'static: loop { |x: _| {}; }) as *const _ as usize] + | +++ error[E0308]: mismatched types --> $DIR/issue-52437.rs:2:5 diff --git a/src/test/ui/const-generics/defaults/doesnt_infer.stderr b/src/test/ui/const-generics/defaults/doesnt_infer.stderr index cccf433e328..227b2f40223 100644 --- a/src/test/ui/const-generics/defaults/doesnt_infer.stderr +++ b/src/test/ui/const-generics/defaults/doesnt_infer.stderr @@ -1,10 +1,13 @@ error[E0282]: type annotations needed for `Foo<N>` - --> $DIR/doesnt_infer.rs:11:15 + --> $DIR/doesnt_infer.rs:11:9 | LL | let foo = Foo::foo(); - | --- ^^^^^^^^ cannot infer the value of const parameter `N` - | | - | consider giving `foo` the explicit type `Foo<N>`, where the const parameter `N` is specified + | ^^^ + | +help: consider giving `foo` an explicit type, where the the value of const parameter `N` is specified + | +LL | let foo: Foo<N> = Foo::foo(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr b/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr index 347cd2364b2..463605e2431 100644 --- a/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr +++ b/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr @@ -1,10 +1,8 @@ error[E0283]: type annotations needed for `Mask<_, LANES>` - --> $DIR/issue-91614.rs:6:13 + --> $DIR/issue-91614.rs:6:9 | LL | let y = Mask::<_, _>::splat(false); - | - ^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` - | | - | consider giving `y` the explicit type `Mask<_, LANES>`, where the type parameter `T` is specified + | ^ | = note: cannot satisfy `_: MaskElement` note: required by a bound in `Mask::<T, LANES>::splat` @@ -12,6 +10,10 @@ note: required by a bound in `Mask::<T, LANES>::splat` | LL | T: MaskElement, | ^^^^^^^^^^^ required by this bound in `Mask::<T, LANES>::splat` +help: consider giving `y` an explicit type, where the type for type parameter `T` is specified + | +LL | let y: Mask<_, LANES> = Mask::<_, _>::splat(false); + | ++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/const-generics/generic_const_exprs/const_eval_resolve_canonical.stderr b/src/test/ui/const-generics/generic_const_exprs/const_eval_resolve_canonical.stderr index e59f1ac8027..9e8328d3701 100644 --- a/src/test/ui/const-generics/generic_const_exprs/const_eval_resolve_canonical.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/const_eval_resolve_canonical.stderr @@ -2,13 +2,18 @@ error[E0282]: type annotations needed --> $DIR/const_eval_resolve_canonical.rs:26:9 | LL | let mut _q = Default::default(); - | ^^^^^^ consider giving `_q` a type + | ^^^^^^ + | +help: consider giving `_q` an explicit type + | +LL | let mut _q: _ = Default::default(); + | +++ error[E0283]: type annotations needed --> $DIR/const_eval_resolve_canonical.rs:29:10 | LL | _q = foo::<_, 2>(_q); - | ^^^^^^^^^^^ cannot infer type + | ^^^^^^^^^^^ cannot infer the value of the constant `{ N + 1 }` | note: multiple `impl`s satisfying `(): Foo<{ N + 1 }>` found --> $DIR/const_eval_resolve_canonical.rs:8:1 diff --git a/src/test/ui/const-generics/infer/cannot-infer-const-args.stderr b/src/test/ui/const-generics/infer/cannot-infer-const-args.stderr index 828f4972403..93e45a88a6c 100644 --- a/src/test/ui/const-generics/infer/cannot-infer-const-args.stderr +++ b/src/test/ui/const-generics/infer/cannot-infer-const-args.stderr @@ -2,12 +2,12 @@ error[E0282]: type annotations needed --> $DIR/cannot-infer-const-args.rs:6:5 | LL | foo(); - | ^^^ cannot infer the value of const parameter `X` declared on the function `foo` + | ^^^ cannot infer the value of the const parameter `X` declared on the function `foo` | -help: consider specifying the const argument +help: consider specifying the generic argument | LL | foo::<X>(); - | ~~~~~~~~ + | +++++ error: aborting due to previous error diff --git a/src/test/ui/const-generics/infer/issue-77092.stderr b/src/test/ui/const-generics/infer/issue-77092.stderr index a625ed2bdc3..1682b26ac87 100644 --- a/src/test/ui/const-generics/infer/issue-77092.stderr +++ b/src/test/ui/const-generics/infer/issue-77092.stderr @@ -2,12 +2,12 @@ error[E0282]: type annotations needed --> $DIR/issue-77092.rs:11:26 | LL | println!("{:?}", take_array_from_mut(&mut arr, i)); - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `take_array_from_mut` + | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `take_array_from_mut` | -help: consider specifying the const argument +help: consider specifying the generic arguments | -LL | println!("{:?}", take_array_from_mut::<N>(&mut arr, i)); - | ~~~~~~~~~~~~~~~~~~~~~~~~ +LL | println!("{:?}", take_array_from_mut::<i32, N>(&mut arr, i)); + | ++++++++++ error: aborting due to previous error diff --git a/src/test/ui/const-generics/infer/method-chain.stderr b/src/test/ui/const-generics/infer/method-chain.stderr index 53d92e5ae72..ff6da535bd2 100644 --- a/src/test/ui/const-generics/infer/method-chain.stderr +++ b/src/test/ui/const-generics/infer/method-chain.stderr @@ -2,12 +2,12 @@ error[E0282]: type annotations needed --> $DIR/method-chain.rs:15:33 | LL | Foo.bar().bar().bar().bar().baz(); - | ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz` + | ^^^ cannot infer the value of the const parameter `N` declared on the associated function `baz` | -help: consider specifying the const argument +help: consider specifying the generic argument | LL | Foo.bar().bar().bar().bar().baz::<N>(); - | ~~~~~~~~ + | +++++ error: aborting due to previous error diff --git a/src/test/ui/const-generics/infer/one-param-uninferred.stderr b/src/test/ui/const-generics/infer/one-param-uninferred.stderr index acf59170c36..98ea8df8252 100644 --- a/src/test/ui/const-generics/infer/one-param-uninferred.stderr +++ b/src/test/ui/const-generics/infer/one-param-uninferred.stderr @@ -2,12 +2,12 @@ error[E0282]: type annotations needed --> $DIR/one-param-uninferred.rs:9:23 | LL | let _: [u8; 17] = foo(); - | ^^^ cannot infer the value of const parameter `M` declared on the function `foo` + | ^^^ cannot infer the value of the const parameter `M` declared on the function `foo` | -help: consider specifying the const argument +help: consider specifying the generic arguments | -LL | let _: [u8; 17] = foo::<M>(); - | ~~~~~~~~ +LL | let _: [u8; 17] = foo::<17_usize, M>(); + | +++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/const-generics/infer/uninferred-consts.stderr b/src/test/ui/const-generics/infer/uninferred-consts.stderr index a6c79fc058a..3980ecea863 100644 --- a/src/test/ui/const-generics/infer/uninferred-consts.stderr +++ b/src/test/ui/const-generics/infer/uninferred-consts.stderr @@ -2,12 +2,12 @@ error[E0282]: type annotations needed --> $DIR/uninferred-consts.rs:9:9 | LL | Foo.foo(); - | ^^^ cannot infer the value of const parameter `A` declared on the associated function `foo` + | ^^^ cannot infer the value of the const parameter `A` declared on the associated function `foo` | -help: consider specifying the const argument +help: consider specifying the generic arguments | -LL | Foo.foo::<A>(); - | ~~~~~~~~ +LL | Foo.foo::<A, B>(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-83249.stderr b/src/test/ui/const-generics/issues/issue-83249.stderr index 3f44a54e80a..362b8554b2f 100644 --- a/src/test/ui/const-generics/issues/issue-83249.stderr +++ b/src/test/ui/const-generics/issues/issue-83249.stderr @@ -1,16 +1,13 @@ error[E0282]: type annotations needed - --> $DIR/issue-83249.rs:19:13 + --> $DIR/issue-83249.rs:19:9 | LL | let _ = foo([0; 1]); - | - ^^^ cannot infer type for type parameter `T` declared on the function `foo` - | | - | consider giving this pattern a type + | ^ | -help: type parameter declared here - --> $DIR/issue-83249.rs:12:8 +help: consider giving this pattern a type | -LL | fn foo<T: Foo>(_: [u8; T::N]) -> T { - | ^ +LL | let _: _ = foo([0; 1]); + | +++ error: aborting due to previous error diff --git a/src/test/ui/consts/issue-64662.stderr b/src/test/ui/consts/issue-64662.stderr index caa582d87f5..21a419711a9 100644 --- a/src/test/ui/consts/issue-64662.stderr +++ b/src/test/ui/consts/issue-64662.stderr @@ -2,25 +2,23 @@ error[E0282]: type annotations needed --> $DIR/issue-64662.rs:2:9 | LL | A = foo(), - | ^^^ cannot infer type for type parameter `T` declared on the function `foo` + | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | -help: type parameter declared here - --> $DIR/issue-64662.rs:6:14 +help: consider specifying the generic argument | -LL | const fn foo<T>() -> isize { - | ^ +LL | A = foo::<T>(), + | +++++ error[E0282]: type annotations needed --> $DIR/issue-64662.rs:3:9 | LL | B = foo(), - | ^^^ cannot infer type for type parameter `T` declared on the function `foo` + | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | -help: type parameter declared here - --> $DIR/issue-64662.rs:6:14 +help: consider specifying the generic argument | -LL | const fn foo<T>() -> isize { - | ^ +LL | B = foo::<T>(), + | +++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0282.stderr b/src/test/ui/error-codes/E0282.stderr index 0f610a5e42f..d01aa3617c7 100644 --- a/src/test/ui/error-codes/E0282.stderr +++ b/src/test/ui/error-codes/E0282.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/E0282.rs:2:9 | LL | let x = "hello".chars().rev().collect(); - | ^ consider giving `x` a type + | ^ + | +help: consider giving `x` an explicit type + | +LL | let x: _ = "hello".chars().rev().collect(); + | +++ error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0283.stderr b/src/test/ui/error-codes/E0283.stderr index e2bab486064..a107160d11a 100644 --- a/src/test/ui/error-codes/E0283.stderr +++ b/src/test/ui/error-codes/E0283.stderr @@ -10,10 +10,7 @@ error[E0283]: type annotations needed --> $DIR/E0283.rs:35:24 | LL | let bar = foo_impl.into() * 1u32; - | ---------^^^^-- - | | | - | | cannot infer type for type parameter `T` declared on the trait `Into` - | this method call resolves to `T` + | ^^^^ | note: multiple `impl`s satisfying `Impl: Into<_>` found --> $DIR/E0283.rs:17:1 @@ -23,10 +20,10 @@ LL | impl Into<u32> for Impl { = note: and another `impl` found in the `core` crate: - impl<T, U> Into<U> for T where U: From<T>; -help: use the fully qualified path for the potential candidate +help: try using a fully qualified path to specify the expected types | -LL | let bar = <Impl as Into<u32>>::into(foo_impl) * 1u32; - | ++++++++++++++++++++++++++ ~ +LL | let bar = <Impl as Into<T>>::into(foo_impl) * 1u32; + | ++++++++++++++++++++++++ ~ error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0401.stderr b/src/test/ui/error-codes/E0401.stderr index e58c9d3116a..81715621dd9 100644 --- a/src/test/ui/error-codes/E0401.stderr +++ b/src/test/ui/error-codes/E0401.stderr @@ -36,13 +36,12 @@ error[E0282]: type annotations needed --> $DIR/E0401.rs:11:5 | LL | bfnr(x); - | ^^^^ cannot infer type for type parameter `U` declared on the function `bfnr` + | ^^^^ cannot infer type of the type parameter `U` declared on the function `bfnr` | -help: type parameter declared here - --> $DIR/E0401.rs:4:13 +help: consider specifying the generic arguments | -LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { - | ^ +LL | bfnr::<U, V, W>(x); + | +++++++++++ error: aborting due to 4 previous errors diff --git a/src/test/ui/for/for-loop-unconstrained-element-type.stderr b/src/test/ui/for/for-loop-unconstrained-element-type.stderr index 580b135ac2d..b1b38f6b919 100644 --- a/src/test/ui/for/for-loop-unconstrained-element-type.stderr +++ b/src/test/ui/for/for-loop-unconstrained-element-type.stderr @@ -1,10 +1,13 @@ error[E0282]: type annotations needed - --> $DIR/for-loop-unconstrained-element-type.rs:8:9 + --> $DIR/for-loop-unconstrained-element-type.rs:8:14 | LL | for i in Vec::new() { } - | ^ ---------- the element type for this iterator is not specified - | | - | cannot infer type + | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec` + | +help: consider specifying the generic argument + | +LL | for i in Vec::<T>::new() { } + | +++++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-91762.stderr b/src/test/ui/generic-associated-types/issue-91762.stderr index a9c465cdd7e..c2785fee387 100644 --- a/src/test/ui/generic-associated-types/issue-91762.stderr +++ b/src/test/ui/generic-associated-types/issue-91762.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/issue-91762.rs:25:15 | LL | ret = <Self::Base as Functor>::fmap(arg); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the associated function `fmap` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the associated function `fmap` + | +help: consider specifying the generic arguments + | +LL | ret = <Self::Base as Functor>::fmap::<T, U>(arg); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/impl-trait/cross-return-site-inference.rs b/src/test/ui/impl-trait/cross-return-site-inference.rs index a7428f9bf12..d881af9ed8f 100644 --- a/src/test/ui/impl-trait/cross-return-site-inference.rs +++ b/src/test/ui/impl-trait/cross-return-site-inference.rs @@ -29,17 +29,17 @@ fn baa(b: bool) -> impl std::fmt::Debug { } fn muh() -> Result<(), impl std::fmt::Debug> { - Err("whoops")?; //~^ ERROR type annotations needed - Ok(()) + Err("whoops")?; + Ok(()) //~ ERROR type annotations needed } fn muh2() -> Result<(), impl std::fmt::Debug> { - return Err(From::from("foo")); //~^ ERROR type annotations needed + return Err(From::from("foo")); //~ ERROR type annotations needed Ok(()) } fn muh3() -> Result<(), impl std::fmt::Debug> { - Err(From::from("foo")) //~^ ERROR type annotations needed + Err(From::from("foo")) //~ ERROR type annotations needed } fn main() {} diff --git a/src/test/ui/impl-trait/cross-return-site-inference.stderr b/src/test/ui/impl-trait/cross-return-site-inference.stderr index 5209d7a5743..1ff777e6503 100644 --- a/src/test/ui/impl-trait/cross-return-site-inference.stderr +++ b/src/test/ui/impl-trait/cross-return-site-inference.stderr @@ -1,20 +1,35 @@ error[E0282]: type annotations needed - --> $DIR/cross-return-site-inference.rs:31:24 + --> $DIR/cross-return-site-inference.rs:33:5 | -LL | fn muh() -> Result<(), impl std::fmt::Debug> { - | ^^^^^^^^^^^^^^^^^^^^ cannot infer type +LL | Ok(()) + | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` + | +help: consider specifying the generic arguments + | +LL | Ok::<(), E>(()) + | +++++++++ error[E0282]: type annotations needed - --> $DIR/cross-return-site-inference.rs:36:25 + --> $DIR/cross-return-site-inference.rs:37:12 + | +LL | return Err(From::from("foo")); + | ^^^ cannot infer type of the type parameter `E` declared on the enum `Result` | -LL | fn muh2() -> Result<(), impl std::fmt::Debug> { - | ^^^^^^^^^^^^^^^^^^^^ cannot infer type +help: consider specifying the generic arguments + | +LL | return Err::<(), E>(From::from("foo")); + | +++++++++ error[E0282]: type annotations needed - --> $DIR/cross-return-site-inference.rs:41:25 + --> $DIR/cross-return-site-inference.rs:42:5 + | +LL | Err(From::from("foo")) + | ^^^ cannot infer type of the type parameter `E` declared on the enum `Result` + | +help: consider specifying the generic arguments | -LL | fn muh3() -> Result<(), impl std::fmt::Debug> { - | ^^^^^^^^^^^^^^^^^^^^ cannot infer type +LL | Err::<(), E>(From::from("foo")) + | +++++++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.rs b/src/test/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.rs new file mode 100644 index 00000000000..3a47710d508 --- /dev/null +++ b/src/test/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.rs @@ -0,0 +1,15 @@ +trait Foo<T> { + fn foo(self, f: impl FnOnce()); +} + +impl<T> Foo<T> for () { + fn foo(self, f: impl FnOnce()) { + f() + } +} + +fn main() { + // FIXME: This should ideally use a fully qualified path + // without mentioning the generic arguments of `foo`. + ().foo(|| ()) //~ ERROR type annotations needed +} diff --git a/src/test/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr b/src/test/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr new file mode 100644 index 00000000000..a1a629bddbd --- /dev/null +++ b/src/test/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/fully-qualified-path-impl-trait.rs:14:8 + | +LL | ().foo(|| ()) + | ^^^ cannot infer type for type parameter `T` declared on the trait `Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/impl-trait/fallback_inference.rs b/src/test/ui/impl-trait/fallback_inference.rs index 001f9ee4877..98f0bd1af28 100644 --- a/src/test/ui/impl-trait/fallback_inference.rs +++ b/src/test/ui/impl-trait/fallback_inference.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; fn weird() -> PhantomData<impl Sized> { - PhantomData //~^ ERROR type annotations needed + PhantomData //~ ERROR type annotations needed } fn main() {} diff --git a/src/test/ui/impl-trait/fallback_inference.stderr b/src/test/ui/impl-trait/fallback_inference.stderr index b637ca694c2..4ac3c238fe9 100644 --- a/src/test/ui/impl-trait/fallback_inference.stderr +++ b/src/test/ui/impl-trait/fallback_inference.stderr @@ -1,8 +1,13 @@ error[E0282]: type annotations needed - --> $DIR/fallback_inference.rs:3:27 + --> $DIR/fallback_inference.rs:4:5 | -LL | fn weird() -> PhantomData<impl Sized> { - | ^^^^^^^^^^ cannot infer type +LL | PhantomData + | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `PhantomData` + | +help: consider specifying the generic argument + | +LL | PhantomData::<T> + | +++++ error: aborting due to previous error diff --git a/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs b/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs index 7876add5aa6..970d84120e0 100644 --- a/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs +++ b/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs @@ -5,8 +5,8 @@ #![feature(type_alias_impl_trait)] fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> { - Thunk::new(|mut cont| { //~ ERROR type annotations needed - cont.reify_as(); + Thunk::new(|mut cont| { + cont.reify_as(); //~ ERROR type annotations needed cont }) } @@ -14,8 +14,8 @@ fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> { type Tait = impl FnOnce(Continuation) -> Continuation; fn reify_as_tait() -> Thunk<Tait> { - Thunk::new(|mut cont| { //~ ERROR type annotations needed - cont.reify_as(); + Thunk::new(|mut cont| { + cont.reify_as(); //~ ERROR type annotations needed cont }) } diff --git a/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr b/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr index dcf1982312f..11ba5aa7867 100644 --- a/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr +++ b/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr @@ -1,16 +1,16 @@ error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:8:17 + --> $DIR/hidden-type-is-opaque-2.rs:9:9 | -LL | Thunk::new(|mut cont| { - | ^^^^^^^^ consider giving this closure parameter a type +LL | cont.reify_as(); + | ^^^^ cannot infer type | = note: type must be known at this point error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:17:17 + --> $DIR/hidden-type-is-opaque-2.rs:18:9 | -LL | Thunk::new(|mut cont| { - | ^^^^^^^^ consider giving this closure parameter a type +LL | cont.reify_as(); + | ^^^^ cannot infer type | = note: type must be known at this point diff --git a/src/test/ui/impl-trait/issues/issue-84073.stderr b/src/test/ui/impl-trait/issues/issue-84073.stderr index 36047d23fed..3c39aa6ce5b 100644 --- a/src/test/ui/impl-trait/issues/issue-84073.stderr +++ b/src/test/ui/impl-trait/issues/issue-84073.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed for `RaceBuilder<T, Never<T>>` --> $DIR/issue-84073.rs:32:16 | LL | Race::new(|race| race.when()); - | ^^^^ consider giving this closure parameter the explicit type `RaceBuilder<T, Never<T>>`, where the type parameter `T` is specified + | ^^^^ + | +help: consider giving this closure parameter an explicit type, where the type for type parameter `T` is specified + | +LL | Race::new(|race: RaceBuilder<T, Never<T>>| race.when()); + | ++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/impl-trait/issues/issue-86719.stderr b/src/test/ui/impl-trait/issues/issue-86719.stderr index e2abf71c110..09047cdcbe1 100644 --- a/src/test/ui/impl-trait/issues/issue-86719.stderr +++ b/src/test/ui/impl-trait/issues/issue-86719.stderr @@ -16,7 +16,12 @@ error[E0282]: type annotations needed --> $DIR/issue-86719.rs:9:10 | LL | |_| true - | ^ consider giving this closure parameter a type + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | |_: _| true + | +++ error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-trait/issues/issue-92305.stderr b/src/test/ui/impl-trait/issues/issue-92305.stderr index c4fc49225e9..e8575b76b09 100644 --- a/src/test/ui/impl-trait/issues/issue-92305.stderr +++ b/src/test/ui/impl-trait/issues/issue-92305.stderr @@ -18,7 +18,12 @@ error[E0282]: type annotations needed --> $DIR/issue-92305.rs:7:5 | LL | iter::empty() - | ^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the function `empty` + | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` + | +help: consider specifying the generic argument + | +LL | iter::empty::<T>() + | +++++ error[E0282]: type annotations needed --> $DIR/issue-92305.rs:10:35 diff --git a/src/test/ui/inference/ambiguous_type_parameter.stderr b/src/test/ui/inference/ambiguous_type_parameter.stderr index 47ef1948aee..a08342371b3 100644 --- a/src/test/ui/inference/ambiguous_type_parameter.stderr +++ b/src/test/ui/inference/ambiguous_type_parameter.stderr @@ -3,12 +3,6 @@ error[E0282]: type annotations needed | LL | InMemoryStore.get_raw(&String::default()); | ^^^^^^^ cannot infer type for type parameter `K` - | -help: type parameter declared here - --> $DIR/ambiguous_type_parameter.rs:9:6 - | -LL | impl<K> Store<String, HashMap<K, String>> for InMemoryStore { - | ^ error: aborting due to previous error diff --git a/src/test/ui/inference/cannot-infer-async.stderr b/src/test/ui/inference/cannot-infer-async.stderr index 23360483361..0579cf238a9 100644 --- a/src/test/ui/inference/cannot-infer-async.stderr +++ b/src/test/ui/inference/cannot-infer-async.stderr @@ -1,11 +1,13 @@ error[E0282]: type annotations needed --> $DIR/cannot-infer-async.rs:13:9 | -LL | let fut = async { - | --- consider giving `fut` a type -... LL | Ok(()) - | ^^ cannot infer type for type parameter `E` declared on the enum `Result` + | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` + | +help: consider specifying the generic arguments + | +LL | Ok::<(), E>(()) + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/inference/cannot-infer-closure-circular.rs b/src/test/ui/inference/cannot-infer-closure-circular.rs index a3b957179b1..ae879db68ec 100644 --- a/src/test/ui/inference/cannot-infer-closure-circular.rs +++ b/src/test/ui/inference/cannot-infer-closure-circular.rs @@ -5,10 +5,9 @@ fn main() { // note about the `?` operator in the closure body, which isn't relevant to // the inference. let x = |r| { - //~^ ERROR type annotations needed let v = r?; Ok(v) }; - let _ = x(x(Ok(()))); + let _ = x(x(Ok(()))); //~ ERROR type annotations needed for `Result<(), E>` } diff --git a/src/test/ui/inference/cannot-infer-closure-circular.stderr b/src/test/ui/inference/cannot-infer-closure-circular.stderr index a6ddb7ae908..3ad8e3cda16 100644 --- a/src/test/ui/inference/cannot-infer-closure-circular.stderr +++ b/src/test/ui/inference/cannot-infer-closure-circular.stderr @@ -1,8 +1,13 @@ error[E0282]: type annotations needed for `Result<(), E>` - --> $DIR/cannot-infer-closure-circular.rs:7:14 + --> $DIR/cannot-infer-closure-circular.rs:12:9 | -LL | let x = |r| { - | ^ consider giving this closure parameter the explicit type `Result<(), E>`, where the type parameter `E` is specified +LL | let _ = x(x(Ok(()))); + | ^ + | +help: consider giving this pattern a type, where the type for type parameter `E` is specified + | +LL | let _: Result<(), E> = x(x(Ok(()))); + | +++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/inference/cannot-infer-closure.rs b/src/test/ui/inference/cannot-infer-closure.rs index 6e84b6d5ad0..1c350b18f5a 100644 --- a/src/test/ui/inference/cannot-infer-closure.rs +++ b/src/test/ui/inference/cannot-infer-closure.rs @@ -1,6 +1,6 @@ fn main() { let x = |a: (), b: ()| { Err(a)?; - Ok(b) //~ ERROR type annotations needed for the closure + Ok(b) //~ ERROR type annotations needed }; } diff --git a/src/test/ui/inference/cannot-infer-closure.stderr b/src/test/ui/inference/cannot-infer-closure.stderr index f8026fafeb2..a4b818e6e2b 100644 --- a/src/test/ui/inference/cannot-infer-closure.stderr +++ b/src/test/ui/inference/cannot-infer-closure.stderr @@ -1,13 +1,13 @@ -error[E0282]: type annotations needed for the closure `fn((), ()) -> Result<(), _>` +error[E0282]: type annotations needed --> $DIR/cannot-infer-closure.rs:4:9 | LL | Ok(b) - | ^^ cannot infer type for type parameter `E` declared on the enum `Result` + | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` | -help: give this closure an explicit return type without `_` placeholders +help: consider specifying the generic arguments | -LL | let x = |a: (), b: ()| -> Result<(), _> { - | ++++++++++++++++ +LL | Ok::<(), E>(b) + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/inference/cannot-infer-partial-try-return.rs b/src/test/ui/inference/cannot-infer-partial-try-return.rs index 6e897a3edfd..976827a4478 100644 --- a/src/test/ui/inference/cannot-infer-partial-try-return.rs +++ b/src/test/ui/inference/cannot-infer-partial-try-return.rs @@ -16,7 +16,8 @@ fn infallible() -> Result<(), std::convert::Infallible> { fn main() { let x = || -> Result<_, QualifiedError<_>> { - infallible()?; //~ ERROR type annotations needed + //~^ ERROR type annotations needed for `Result<(), QualifiedError<_>>` + infallible()?; Ok(()) }; } diff --git a/src/test/ui/inference/cannot-infer-partial-try-return.stderr b/src/test/ui/inference/cannot-infer-partial-try-return.stderr index 3542eb6848c..220602c124c 100644 --- a/src/test/ui/inference/cannot-infer-partial-try-return.stderr +++ b/src/test/ui/inference/cannot-infer-partial-try-return.stderr @@ -1,10 +1,10 @@ -error[E0282]: type annotations needed for the closure `fn() -> Result<(), QualifiedError<_>>` - --> $DIR/cannot-infer-partial-try-return.rs:19:9 +error[E0282]: type annotations needed for `Result<(), QualifiedError<_>>` + --> $DIR/cannot-infer-partial-try-return.rs:18:13 | -LL | infallible()?; - | ^^^^^^^^^^^^^ cannot infer type +LL | let x = || -> Result<_, QualifiedError<_>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: give this closure an explicit return type without `_` placeholders +help: try giving this closure an explicit return type | LL | let x = || -> Result<(), QualifiedError<_>> { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/test/ui/inference/erase-type-params-in-label.stderr b/src/test/ui/inference/erase-type-params-in-label.stderr index 51fac5f79df..fd58844c238 100644 --- a/src/test/ui/inference/erase-type-params-in-label.stderr +++ b/src/test/ui/inference/erase-type-params-in-label.stderr @@ -1,46 +1,40 @@ error[E0283]: type annotations needed for `Foo<i32, &str, W, Z>` - --> $DIR/erase-type-params-in-label.rs:2:15 + --> $DIR/erase-type-params-in-label.rs:2:9 | LL | let foo = foo(1, ""); - | --- ^^^ cannot infer type for type parameter `W` declared on the function `foo` - | | - | consider giving `foo` the explicit type `Foo<_, _, W, Z>`, where the type parameter `W` is specified + | ^^^ | -help: type parameter declared here - --> $DIR/erase-type-params-in-label.rs:25:14 - | -LL | fn foo<T, K, W: Default, Z: Default>(t: T, k: K) -> Foo<T, K, W, Z> { - | ^ = note: cannot satisfy `_: Default` note: required by a bound in `foo` --> $DIR/erase-type-params-in-label.rs:25:17 | LL | fn foo<T, K, W: Default, Z: Default>(t: T, k: K) -> Foo<T, K, W, Z> { | ^^^^^^^ required by this bound in `foo` +help: consider giving `foo` an explicit type, where the type for type parameter `W` is specified + | +LL | let foo: Foo<i32, &str, W, Z> = foo(1, ""); + | ++++++++++++++++++++++ help: consider specifying the type arguments in the function call | LL | let foo = foo::<T, K, W, Z>(1, ""); | ++++++++++++++ error[E0283]: type annotations needed for `Bar<i32, &str, Z>` - --> $DIR/erase-type-params-in-label.rs:5:15 + --> $DIR/erase-type-params-in-label.rs:5:9 | LL | let bar = bar(1, ""); - | --- ^^^ cannot infer type for type parameter `Z` declared on the function `bar` - | | - | consider giving `bar` the explicit type `Bar<_, _, Z>`, where the type parameter `Z` is specified + | ^^^ | -help: type parameter declared here - --> $DIR/erase-type-params-in-label.rs:14:14 - | -LL | fn bar<T, K, Z: Default>(t: T, k: K) -> Bar<T, K, Z> { - | ^ = note: cannot satisfy `_: Default` note: required by a bound in `bar` --> $DIR/erase-type-params-in-label.rs:14:17 | LL | fn bar<T, K, Z: Default>(t: T, k: K) -> Bar<T, K, Z> { | ^^^^^^^ required by this bound in `bar` +help: consider giving `bar` an explicit type, where the type for type parameter `Z` is specified + | +LL | let bar: Bar<i32, &str, Z> = bar(1, ""); + | +++++++++++++++++++ help: consider specifying the type arguments in the function call | LL | let bar = bar::<T, K, Z>(1, ""); diff --git a/src/test/ui/inference/issue-71732.stderr b/src/test/ui/inference/issue-71732.stderr index 0369196c910..db153d38aaa 100644 --- a/src/test/ui/inference/issue-71732.stderr +++ b/src/test/ui/inference/issue-71732.stderr @@ -2,9 +2,7 @@ error[E0283]: type annotations needed --> $DIR/issue-71732.rs:18:10 | LL | .get(&"key".into()) - | ^^^ ------------ this method call resolves to `T` - | | - | cannot infer type for type parameter `Q` declared on the associated function `get` + | ^^^ cannot infer type of the type parameter `Q` declared on the associated function `get` | = note: multiple `impl`s satisfying `String: Borrow<_>` found in the following crates: `alloc`, `core`: - impl Borrow<str> for String; @@ -15,6 +13,10 @@ note: required by a bound in `HashMap::<K, V, S>::get` | LL | K: Borrow<Q>, | ^^^^^^^^^ required by this bound in `HashMap::<K, V, S>::get` +help: consider specifying the generic argument + | +LL | .get::<Q>(&"key".into()) + | +++++ help: consider specifying the type argument in the function call | LL | .get::<Q>(&"key".into()) diff --git a/src/test/ui/inference/issue-72616.stderr b/src/test/ui/inference/issue-72616.stderr index 0077c734748..3c53d8126e7 100644 --- a/src/test/ui/inference/issue-72616.stderr +++ b/src/test/ui/inference/issue-72616.stderr @@ -1,16 +1,18 @@ error[E0283]: type annotations needed - --> $DIR/issue-72616.rs:20:30 + --> $DIR/issue-72616.rs:20:37 | LL | if String::from("a") == "a".try_into().unwrap() {} - | ^^ -------------- this method call resolves to `Result<T, <Self as TryInto<T>>::Error>` - | | - | cannot infer type + | ^^^^^^^^ | = note: multiple `impl`s satisfying `String: PartialEq<_>` found in the `alloc` crate: - impl PartialEq for String; - impl<'a, 'b> PartialEq<&'a str> for String; - impl<'a, 'b> PartialEq<Cow<'a, str>> for String; - impl<'a, 'b> PartialEq<str> for String; +help: try using a fully qualified path to specify the expected types + | +LL | if String::from("a") == <&str as TryInto<T>>::try_into("a").unwrap() {} + | +++++++++++++++++++++++++++++++ ~ error: aborting due to previous error diff --git a/src/test/ui/inference/issue-83606.stderr b/src/test/ui/inference/issue-83606.stderr index 9ca8f35fd54..4ffaf820b82 100644 --- a/src/test/ui/inference/issue-83606.stderr +++ b/src/test/ui/inference/issue-83606.stderr @@ -1,10 +1,13 @@ error[E0282]: type annotations needed for `[usize; _]` - --> $DIR/issue-83606.rs:8:13 + --> $DIR/issue-83606.rs:8:9 | LL | let _ = foo("foo"); //<- Do not suggest `foo::<N>("foo");`! - | - ^^^ cannot infer the value of const parameter `N` declared on the function `foo` - | | - | consider giving this pattern the explicit type `[_; N]`, where the const parameter `N` is specified + | ^ + | +help: consider giving this pattern a type, where the the value of const parameter `N` is specified + | +LL | let _: [usize; _] = foo("foo"); //<- Do not suggest `foo::<N>("foo");`! + | ++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/inference/issue-86162-1.stderr b/src/test/ui/inference/issue-86162-1.stderr index edf97c0aed4..6641b29b30b 100644 --- a/src/test/ui/inference/issue-86162-1.stderr +++ b/src/test/ui/inference/issue-86162-1.stderr @@ -1,20 +1,19 @@ error[E0283]: type annotations needed - --> $DIR/issue-86162-1.rs:7:5 + --> $DIR/issue-86162-1.rs:7:9 | LL | foo(gen()); //<- Do not suggest `foo::<impl Clone>()`! - | ^^^ cannot infer type for type parameter `impl Clone` declared on the function `foo` + | ^^^ cannot infer type of the type parameter `T` declared on the function `gen` | -help: type parameter declared here - --> $DIR/issue-86162-1.rs:3:11 - | -LL | fn foo(x: impl Clone) {} - | ^^^^^^^^^^ = note: cannot satisfy `_: Clone` note: required by a bound in `foo` --> $DIR/issue-86162-1.rs:3:16 | LL | fn foo(x: impl Clone) {} | ^^^^^ required by this bound in `foo` +help: consider specifying the generic argument + | +LL | foo(gen::<T>()); //<- Do not suggest `foo::<impl Clone>()`! + | +++++ error: aborting due to previous error diff --git a/src/test/ui/inference/issue-86162-2.stderr b/src/test/ui/inference/issue-86162-2.stderr index c642ebb0576..d2a026a9269 100644 --- a/src/test/ui/inference/issue-86162-2.stderr +++ b/src/test/ui/inference/issue-86162-2.stderr @@ -1,20 +1,19 @@ error[E0283]: type annotations needed - --> $DIR/issue-86162-2.rs:12:5 + --> $DIR/issue-86162-2.rs:12:14 | LL | Foo::bar(gen()); //<- Do not suggest `Foo::bar::<impl Clone>()`! - | ^^^^^^^^ cannot infer type for type parameter `impl Clone` declared on the associated function `bar` + | ^^^ cannot infer type of the type parameter `T` declared on the function `gen` | -help: type parameter declared here - --> $DIR/issue-86162-2.rs:8:15 - | -LL | fn bar(x: impl Clone) {} - | ^^^^^^^^^^ = note: cannot satisfy `_: Clone` note: required by a bound in `Foo::bar` --> $DIR/issue-86162-2.rs:8:20 | LL | fn bar(x: impl Clone) {} | ^^^^^ required by this bound in `Foo::bar` +help: consider specifying the generic argument + | +LL | Foo::bar(gen::<T>()); //<- Do not suggest `Foo::bar::<impl Clone>()`! + | +++++ error: aborting due to previous error 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 diff --git a/src/test/ui/match/match-unresolved-one-arm.stderr b/src/test/ui/match/match-unresolved-one-arm.stderr index 77df9921b75..9eadb88a8ba 100644 --- a/src/test/ui/match/match-unresolved-one-arm.stderr +++ b/src/test/ui/match/match-unresolved-one-arm.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/match-unresolved-one-arm.rs:4:9 | LL | let x = match () { - | ^ consider giving `x` a type + | ^ + | +help: consider giving `x` an explicit type + | +LL | let x: _ = match () { + | +++ error: aborting due to previous error 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 f33672433de..66e7ada3ac5 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 @@ -1,10 +1,13 @@ error[E0282]: type annotations needed for `Vec<T>` - --> $DIR/method-ambig-one-trait-unknown-int-type.rs:24:17 + --> $DIR/method-ambig-one-trait-unknown-int-type.rs:24:9 | LL | let mut x = Vec::new(); - | ----- ^^^^^^^^ cannot infer type for type parameter `T` - | | - | consider giving `x` the explicit type `Vec<T>`, where the type parameter `T` is specified + | ^^^^^ + | +help: consider giving `x` an explicit type, where the type for type parameter `T` is specified + | +LL | let mut x: Vec<T> = Vec::new(); + | ++++++++ error[E0283]: type annotations needed --> $DIR/method-ambig-one-trait-unknown-int-type.rs:26:7 diff --git a/src/test/ui/missing/missing-items/missing-type-parameter.stderr b/src/test/ui/missing/missing-items/missing-type-parameter.stderr index 2aa2b0e6a3c..722539fca6b 100644 --- a/src/test/ui/missing/missing-items/missing-type-parameter.stderr +++ b/src/test/ui/missing/missing-items/missing-type-parameter.stderr @@ -2,13 +2,12 @@ error[E0282]: type annotations needed --> $DIR/missing-type-parameter.rs:4:5 | LL | foo(); - | ^^^ cannot infer type for type parameter `X` declared on the function `foo` + | ^^^ cannot infer type of the type parameter `X` declared on the function `foo` | -help: type parameter declared here - --> $DIR/missing-type-parameter.rs:1:8 +help: consider specifying the generic argument | -LL | fn foo<X>() { } - | ^ +LL | foo::<X>(); + | +++++ error: aborting due to previous error diff --git a/src/test/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr b/src/test/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr index 34f1397ce1d..85c9fe409db 100644 --- a/src/test/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr +++ b/src/test/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr @@ -116,7 +116,12 @@ error[E0282]: type annotations needed --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:14 | LL | V = [Vec::new; { [0].len() ].len() as isize, - | ^^^^^^^^ cannot infer type for type parameter `T` + | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec` + | +help: consider specifying the generic argument + | +LL | V = [Vec::<T>::new; { [0].len() ].len() as isize, + | +++++ error: aborting due to 14 previous errors diff --git a/src/test/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr b/src/test/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr index 427234e97cf..bad241634cb 100644 --- a/src/test/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr +++ b/src/test/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr @@ -40,24 +40,26 @@ LL | let v : Vec<'a> = vec![]; | + error[E0282]: type annotations needed for `Vec<T>` - --> $DIR/missing-closing-angle-bracket-eq-constraint.rs:7:25 + --> $DIR/missing-closing-angle-bracket-eq-constraint.rs:7:7 | LL | let v : Vec<(u32,_) = vec![]; - | - ^^^^^^ cannot infer type for type parameter `T` - | | - | consider giving `v` the explicit type `Vec<T>`, where the type parameter `T` is specified + | ^ + | +help: consider giving `v` an explicit type, where the type for type parameter `T` is specified | - = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | let v: Vec<T> : Vec<(u32,_) = vec![]; + | ++++++++ error[E0282]: type annotations needed for `Vec<T>` - --> $DIR/missing-closing-angle-bracket-eq-constraint.rs:18:20 + --> $DIR/missing-closing-angle-bracket-eq-constraint.rs:18:7 | LL | let v : Vec<'a = vec![]; - | - ^^^^^^ cannot infer type for type parameter `T` - | | - | consider giving `v` the explicit type `Vec<T>`, where the type parameter `T` is specified + | ^ + | +help: consider giving `v` an explicit type, where the type for type parameter `T` is specified | - = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) +LL | let v: Vec<T> : Vec<'a = vec![]; + | ++++++++ error: aborting due to 5 previous errors diff --git a/src/test/ui/pattern/pat-tuple-bad-type.rs b/src/test/ui/pattern/pat-tuple-bad-type.rs index 01e793e8685..98481167a59 100644 --- a/src/test/ui/pattern/pat-tuple-bad-type.rs +++ b/src/test/ui/pattern/pat-tuple-bad-type.rs @@ -1,8 +1,8 @@ fn main() { - let x; + let x; //~ ERROR type annotations needed match x { - (..) => {} //~ ERROR type annotations needed + (..) => {} _ => {} } diff --git a/src/test/ui/pattern/pat-tuple-bad-type.stderr b/src/test/ui/pattern/pat-tuple-bad-type.stderr index 598b6a3794e..11b28987848 100644 --- a/src/test/ui/pattern/pat-tuple-bad-type.stderr +++ b/src/test/ui/pattern/pat-tuple-bad-type.stderr @@ -1,13 +1,14 @@ error[E0282]: type annotations needed - --> $DIR/pat-tuple-bad-type.rs:5:9 + --> $DIR/pat-tuple-bad-type.rs:2:9 | LL | let x; - | - consider giving `x` a type -... -LL | (..) => {} - | ^^^^ cannot infer type + | ^ | = note: type must be known at this point +help: consider giving `x` an explicit type + | +LL | let x: _; + | +++ error[E0308]: mismatched types --> $DIR/pat-tuple-bad-type.rs:10:9 diff --git a/src/test/ui/pattern/rest-pat-semantic-disallowed.stderr b/src/test/ui/pattern/rest-pat-semantic-disallowed.stderr index 06b6e80b44f..e6a4e5f19b7 100644 --- a/src/test/ui/pattern/rest-pat-semantic-disallowed.stderr +++ b/src/test/ui/pattern/rest-pat-semantic-disallowed.stderr @@ -189,7 +189,12 @@ error[E0282]: type annotations needed --> $DIR/rest-pat-semantic-disallowed.rs:33:9 | LL | let x @ ..; - | ^^^^^^ consider giving this pattern a type + | ^^^^^^ + | +help: consider giving this pattern a type + | +LL | let x @ ..: _; + | +++ error: aborting due to 23 previous errors diff --git a/src/test/ui/resolve/issue-85348.stderr b/src/test/ui/resolve/issue-85348.stderr index f475c26f32b..f839dd927db 100644 --- a/src/test/ui/resolve/issue-85348.stderr +++ b/src/test/ui/resolve/issue-85348.stderr @@ -17,7 +17,12 @@ error[E0282]: type annotations needed --> $DIR/issue-85348.rs:6:13 | LL | let mut N; - | ^^^^^ consider giving `N` a type + | ^^^^^ + | +help: consider giving `N` an explicit type + | +LL | let mut N: _; + | +++ error: aborting due to 3 previous errors diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.full.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.full.stderr index 278d0492244..cd3ffdc6f9d 100644 --- a/src/test/ui/span/issue-42234-unknown-receiver-type.full.stderr +++ b/src/test/ui/span/issue-42234-unknown-receiver-type.full.stderr @@ -1,20 +1,26 @@ -error[E0282]: type annotations needed for `Option<_>` - --> $DIR/issue-42234-unknown-receiver-type.rs:10:7 +error[E0282]: type annotations needed + --> $DIR/issue-42234-unknown-receiver-type.rs:9:24 | LL | let x: Option<_> = None; - | - consider giving `x` the explicit type `Option<_>`, where the type parameter `T` is specified -LL | x.unwrap().method_that_could_exist_on_some_type(); - | ^^^^^^ cannot infer type for type parameter `T` + | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` | = note: type must be known at this point +help: consider specifying the generic argument + | +LL | let x: Option<_> = None::<T>; + | +++++ error[E0282]: type annotations needed - --> $DIR/issue-42234-unknown-receiver-type.rs:16:10 + --> $DIR/issue-42234-unknown-receiver-type.rs:15:10 | LL | .sum::<_>() - | ^^^ cannot infer type + | ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum` | = note: type must be known at this point +help: consider specifying the generic argument + | +LL | .sum::<_>() + | ~~~~~ error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr index 8d4ed4aea6a..b6a3f07f571 100644 --- a/src/test/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr +++ b/src/test/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr @@ -1,20 +1,26 @@ -error[E0282]: type annotations needed for `Option<_>` - --> $DIR/issue-42234-unknown-receiver-type.rs:10:7 +error[E0282]: type annotations needed + --> $DIR/issue-42234-unknown-receiver-type.rs:9:24 | LL | let x: Option<_> = None; - | - consider giving `x` the explicit type `Option<_>`, where the type parameter `T` is specified -LL | x.unwrap().method_that_could_exist_on_some_type(); - | ^^^^^^ cannot infer type for type parameter `T` + | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` | = note: type must be known at this point +help: consider specifying the generic argument + | +LL | let x: Option<_> = None::<T>; + | +++++ error[E0282]: type annotations needed - --> $DIR/issue-42234-unknown-receiver-type.rs:16:16 + --> $DIR/issue-42234-unknown-receiver-type.rs:15:10 | LL | .sum::<_>() - | ^ cannot infer type for type parameter `S` declared on the associated function `sum` + | ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum` | = note: type must be known at this point +help: consider specifying the generic argument + | +LL | .sum::<S>() + | ~~~~~ error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.rs b/src/test/ui/span/issue-42234-unknown-receiver-type.rs index 15b00de44b9..fd53121204c 100644 --- a/src/test/ui/span/issue-42234-unknown-receiver-type.rs +++ b/src/test/ui/span/issue-42234-unknown-receiver-type.rs @@ -6,9 +6,8 @@ // the fix of which this tests). fn shines_a_beacon_through_the_darkness() { - let x: Option<_> = None; + let x: Option<_> = None; //~ ERROR type annotations needed x.unwrap().method_that_could_exist_on_some_type(); - //~^ ERROR type annotations needed } fn courier_to_des_moines_and_points_west(data: &[u32]) -> String { diff --git a/src/test/ui/span/method-and-field-eager-resolution.rs b/src/test/ui/span/method-and-field-eager-resolution.rs index a38f07d58e4..a0f0d8810e5 100644 --- a/src/test/ui/span/method-and-field-eager-resolution.rs +++ b/src/test/ui/span/method-and-field-eager-resolution.rs @@ -2,14 +2,14 @@ fn main() { let mut x = Default::default(); - x.0; //~^ ERROR type annotations needed + x.0; x = 1; } fn foo() { let mut x = Default::default(); - x[0]; //~^ ERROR type annotations needed + x[0]; x = 1; } diff --git a/src/test/ui/span/method-and-field-eager-resolution.stderr b/src/test/ui/span/method-and-field-eager-resolution.stderr index 0ecbe4c136e..2dd650f38ce 100644 --- a/src/test/ui/span/method-and-field-eager-resolution.stderr +++ b/src/test/ui/span/method-and-field-eager-resolution.stderr @@ -1,22 +1,26 @@ error[E0282]: type annotations needed - --> $DIR/method-and-field-eager-resolution.rs:5:5 + --> $DIR/method-and-field-eager-resolution.rs:4:9 | LL | let mut x = Default::default(); - | ----- consider giving `x` a type -LL | x.0; - | ^ cannot infer type + | ^^^^^ | = note: type must be known at this point +help: consider giving `x` an explicit type + | +LL | let mut x: _ = Default::default(); + | +++ error[E0282]: type annotations needed - --> $DIR/method-and-field-eager-resolution.rs:12:5 + --> $DIR/method-and-field-eager-resolution.rs:11:9 | LL | let mut x = Default::default(); - | ----- consider giving `x` a type -LL | x[0]; - | ^ cannot infer type + | ^^^^^ | = note: type must be known at this point +help: consider giving `x` an explicit type + | +LL | let mut x: _ = Default::default(); + | +++ error: aborting due to 2 previous errors diff --git a/src/test/ui/span/type-annotations-needed-expr.stderr b/src/test/ui/span/type-annotations-needed-expr.stderr index fbfbefd0782..e4a8f746462 100644 --- a/src/test/ui/span/type-annotations-needed-expr.stderr +++ b/src/test/ui/span/type-annotations-needed-expr.stderr @@ -2,10 +2,10 @@ error[E0282]: type annotations needed --> $DIR/type-annotations-needed-expr.rs:2:39 | LL | let _ = (vec![1,2,3]).into_iter().sum() as f64; - | ^^^ cannot infer type for type parameter `S` declared on the associated function `sum` + | ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum` | = note: type must be known at this point -help: consider specifying the type argument in the method call +help: consider specifying the generic argument | LL | let _ = (vec![1,2,3]).into_iter().sum::<S>() as f64; | +++++ diff --git a/src/test/ui/suggestions/fn-needing-specified-return-type-param.rs b/src/test/ui/suggestions/fn-needing-specified-return-type-param.rs index 2f140f823af..bcc91b5cb4c 100644 --- a/src/test/ui/suggestions/fn-needing-specified-return-type-param.rs +++ b/src/test/ui/suggestions/fn-needing-specified-return-type-param.rs @@ -1,5 +1,7 @@ fn f<A>() -> A { unimplemented!() } fn foo() { - let _ = f; //~ ERROR type annotations needed for `fn() -> A` + let _ = f; + //~^ ERROR type annotations needed + //~| HELP consider specifying the generic argument } fn main() {} diff --git a/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr b/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr index a4cfee55633..9dea667fb96 100644 --- a/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr +++ b/src/test/ui/suggestions/fn-needing-specified-return-type-param.stderr @@ -1,16 +1,13 @@ -error[E0282]: type annotations needed for `fn() -> A` +error[E0282]: type annotations needed --> $DIR/fn-needing-specified-return-type-param.rs:3:13 | LL | let _ = f; - | - ^ cannot infer type for type parameter `A` declared on the function `f` - | | - | consider giving this pattern the explicit type `fn() -> A`, where the type parameter `A` is specified + | ^ cannot infer type of the type parameter `A` declared on the function `f` | -help: type parameter declared here - --> $DIR/fn-needing-specified-return-type-param.rs:1:6 +help: consider specifying the generic argument | -LL | fn f<A>() -> A { unimplemented!() } - | ^ +LL | let _ = f::<A>; + | +++++ error: aborting due to previous error diff --git a/src/test/ui/suggestions/suggest-closure-return-type-1.rs b/src/test/ui/suggestions/suggest-closure-return-type-1.rs index 910f273b972..8bb4219039b 100644 --- a/src/test/ui/suggestions/suggest-closure-return-type-1.rs +++ b/src/test/ui/suggestions/suggest-closure-return-type-1.rs @@ -1,3 +1,7 @@ +fn unbound_drop(_: impl Sized) {} + fn main() { - let _v = || -> _ { [] }; //~ ERROR type annotations needed for the closure + unbound_drop(|| -> _ { [] }); + //~^ ERROR type annotations needed for `[_; 0]` + //~| HELP try giving this closure an explicit return type } diff --git a/src/test/ui/suggestions/suggest-closure-return-type-1.stderr b/src/test/ui/suggestions/suggest-closure-return-type-1.stderr index 7161ca3903e..3116211b52c 100644 --- a/src/test/ui/suggestions/suggest-closure-return-type-1.stderr +++ b/src/test/ui/suggestions/suggest-closure-return-type-1.stderr @@ -1,13 +1,13 @@ -error[E0282]: type annotations needed for the closure `fn() -> [_; 0]` - --> $DIR/suggest-closure-return-type-1.rs:2:24 +error[E0282]: type annotations needed for `[_; 0]` + --> $DIR/suggest-closure-return-type-1.rs:4:18 | -LL | let _v = || -> _ { [] }; - | ^^ cannot infer type +LL | unbound_drop(|| -> _ { [] }); + | ^^^^^^^ | -help: give this closure an explicit return type without `_` placeholders +help: try giving this closure an explicit return type | -LL | let _v = || -> [_; 0] { [] }; - | ~~~~~~ +LL | unbound_drop(|| -> [_; 0] { [] }); + | ~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/suggestions/suggest-closure-return-type-2.rs b/src/test/ui/suggestions/suggest-closure-return-type-2.rs index 6955b37ad97..25ed1882e8d 100644 --- a/src/test/ui/suggestions/suggest-closure-return-type-2.rs +++ b/src/test/ui/suggestions/suggest-closure-return-type-2.rs @@ -1,3 +1,7 @@ +fn unbound_drop(_: impl Sized) {} + fn main() { - let _v = || { [] }; //~ ERROR type annotations needed for the closure + unbound_drop(|| { [] }) + //~^ ERROR type annotations needed for `[_; 0]` + //~| HELP try giving this closure an explicit return type } diff --git a/src/test/ui/suggestions/suggest-closure-return-type-2.stderr b/src/test/ui/suggestions/suggest-closure-return-type-2.stderr index a7f5b58c4da..f368e7de467 100644 --- a/src/test/ui/suggestions/suggest-closure-return-type-2.stderr +++ b/src/test/ui/suggestions/suggest-closure-return-type-2.stderr @@ -1,13 +1,13 @@ -error[E0282]: type annotations needed for the closure `fn() -> [_; 0]` - --> $DIR/suggest-closure-return-type-2.rs:2:19 +error[E0282]: type annotations needed for `[_; 0]` + --> $DIR/suggest-closure-return-type-2.rs:4:18 | -LL | let _v = || { [] }; - | ^^ cannot infer type +LL | unbound_drop(|| { [] }) + | ^^ | -help: give this closure an explicit return type without `_` placeholders +help: try giving this closure an explicit return type | -LL | let _v = || -> [_; 0] { [] }; - | +++++++++ +LL | unbound_drop(|| -> [_; 0] { [] }) + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/suggestions/suggest-closure-return-type-3.rs b/src/test/ui/suggestions/suggest-closure-return-type-3.rs index ec6c094027e..3de6c55cf16 100644 --- a/src/test/ui/suggestions/suggest-closure-return-type-3.rs +++ b/src/test/ui/suggestions/suggest-closure-return-type-3.rs @@ -1,3 +1,7 @@ +fn unbound_drop(_: impl Sized) {} + fn main() { - let _v = || []; //~ ERROR type annotations needed for the closure + unbound_drop(|| []); + //~^ ERROR type annotations needed for `[_; 0]` + //~| HELP try giving this closure an explicit return type } diff --git a/src/test/ui/suggestions/suggest-closure-return-type-3.stderr b/src/test/ui/suggestions/suggest-closure-return-type-3.stderr index eeec23e0da0..41769321533 100644 --- a/src/test/ui/suggestions/suggest-closure-return-type-3.stderr +++ b/src/test/ui/suggestions/suggest-closure-return-type-3.stderr @@ -1,13 +1,13 @@ -error[E0282]: type annotations needed for the closure `fn() -> [_; 0]` - --> $DIR/suggest-closure-return-type-3.rs:2:17 +error[E0282]: type annotations needed for `[_; 0]` + --> $DIR/suggest-closure-return-type-3.rs:4:18 | -LL | let _v = || []; - | ^^ cannot infer type +LL | unbound_drop(|| []); + | ^^ | -help: give this closure an explicit return type without `_` placeholders +help: try giving this closure an explicit return type | -LL | let _v = || -> [_; 0] { [] }; - | +++++++++++ + +LL | unbound_drop(|| -> [_; 0] { [] }); + | +++++++++++ + error: aborting due to previous error diff --git a/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr b/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr index 0e52420ec43..57b2587ae5c 100644 --- a/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr +++ b/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr @@ -2,19 +2,18 @@ error[E0282]: type annotations needed --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:17:11 | LL | thing.method(42); - | ------^^^^^^---- - | | | - | | cannot infer type for type parameter `T` declared on the trait `Method` - | this method call resolves to `T` + | ^^^^^^ + | +help: try using a fully qualified path to specify the expected types + | +LL | <Thing<bool> as Method<T>>::method(thing, 42); + | +++++++++++++++++++++++++++++++++++ ~ error[E0283]: type annotations needed --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:17:11 | LL | thing.method(42); - | ------^^^^^^---- - | | | - | | cannot infer type for type parameter `T` declared on the trait `Method` - | this method call resolves to `T` + | ^^^^^^ | note: multiple `impl`s satisfying `Thing<bool>: Method<_>` found --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:7:1 @@ -24,12 +23,10 @@ LL | impl<X> Method<i32> for Thing<X> { ... LL | impl<X> Method<u32> for Thing<X> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: use the fully qualified path for the potential candidates +help: try using a fully qualified path to specify the expected types | -LL | <Thing<_> as Method<i32>>::method(thing, 42); - | ++++++++++++++++++++++++++++++++++ ~ -LL | <Thing<_> as Method<u32>>::method(thing, 42); - | ++++++++++++++++++++++++++++++++++ ~ +LL | <Thing<bool> as Method<T>>::method(thing, 42); + | +++++++++++++++++++++++++++++++++++ ~ error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/issue-77982.stderr b/src/test/ui/traits/issue-77982.stderr index 63c1cb3791e..5aa42b5b1d3 100644 --- a/src/test/ui/traits/issue-77982.stderr +++ b/src/test/ui/traits/issue-77982.stderr @@ -2,9 +2,7 @@ error[E0283]: type annotations needed --> $DIR/issue-77982.rs:8:10 | LL | opts.get(opt.as_ref()); - | ^^^ ------------ this method call resolves to `&T` - | | - | cannot infer type for type parameter `Q` declared on the associated function `get` + | ^^^ cannot infer type of the type parameter `Q` declared on the associated function `get` | = note: multiple `impl`s satisfying `String: Borrow<_>` found in the following crates: `alloc`, `core`: - impl Borrow<str> for String; @@ -15,44 +13,36 @@ note: required by a bound in `HashMap::<K, V, S>::get` | LL | K: Borrow<Q>, | ^^^^^^^^^ required by this bound in `HashMap::<K, V, S>::get` +help: consider specifying the generic argument + | +LL | opts.get::<Q>(opt.as_ref()); + | +++++ help: consider specifying the type argument in the function call | LL | opts.get::<Q>(opt.as_ref()); | +++++ error[E0283]: type annotations needed - --> $DIR/issue-77982.rs:8:18 + --> $DIR/issue-77982.rs:8:10 | LL | opts.get(opt.as_ref()); - | ----^^^^^^-- - | | | - | | cannot infer type for type parameter `T` declared on the trait `AsRef` - | this method call resolves to `&T` + | ^^^ cannot infer type of the type parameter `Q` declared on the associated function `get` | = note: multiple `impl`s satisfying `String: AsRef<_>` found in the following crates: `alloc`, `std`: - impl AsRef<OsStr> for String; - impl AsRef<Path> for String; - impl AsRef<[u8]> for String; - impl AsRef<str> for String; -help: use the fully qualified path for the potential candidates - | -LL | opts.get(<String as AsRef<OsStr>>::as_ref(opt)); - | +++++++++++++++++++++++++++++++++ ~ -LL | opts.get(<String as AsRef<Path>>::as_ref(opt)); - | ++++++++++++++++++++++++++++++++ ~ -LL | opts.get(<String as AsRef<[u8]>>::as_ref(opt)); - | ++++++++++++++++++++++++++++++++ ~ -LL | opts.get(<String as AsRef<str>>::as_ref(opt)); - | +++++++++++++++++++++++++++++++ ~ - and 4 other candidates +help: consider specifying the generic argument + | +LL | opts.get::<Q>(opt.as_ref()); + | +++++ error[E0283]: type annotations needed - --> $DIR/issue-77982.rs:13:44 + --> $DIR/issue-77982.rs:13:59 | LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(); - | ^^^^^^^^^ ----------- this method call resolves to `T` - | | - | cannot infer type for type parameter `T` declared on the trait `From` + | ^^^^ | = note: multiple `impl`s satisfying `u32: From<_>` found in the following crates: `core`, `std`: - impl From<Ipv4Addr> for u32; @@ -60,14 +50,16 @@ LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect( - impl From<bool> for u32; - impl From<char> for u32; and 3 more +help: try using a fully qualified path to specify the expected types + | +LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(<u32 as Into<T>>::into(0u32))).collect(); + | +++++++++++++++++++++++ ~ error[E0283]: type annotations needed for `Box<T>` - --> $DIR/issue-77982.rs:36:16 + --> $DIR/issue-77982.rs:36:9 | LL | let _ = ().foo(); - | - ^^^ cannot infer type for type parameter `T` declared on the trait `Foo` - | | - | consider giving this pattern the explicit type `Box<T>`, where the type parameter `T` is specified + | ^ | note: multiple `impl`s satisfying `(): Foo<'_, _>` found --> $DIR/issue-77982.rs:29:1 @@ -76,14 +68,16 @@ LL | impl Foo<'static, u32> for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | impl<'a> Foo<'a, i16> for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: consider giving this pattern a type, where the type for type parameter `T` is specified + | +LL | let _: Box<T> = ().foo(); + | ++++++++ error[E0283]: type annotations needed for `Box<T>` - --> $DIR/issue-77982.rs:40:19 + --> $DIR/issue-77982.rs:40:9 | LL | let _ = (&()).bar(); - | - ^^^ cannot infer type for type parameter `T` declared on the trait `Bar` - | | - | consider giving this pattern the explicit type `Box<T>`, where the type parameter `T` is specified + | ^ | note: multiple `impl`s satisfying `&(): Bar<'_, _>` found --> $DIR/issue-77982.rs:32:1 @@ -92,6 +86,10 @@ LL | impl<'a> Bar<'static, u32> for &'a () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | impl<'a> Bar<'a, i16> for &'a () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: consider giving this pattern a type, where the type for type parameter `T` is specified + | +LL | let _: Box<T> = (&()).bar(); + | ++++++++ error: aborting due to 5 previous errors diff --git a/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr b/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr index da746134710..25f8d538377 100644 --- a/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr +++ b/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr @@ -2,25 +2,19 @@ error[E0282]: type annotations needed --> $DIR/multidispatch-convert-ambig-dest.rs:26:5 | LL | test(22, std::default::Default::default()); - | ^^^^ cannot infer type for type parameter `U` declared on the function `test` + | ^^^^ cannot infer type of the type parameter `U` declared on the function `test` | -help: type parameter declared here - --> $DIR/multidispatch-convert-ambig-dest.rs:20:11 +help: consider specifying the generic arguments | -LL | fn test<T,U>(_: T, _: U) - | ^ +LL | test::<i32, U>(22, std::default::Default::default()); + | ++++++++++ error[E0283]: type annotations needed --> $DIR/multidispatch-convert-ambig-dest.rs:26:5 | LL | test(22, std::default::Default::default()); - | ^^^^ cannot infer type for type parameter `U` declared on the function `test` - | -help: type parameter declared here - --> $DIR/multidispatch-convert-ambig-dest.rs:20:11 + | ^^^^ cannot infer type of the type parameter `U` declared on the function `test` | -LL | fn test<T,U>(_: T, _: U) - | ^ note: multiple `impl`s satisfying `i32: Convert<_>` found --> $DIR/multidispatch-convert-ambig-dest.rs:8:1 | @@ -36,6 +30,10 @@ LL | fn test<T,U>(_: T, _: U) | ---- required by a bound in this LL | where T : Convert<U> | ^^^^^^^^^^ required by this bound in `test` +help: consider specifying the generic arguments + | +LL | test::<i32, U>(22, std::default::Default::default()); + | ++++++++++ help: consider specifying the type arguments in the function call | LL | test::<T, U>(22, std::default::Default::default()); diff --git a/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr b/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr index 3c8d7450f96..75d45d9052b 100644 --- a/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr +++ b/src/test/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr @@ -2,25 +2,19 @@ error[E0282]: type annotations needed --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7 | LL | a.method(); - | --^^^^^^-- - | | | - | | cannot infer type for type parameter `U` declared on the trait `V` - | this method call resolves to `U` + | ^^^^^^ + | +help: try using a fully qualified path to specify the expected types + | +LL | <A<B> as V<U>>::method(a); + | +++++++++++++++++++++++ ~ error[E0283]: type annotations needed --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7 | LL | a.method(); - | --^^^^^^-- - | | | - | | cannot infer type for type parameter `U` - | this method call resolves to `U` - | -help: type parameter declared here - --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:12:9 + | ^^^^^^ | -LL | impl<T, U> V<U> for A<T> - | ^ note: multiple `impl`s satisfying `B: I<_>` found --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:5:1 | @@ -33,6 +27,10 @@ note: required because of the requirements on the impl of `V<_>` for `A<B>` | LL | impl<T, U> V<U> for A<T> | ^^^^ ^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <A<B> as V<U>>::method(a); + | +++++++++++++++++++++++ ~ error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.rs b/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.rs new file mode 100644 index 00000000000..9a2cf469d08 --- /dev/null +++ b/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.rs @@ -0,0 +1,60 @@ +use std::ops::{Deref, DerefMut}; + +struct Thing; + +trait Method<T> { + fn method(&self) -> T; + fn mut_method(&mut self) -> T; +} + +impl Method<i32> for Thing { + fn method(&self) -> i32 { 0 } + fn mut_method(&mut self) -> i32 { 0 } +} + +impl Method<u32> for Thing { + fn method(&self) -> u32 { 0 } + fn mut_method(&mut self) -> u32 { 0 } +} +trait MethodRef<T> { + fn by_self(self); +} +impl MethodRef<i32> for &Thing { + fn by_self(self) {} +} +impl MethodRef<u32> for &Thing { + fn by_self(self) {} +} + + +struct DerefsTo<T>(T); +impl<T> Deref for DerefsTo<T> { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } +} +impl<T> DerefMut for DerefsTo<T> { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +fn main() { + let mut thing = Thing; + thing.method(); + //~^ ERROR type annotations needed + //~| ERROR type annotations needed + thing.mut_method(); //~ ERROR type annotations needed + thing.by_self(); //~ ERROR type annotations needed + + let mut deref_to = DerefsTo(Thing); + deref_to.method(); //~ ERROR type annotations needed + deref_to.mut_method(); //~ ERROR type annotations needed + deref_to.by_self(); //~ ERROR type annotations needed + + let mut deref_deref_to = DerefsTo(DerefsTo(Thing)); + deref_deref_to.method(); //~ ERROR type annotations needed + deref_deref_to.mut_method(); //~ ERROR type annotations needed + deref_deref_to.by_self(); //~ ERROR type annotations needed +} diff --git a/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr b/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr new file mode 100644 index 00000000000..68b31a1ca34 --- /dev/null +++ b/src/test/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr @@ -0,0 +1,186 @@ +error[E0282]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:45:11 + | +LL | thing.method(); + | ^^^^^^ + | +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::method(&thing); + | ++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:45:11 + | +LL | thing.method(); + | ^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::method(&thing); + | ++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:48:11 + | +LL | thing.mut_method(); + | ^^^^^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::mut_method(&mut thing); + | +++++++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:49:11 + | +LL | thing.by_self(); + | ^^^^^^^ + | +note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:22:1 + | +LL | impl MethodRef<i32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl MethodRef<u32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <&Thing as MethodRef<T>>::by_self(&thing); + | +++++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:52:14 + | +LL | deref_to.method(); + | ^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::method(&deref_to); + | ++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:53:14 + | +LL | deref_to.mut_method(); + | ^^^^^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::mut_method(&mut deref_to); + | +++++++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:54:14 + | +LL | deref_to.by_self(); + | ^^^^^^^ + | +note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:22:1 + | +LL | impl MethodRef<i32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl MethodRef<u32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <&Thing as MethodRef<T>>::by_self(&deref_to); + | +++++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:57:20 + | +LL | deref_deref_to.method(); + | ^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::method(&deref_deref_to); + | ++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:58:20 + | +LL | deref_deref_to.mut_method(); + | ^^^^^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::mut_method(&mut deref_deref_to); + | +++++++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:59:20 + | +LL | deref_deref_to.by_self(); + | ^^^^^^^ + | +note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:22:1 + | +LL | impl MethodRef<i32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl MethodRef<u32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <&Thing as MethodRef<T>>::by_self(&deref_deref_to); + | +++++++++++++++++++++++++++++++++++ ~ + +error: aborting due to 10 previous errors + +Some errors have detailed explanations: E0282, E0283. +For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/traits/suggest-fully-qualified-path-with-appropriate-params.rs b/src/test/ui/traits/suggest-fully-qualified-path-with-appropriate-params.rs deleted file mode 100644 index da68b996be9..00000000000 --- a/src/test/ui/traits/suggest-fully-qualified-path-with-appropriate-params.rs +++ /dev/null @@ -1,24 +0,0 @@ -struct Thing; - -trait Method<T> { - fn method(&self) -> T; - fn mut_method(&mut self) -> T; -} - -impl Method<i32> for Thing { - fn method(&self) -> i32 { 0 } - fn mut_method(&mut self) -> i32 { 0 } -} - -impl Method<u32> for Thing { - fn method(&self) -> u32 { 0 } - fn mut_method(&mut self) -> u32 { 0 } -} - -fn main() { - let thing = Thing; - thing.method(); - //~^ ERROR type annotations needed - //~| ERROR type annotations needed - thing.mut_method(); //~ ERROR type annotations needed -} diff --git a/src/test/ui/traits/suggest-fully-qualified-path-with-appropriate-params.stderr b/src/test/ui/traits/suggest-fully-qualified-path-with-appropriate-params.stderr deleted file mode 100644 index 0c4962417e9..00000000000 --- a/src/test/ui/traits/suggest-fully-qualified-path-with-appropriate-params.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:20:11 - | -LL | thing.method(); - | ------^^^^^^-- - | | | - | | cannot infer type for type parameter `T` declared on the trait `Method` - | this method call resolves to `T` - -error[E0283]: type annotations needed - --> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:20:11 - | -LL | thing.method(); - | ------^^^^^^-- - | | | - | | cannot infer type for type parameter `T` declared on the trait `Method` - | this method call resolves to `T` - | -note: multiple `impl`s satisfying `Thing: Method<_>` found - --> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:8:1 - | -LL | impl Method<i32> for Thing { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | impl Method<u32> for Thing { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: use the fully qualified path for the potential candidates - | -LL | <Thing as Method<i32>>::method(&thing); - | ++++++++++++++++++++++++++++++++ ~ -LL | <Thing as Method<u32>>::method(&thing); - | ++++++++++++++++++++++++++++++++ ~ - -error[E0283]: type annotations needed - --> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:23:11 - | -LL | thing.mut_method(); - | ------^^^^^^^^^^-- - | | | - | | cannot infer type for type parameter `T` declared on the trait `Method` - | this method call resolves to `T` - | -note: multiple `impl`s satisfying `Thing: Method<_>` found - --> $DIR/suggest-fully-qualified-path-with-appropriate-params.rs:8:1 - | -LL | impl Method<i32> for Thing { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | impl Method<u32> for Thing { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: use the fully qualified path for the potential candidates - | -LL | <Thing as Method<i32>>::mut_method(&mut thing); - | +++++++++++++++++++++++++++++++++++++++ ~ -LL | <Thing as Method<u32>>::mut_method(&mut thing); - | +++++++++++++++++++++++++++++++++++++++ ~ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0282, E0283. -For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.rs b/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.rs new file mode 100644 index 00000000000..da640c8c8c2 --- /dev/null +++ b/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.rs @@ -0,0 +1,64 @@ +use std::ops::{Deref, DerefMut}; + +struct Thing; + +trait Method<T> { + fn method(&self) -> T; + fn mut_method(&mut self) -> T; +} + +impl Method<i32> for Thing { + fn method(&self) -> i32 { 0 } + fn mut_method(&mut self) -> i32 { 0 } +} + +impl Method<u32> for Thing { + fn method(&self) -> u32 { 0 } + fn mut_method(&mut self) -> u32 { 0 } +} + +trait MethodRef<T> { + fn by_self(self); +} +impl MethodRef<i32> for &Thing { + fn by_self(self) {} +} +impl MethodRef<u32> for &Thing { + fn by_self(self) {} +} + +struct DerefsTo<T>(T); +impl<T> Deref for DerefsTo<T> { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } +} +impl<T> DerefMut for DerefsTo<T> { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +fn main() { + let mut ref_thing = &Thing; + ref_thing.method(); + //~^ ERROR type annotations needed + //~| ERROR type annotations needed + ref_thing.by_self(); //~ ERROR type annotations needed + + let mut mut_thing = &mut Thing; + mut_thing.method(); //~ ERROR type annotations needed + mut_thing.mut_method(); //~ ERROR type annotations needed + mut_thing.by_self(); //~ ERROR type annotations needed + + let mut deref_to = &DerefsTo(Thing); + deref_to.method(); //~ ERROR type annotations needed + deref_to.mut_method(); //~ ERROR type annotations needed + deref_to.by_self(); //~ ERROR type annotations needed + + let mut deref_deref_to = &DerefsTo(DerefsTo(Thing)); + deref_deref_to.method(); //~ ERROR type annotations needed + deref_deref_to.mut_method(); //~ ERROR type annotations needed + deref_deref_to.by_self(); //~ ERROR type annotations needed +} diff --git a/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr b/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr new file mode 100644 index 00000000000..27518a54e75 --- /dev/null +++ b/src/test/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr @@ -0,0 +1,224 @@ +error[E0282]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:45:15 + | +LL | ref_thing.method(); + | ^^^^^^ + | +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::method(ref_thing); + | +++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:45:15 + | +LL | ref_thing.method(); + | ^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::method(ref_thing); + | +++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:48:15 + | +LL | ref_thing.by_self(); + | ^^^^^^^ + | +note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1 + | +LL | impl MethodRef<i32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl MethodRef<u32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <&Thing as MethodRef<T>>::by_self(ref_thing); + | ++++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:51:15 + | +LL | mut_thing.method(); + | ^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::method(mut_thing); + | +++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:52:15 + | +LL | mut_thing.mut_method(); + | ^^^^^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::mut_method(mut_thing); + | +++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:53:15 + | +LL | mut_thing.by_self(); + | ^^^^^^^ + | +note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1 + | +LL | impl MethodRef<i32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl MethodRef<u32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <&Thing as MethodRef<T>>::by_self(mut_thing); + | ++++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:56:14 + | +LL | deref_to.method(); + | ^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::method(deref_to); + | +++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:57:14 + | +LL | deref_to.mut_method(); + | ^^^^^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::mut_method(deref_to); + | +++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:58:14 + | +LL | deref_to.by_self(); + | ^^^^^^^ + | +note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1 + | +LL | impl MethodRef<i32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl MethodRef<u32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <&Thing as MethodRef<T>>::by_self(deref_to); + | ++++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:61:20 + | +LL | deref_deref_to.method(); + | ^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::method(deref_deref_to); + | +++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:62:20 + | +LL | deref_deref_to.mut_method(); + | ^^^^^^^^^^ + | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 + | +LL | impl Method<i32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method<u32> for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <Thing as Method<T>>::mut_method(deref_deref_to); + | +++++++++++++++++++++++++++++++++ ~ + +error[E0283]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:63:20 + | +LL | deref_deref_to.by_self(); + | ^^^^^^^ + | +note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1 + | +LL | impl MethodRef<i32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl MethodRef<u32> for &Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: try using a fully qualified path to specify the expected types + | +LL | <&Thing as MethodRef<T>>::by_self(deref_deref_to); + | ++++++++++++++++++++++++++++++++++ ~ + +error: aborting due to 12 previous errors + +Some errors have detailed explanations: E0282, E0283. +For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr b/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr index cfa4a4b9d20..b3ca260894b 100644 --- a/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr +++ b/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr @@ -2,9 +2,13 @@ error[E0282]: type annotations needed --> $DIR/closures_in_branches.rs:21:10 | LL | |x| x.len() - | ^ consider giving this closure parameter a type + | ^ | = note: type must be known at this point +help: consider giving this closure parameter an explicit type + | +LL | |x: _| x.len() + | +++ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/incomplete-inference.stderr b/src/test/ui/type-alias-impl-trait/incomplete-inference.stderr index 0cdd4cc8dc3..9a0e71b4eed 100644 --- a/src/test/ui/type-alias-impl-trait/incomplete-inference.stderr +++ b/src/test/ui/type-alias-impl-trait/incomplete-inference.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/incomplete-inference.rs:6:5 | LL | 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 | None::<T> + | +++++ error: aborting due to previous error diff --git a/src/test/ui/type-inference/or_else-multiple-type-params.stderr b/src/test/ui/type-inference/or_else-multiple-type-params.stderr index 12a98e4d783..6ac63a91ee9 100644 --- a/src/test/ui/type-inference/or_else-multiple-type-params.stderr +++ b/src/test/ui/type-inference/or_else-multiple-type-params.stderr @@ -1,13 +1,13 @@ -error[E0282]: type annotations needed - --> $DIR/or_else-multiple-type-params.rs:7:10 +error[E0282]: type annotations needed for `Result<Child, F>` + --> $DIR/or_else-multiple-type-params.rs:7:18 | LL | .or_else(|err| { - | ^^^^^^^ cannot infer type for type parameter `F` declared on the associated function `or_else` + | ^^^^^ | -help: consider specifying the type arguments in the method call +help: try giving this closure an explicit return type | -LL | .or_else::<F, O>(|err| { - | ++++++++ +LL | .or_else(|err| -> Result<Child, F> { + | +++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/type-inference/sort_by_key.stderr b/src/test/ui/type-inference/sort_by_key.stderr index 78b7386c03e..0a48d5756eb 100644 --- a/src/test/ui/type-inference/sort_by_key.stderr +++ b/src/test/ui/type-inference/sort_by_key.stderr @@ -1,10 +1,10 @@ error[E0282]: type annotations needed - --> $DIR/sort_by_key.rs:3:9 + --> $DIR/sort_by_key.rs:3:40 | LL | lst.sort_by_key(|&(v, _)| v.iter().sum()); - | ^^^^^^^^^^^ cannot infer type for type parameter `K` declared on the associated function `sort_by_key` + | ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum` | -help: consider specifying the type argument in the method call +help: consider specifying the generic argument | LL | lst.sort_by_key(|&(v, _)| v.iter().sum::<S>()); | +++++ diff --git a/src/test/ui/type-inference/unbounded-associated-type.stderr b/src/test/ui/type-inference/unbounded-associated-type.stderr index 19e2bd4513d..e0fecc72f30 100644 --- a/src/test/ui/type-inference/unbounded-associated-type.stderr +++ b/src/test/ui/type-inference/unbounded-associated-type.stderr @@ -1,14 +1,13 @@ error[E0282]: type annotations needed - --> $DIR/unbounded-associated-type.rs:15:5 + --> $DIR/unbounded-associated-type.rs:15:7 | -LL | type A; - | ------- `<Self as T>::A` defined here -... LL | S(std::marker::PhantomData).foo(); - | ^-------------------------------- - | | - | this method call resolves to `<Self as T>::A` - | cannot infer type for type parameter `X` declared on the struct `S` + | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `PhantomData` + | +help: consider specifying the generic argument + | +LL | S(std::marker::PhantomData::<T>).foo(); + | +++++ error: aborting due to previous error diff --git a/src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr b/src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr index 501fa7c8c67..209abfe5cba 100644 --- a/src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr +++ b/src/test/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr @@ -2,13 +2,12 @@ error[E0282]: type annotations needed --> $DIR/unbounded-type-param-in-fn-with-assoc-type.rs:8:5 | LL | foo(); - | ^^^ cannot infer type for type parameter `T` declared on the function `foo` + | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | -help: type parameter declared here - --> $DIR/unbounded-type-param-in-fn-with-assoc-type.rs:3:8 +help: consider specifying the generic arguments | -LL | fn foo<T, U = u64>() -> (T, U) { - | ^ +LL | foo::<T, U>(); + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/type-inference/unbounded-type-param-in-fn.stderr b/src/test/ui/type-inference/unbounded-type-param-in-fn.stderr index d01c3a7d4e2..d92892eeb84 100644 --- a/src/test/ui/type-inference/unbounded-type-param-in-fn.stderr +++ b/src/test/ui/type-inference/unbounded-type-param-in-fn.stderr @@ -2,13 +2,12 @@ error[E0282]: type annotations needed --> $DIR/unbounded-type-param-in-fn.rs:6:5 | LL | foo(); - | ^^^ cannot infer type for type parameter `T` declared on the function `foo` + | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | -help: type parameter declared here - --> $DIR/unbounded-type-param-in-fn.rs:1:8 +help: consider specifying the generic argument | -LL | fn foo<T>() -> T { - | ^ +LL | foo::<T>(); + | +++++ error: aborting due to previous error diff --git a/src/test/ui/type/type-annotation-needed.stderr b/src/test/ui/type/type-annotation-needed.stderr index 64fdbfe7db4..7d7890c8b80 100644 --- a/src/test/ui/type/type-annotation-needed.stderr +++ b/src/test/ui/type/type-annotation-needed.stderr @@ -2,19 +2,18 @@ error[E0283]: type annotations needed --> $DIR/type-annotation-needed.rs:6:5 | LL | foo(42); - | ^^^ cannot infer type for type parameter `T` declared on the function `foo` + | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | -help: type parameter declared here - --> $DIR/type-annotation-needed.rs:1:8 - | -LL | fn foo<T: Into<String>>(x: i32) {} - | ^ = note: cannot satisfy `_: Into<String>` note: required by a bound in `foo` --> $DIR/type-annotation-needed.rs:1:11 | LL | fn foo<T: Into<String>>(x: i32) {} | ^^^^^^^^^^^^ required by this bound in `foo` +help: consider specifying the generic argument + | +LL | foo::<T>(42); + | +++++ help: consider specifying the type argument in the function call | LL | foo::<T>(42); diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr index 8edec6e0ea3..d68d5e5d40b 100644 --- a/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr +++ b/src/test/ui/type/type-check/cannot_infer_local_or_array.stderr @@ -1,10 +1,13 @@ error[E0282]: type annotations needed for `[_; 0]` - --> $DIR/cannot_infer_local_or_array.rs:2:13 + --> $DIR/cannot_infer_local_or_array.rs:2:9 | LL | let x = []; - | - ^^ cannot infer type - | | - | consider giving `x` the explicit type `[_; 0]`, with the type parameters specified + | ^ + | +help: consider giving `x` an explicit type, where the placeholders `_` are specified + | +LL | let x: [_; 0] = []; + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr index 69a4af4672f..b63d2a3b61c 100644 --- a/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr +++ b/src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr @@ -1,12 +1,13 @@ error[E0282]: type annotations needed for `Vec<T>` - --> $DIR/cannot_infer_local_or_vec.rs:2:13 + --> $DIR/cannot_infer_local_or_vec.rs:2:9 | LL | let x = vec![]; - | - ^^^^^^ cannot infer type for type parameter `T` - | | - | consider giving `x` the explicit type `Vec<T>`, where the type parameter `T` is specified + | ^ | - = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider giving `x` an explicit type, where the type for type parameter `T` is specified + | +LL | let x: Vec<T> = vec![]; + | ++++++++ error: aborting due to previous error diff --git a/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr index af7db439704..be60cda68b9 100644 --- a/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr +++ b/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr @@ -1,12 +1,13 @@ error[E0282]: type annotations needed for `(Vec<T>,)` - --> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:18 + --> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:9 | LL | let (x, ) = (vec![], ); - | ----- ^^^^^^ cannot infer type for type parameter `T` - | | - | consider giving this pattern the explicit type `(Vec<T>,)`, where the type parameter `T` is specified + | ^^^^^ | - = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider giving this pattern a type, where the type for type parameter `T` is specified + | +LL | let (x, ): (Vec<T>,) = (vec![], ); + | +++++++++++ error: aborting due to previous error diff --git a/src/test/ui/type/type-check/unknown_type_for_closure.rs b/src/test/ui/type/type-check/unknown_type_for_closure.rs index 0089d86e340..167687c1871 100644 --- a/src/test/ui/type/type-check/unknown_type_for_closure.rs +++ b/src/test/ui/type/type-check/unknown_type_for_closure.rs @@ -11,7 +11,7 @@ fn infer_ty() { } fn ambig_return() { - let x = || -> Vec<_> { Vec::new() }; //~ ERROR type annotations needed for the closure `fn() -> Vec<_>` + let x = || -> Vec<_> { Vec::new() }; //~ ERROR type annotations needed } fn main() {} diff --git a/src/test/ui/type/type-check/unknown_type_for_closure.stderr b/src/test/ui/type/type-check/unknown_type_for_closure.stderr index c3accad5f25..9ae97f390d3 100644 --- a/src/test/ui/type/type-check/unknown_type_for_closure.stderr +++ b/src/test/ui/type/type-check/unknown_type_for_closure.stderr @@ -1,31 +1,36 @@ -error[E0282]: type annotations needed for `Vec<_>` - --> $DIR/unknown_type_for_closure.rs:2:14 +error[E0282]: type annotations needed + --> $DIR/unknown_type_for_closure.rs:2:13 | LL | let x = |b: Vec<_>| {}; - | ^ consider giving this closure parameter a type + | ^^^^^^^^^^^^^^ cannot infer type for struct `Vec<_>` error[E0282]: type annotations needed --> $DIR/unknown_type_for_closure.rs:6:14 | LL | let x = |_| {}; - | ^ consider giving this closure parameter a type + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | let x = |_: _| {}; + | +++ error[E0282]: type annotations needed --> $DIR/unknown_type_for_closure.rs:10:14 | LL | let x = |k: _| {}; - | ^ consider giving this closure parameter a type + | ^ cannot infer type -error[E0282]: type annotations needed for the closure `fn() -> Vec<_>` +error[E0282]: type annotations needed --> $DIR/unknown_type_for_closure.rs:14:28 | LL | let x = || -> Vec<_> { Vec::new() }; - | ^^^^^^^^ cannot infer type for type parameter `T` + | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec` | -help: give this closure an explicit return type without `_` placeholders +help: consider specifying the generic argument | -LL | let x = || -> Vec<_> { Vec::new() }; - | ~~~~~~ +LL | let x = || -> Vec<_> { Vec::<T>::new() }; + | +++++ error: aborting due to 4 previous errors diff --git a/src/test/ui/type/type-path-err-node-types.stderr b/src/test/ui/type/type-path-err-node-types.stderr index baf218243c4..c1ae10efac4 100644 --- a/src/test/ui/type/type-path-err-node-types.stderr +++ b/src/test/ui/type/type-path-err-node-types.stderr @@ -26,7 +26,12 @@ error[E0282]: type annotations needed --> $DIR/type-path-err-node-types.rs:23:14 | LL | let _ = |a, b: _| -> _ { 0 }; - | ^ consider giving this closure parameter a type + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | let _ = |a: _, b: _| -> _ { 0 }; + | +++ error: aborting due to 5 previous errors diff --git a/src/test/ui/typeck/issue-65611.stderr b/src/test/ui/typeck/issue-65611.stderr index e3c005a0593..5f831291a38 100644 --- a/src/test/ui/typeck/issue-65611.stderr +++ b/src/test/ui/typeck/issue-65611.stderr @@ -1,11 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/issue-65611.rs:59:20 + --> $DIR/issue-65611.rs:59:13 | LL | let x = buffer.last().unwrap().0.clone(); - | -------^^^^-- - | | | - | | cannot infer type for type parameter `T` - | this method call resolves to `Option<&T>` + | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` | = note: type must be known at this point diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.rs b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.rs index d03001f5237..25c2dbe196f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.rs @@ -6,6 +6,7 @@ fn a() { let mut closure0 = None; + //~^ ERROR type annotations needed let vec = vec![1, 2, 3]; loop { @@ -14,7 +15,6 @@ fn a() { match closure0.take() { Some(c) => { return c(); - //~^ ERROR type annotations needed } None => { } } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr index de20a38c447..666ab79b65c 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr @@ -1,13 +1,14 @@ error[E0282]: type annotations needed for `Option<T>` - --> $DIR/unboxed-closures-failed-recursive-fn-2.rs:16:32 + --> $DIR/unboxed-closures-failed-recursive-fn-2.rs:8:9 | LL | let mut closure0 = None; - | ------------ consider giving `closure0` the explicit type `Option<T>`, with the type parameters specified -... -LL | return c(); - | ^^^ cannot infer type + | ^^^^^^^^^^^^ | = note: type must be known at this point +help: consider giving `closure0` an explicit type, where the placeholders `_` are specified + | +LL | let mut closure0: Option<T> = None; + | +++++++++++ error: aborting due to previous error diff --git a/src/test/ui/unconstrained-none.stderr b/src/test/ui/unconstrained-none.stderr index fbd71bd091d..19ac74fdf58 100644 --- a/src/test/ui/unconstrained-none.stderr +++ b/src/test/ui/unconstrained-none.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/unconstrained-none.rs:4:5 | LL | 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 | None::<T>; + | +++++ error: aborting due to previous error diff --git a/src/test/ui/unconstrained-ref.stderr b/src/test/ui/unconstrained-ref.stderr index eb8ebb5165d..1df6d8b446d 100644 --- a/src/test/ui/unconstrained-ref.stderr +++ b/src/test/ui/unconstrained-ref.stderr @@ -2,7 +2,12 @@ error[E0282]: type annotations needed --> $DIR/unconstrained-ref.rs:6:5 | LL | S { o: &None }; - | ^ cannot infer type for type parameter `T` declared on the struct `S` + | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `S` + | +help: consider specifying the generic argument + | +LL | S::<T> { o: &None }; + | +++++ error: aborting due to previous error |
