diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index 16b0e96cde0fa..8b5255b8b1dcb 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -68,6 +68,7 @@ pub struct InferenceDiagnosticsData { pub struct InferenceDiagnosticsParentData { prefix: &'static str, name: String, + span: Span, } #[derive(Clone)] @@ -124,10 +125,12 @@ impl InferenceDiagnosticsParentData { ) -> Option { let parent_name = tcx.def_key(parent_def_id).disambiguated_data.data.get_opt_name()?.to_string(); + let span = tcx.def_span(parent_def_id); Some(InferenceDiagnosticsParentData { prefix: tcx.def_descr(parent_def_id), name: parent_name, + span, }) } @@ -423,16 +426,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { error_code: TypeAnnotationNeeded, ) -> Diag<'a> { let source_kind = "other"; - let source_name = ""; + let bad_error = arg_data.make_bad_error(span); + let source_name = &bad_error.name.clone(); let failure_span = None; let infer_subdiags = Vec::new(); let multi_suggestions = Vec::new(); - let bad_label = Some(arg_data.make_bad_error(span)); + let bad_label = Some(bad_error); match error_code { TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired { span, source_kind, source_name, + source_span: arg_data.parent.as_ref().map(|p| p.span), failure_span, infer_subdiags, multi_suggestions, @@ -442,6 +447,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { span, source_kind, source_name, + source_span: arg_data.parent.as_ref().map(|p| p.span), failure_span, infer_subdiags, multi_suggestions, @@ -451,6 +457,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { span, source_kind, source_name, + source_span: arg_data.parent.as_ref().map(|p| p.span), failure_span, infer_subdiags, multi_suggestions, @@ -677,6 +684,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { span, source_kind, source_name: &name, + source_span: arg_data.parent.as_ref().map(|p| p.span), failure_span, infer_subdiags, multi_suggestions, @@ -686,6 +694,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { span, source_kind, source_name: &name, + source_span: arg_data.parent.as_ref().map(|p| p.span), failure_span, infer_subdiags, multi_suggestions, @@ -695,6 +704,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { span, source_kind, source_name: &name, + source_span: arg_data.parent.as_ref().map(|p| p.span), failure_span, infer_subdiags, multi_suggestions, diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs index 34b9c9988f35c..528c5ed0b42d0 100644 --- a/compiler/rustc_trait_selection/src/errors.rs +++ b/compiler/rustc_trait_selection/src/errors.rs @@ -192,6 +192,8 @@ pub struct AnnotationRequired<'a> { pub span: Span, pub source_kind: &'static str, pub source_name: &'a str, + #[note("type must be known for type parameter in this")] + pub source_span: Option, #[label("type must be known at this point")] pub failure_span: Option, #[subdiagnostic] @@ -214,6 +216,8 @@ pub struct AmbiguousImpl<'a> { pub span: Span, pub source_kind: &'static str, pub source_name: &'a str, + #[note("type must be known for type parameter in this")] + pub source_span: Option, #[label("type must be known at this point")] pub failure_span: Option, #[subdiagnostic] @@ -236,6 +240,8 @@ pub struct AmbiguousReturn<'a> { pub span: Span, pub source_kind: &'static str, pub source_name: &'a str, + #[note("type must be known for type parameter in this")] + pub source_span: Option, #[label("type must be known at this point")] pub failure_span: Option, #[subdiagnostic] diff --git a/tests/ui/array-slice-vec/vector-no-ann.stderr b/tests/ui/array-slice-vec/vector-no-ann.stderr index 716971eb12045..c695dd41623c6 100644 --- a/tests/ui/array-slice-vec/vector-no-ann.stderr +++ b/tests/ui/array-slice-vec/vector-no-ann.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed for `Vec<_>` LL | let _foo = Vec::new(); | ^^^^ ---------- type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL help: consider giving `_foo` an explicit type, where the type for type parameter `T` is specified | LL | let _foo: Vec = Vec::new(); diff --git a/tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.current.stderr b/tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.current.stderr index eaa212c6ce8e3..e503eb3cf44c7 100644 --- a/tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.current.stderr +++ b/tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.current.stderr @@ -6,6 +6,11 @@ LL | impls(rigid); | | | cannot infer type of the type parameter `U` declared on the function `impls` | +note: type must be known for type parameter in this + --> $DIR/dedup-normalized-2-higher-ranked.rs:25:1 + | +LL | fn impls Bound<'b, U>, U>(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: cannot satisfy `for<'b>

::Rigid: Bound<'b, _>` note: required by a bound in `impls` --> $DIR/dedup-normalized-2-higher-ranked.rs:25:13 diff --git a/tests/ui/associated-type-bounds/duplicate-bound-err.stderr b/tests/ui/associated-type-bounds/duplicate-bound-err.stderr index e6bf93970d0a4..e9d942f9984e3 100644 --- a/tests/ui/associated-type-bounds/duplicate-bound-err.stderr +++ b/tests/ui/associated-type-bounds/duplicate-bound-err.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | iter::empty() | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/iter/sources/empty.rs:LL:COL help: consider specifying the generic argument | LL | iter::empty::() @@ -15,6 +17,8 @@ error[E0282]: type annotations needed LL | iter::empty() | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/iter/sources/empty.rs:LL:COL help: consider specifying the generic argument | LL | iter::empty::() @@ -26,6 +30,8 @@ error[E0282]: type annotations needed LL | iter::empty() | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/iter/sources/empty.rs:LL:COL help: consider specifying the generic argument | LL | iter::empty::() diff --git a/tests/ui/async-await/unresolved_type_param.stderr b/tests/ui/async-await/unresolved_type_param.stderr index b9fb9832086cd..0dcc63fd959e3 100644 --- a/tests/ui/async-await/unresolved_type_param.stderr +++ b/tests/ui/async-await/unresolved_type_param.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | bar().await; | ^^^ cannot infer type of the type parameter `T` declared on the function `bar` | +note: type must be known for type parameter in this + --> $DIR/unresolved_type_param.rs:6:1 + | +LL | async fn bar() -> () {} + | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | bar::().await; diff --git a/tests/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr b/tests/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr index 8799a2a0772f2..5306577c5147b 100644 --- a/tests/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr +++ b/tests/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr @@ -4,6 +4,12 @@ error[E0282]: type annotations needed LL | with_closure(|x: u32, y| {}); | ^ | +note: type must be known for type parameter in this + --> $DIR/expect-two-infer-vars-supply-ty-with-bound-region.rs:1:1 + | +LL | / fn with_closure(_: F) +LL | | where F: FnOnce(A, B) + | |_________________________^ help: consider giving this closure parameter an explicit type | LL | with_closure(|x: u32, y: /* Type */| {}); diff --git a/tests/ui/closures/issue-99565.stderr b/tests/ui/closures/issue-99565.stderr index e48f5106165b0..c2e7949a0bff9 100644 --- a/tests/ui/closures/issue-99565.stderr +++ b/tests/ui/closures/issue-99565.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | foo(|| {}); | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/issue-99565.rs:3:1 + | +LL | fn foo(_: U) {} + | ^^^^^^^^^^^^^^^^^^ help: consider specifying the generic arguments | LL | foo::(|| {}); diff --git a/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr index 286d662ab27e2..745e4f3b49741 100644 --- a/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -56,6 +56,11 @@ error[E0284]: type annotations needed LL | uwu(); | ^^^ cannot infer the value of the const parameter `N` declared on the function `uwu` | +note: type must be known for type parameter in this + --> $DIR/rp_impl_trait_fail.rs:16:1 + | +LL | fn uwu() -> impl Traitor { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `uwu` --> $DIR/rp_impl_trait_fail.rs:16:8 | diff --git a/tests/ui/const-generics/fn-const-param-infer.adt_const_params.stderr b/tests/ui/const-generics/fn-const-param-infer.adt_const_params.stderr index 54f3bff172af6..7468cc15a1dcb 100644 --- a/tests/ui/const-generics/fn-const-param-infer.adt_const_params.stderr +++ b/tests/ui/const-generics/fn-const-param-infer.adt_const_params.stderr @@ -19,6 +19,11 @@ error[E0282]: type annotations needed LL | let _ = Checked::; | ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `generic` | +note: type must be known for type parameter in this + --> $DIR/fn-const-param-infer.rs:22:1 + | +LL | fn generic(val: usize) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | let _ = Checked::>; diff --git a/tests/ui/const-generics/fn-const-param-infer.full.stderr b/tests/ui/const-generics/fn-const-param-infer.full.stderr index 54f3bff172af6..7468cc15a1dcb 100644 --- a/tests/ui/const-generics/fn-const-param-infer.full.stderr +++ b/tests/ui/const-generics/fn-const-param-infer.full.stderr @@ -19,6 +19,11 @@ error[E0282]: type annotations needed LL | let _ = Checked::; | ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `generic` | +note: type must be known for type parameter in this + --> $DIR/fn-const-param-infer.rs:22:1 + | +LL | fn generic(val: usize) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | let _ = Checked::>; diff --git a/tests/ui/const-generics/fn-const-param-infer.min.stderr b/tests/ui/const-generics/fn-const-param-infer.min.stderr index 5e08f71a26701..b7ccf25969a6c 100644 --- a/tests/ui/const-generics/fn-const-param-infer.min.stderr +++ b/tests/ui/const-generics/fn-const-param-infer.min.stderr @@ -21,6 +21,11 @@ error[E0282]: type annotations needed LL | let _ = Checked::; | ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `generic` | +note: type must be known for type parameter in this + --> $DIR/fn-const-param-infer.rs:22:1 + | +LL | fn generic(val: usize) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | let _ = Checked::>; diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.stderr b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.stderr index f9904c9d2e48f..9253d7db08d20 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-ok-infer-err.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | use_dyn(&()); | ^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `use_dyn` | +note: type must be known for type parameter in this + --> $DIR/dyn-compatibility-ok-infer-err.rs:14:1 + | +LL | fn use_dyn(v: &dyn Foo) where [u8; N + 1]: Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `use_dyn` --> $DIR/dyn-compatibility-ok-infer-err.rs:14:12 | diff --git a/tests/ui/const-generics/infer/cannot-infer-const-args.stderr b/tests/ui/const-generics/infer/cannot-infer-const-args.stderr index c349a50a83ffb..0fad577402679 100644 --- a/tests/ui/const-generics/infer/cannot-infer-const-args.stderr +++ b/tests/ui/const-generics/infer/cannot-infer-const-args.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | foo(); | ^^^ cannot infer the value of the const parameter `X` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/cannot-infer-const-args.rs:1:1 + | +LL | fn foo() -> usize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `foo` --> $DIR/cannot-infer-const-args.rs:1:8 | diff --git a/tests/ui/const-generics/infer/issue-77092.stderr b/tests/ui/const-generics/infer/issue-77092.stderr index 96f6496eca537..05cf2b873164e 100644 --- a/tests/ui/const-generics/infer/issue-77092.stderr +++ b/tests/ui/const-generics/infer/issue-77092.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | println!("{:?}", take_array_from_mut(&mut arr, i)); | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `take_array_from_mut` | +note: type must be known for type parameter in this + --> $DIR/issue-77092.rs:3:1 + | +LL | fn take_array_from_mut(data: &mut [T], start: usize) -> &mut [T; N] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `take_array_from_mut` --> $DIR/issue-77092.rs:3:27 | diff --git a/tests/ui/const-generics/infer/method-chain.stderr b/tests/ui/const-generics/infer/method-chain.stderr index 95044bb5203b3..dec58257229b1 100644 --- a/tests/ui/const-generics/infer/method-chain.stderr +++ b/tests/ui/const-generics/infer/method-chain.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | Foo.bar().bar().bar().bar().baz(); | ^^^ cannot infer the value of the const parameter `N` declared on the method `baz` | +note: type must be known for type parameter in this + --> $DIR/method-chain.rs:8:5 + | +LL | fn baz(self) -> Foo { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `Foo::baz` --> $DIR/method-chain.rs:8:12 | diff --git a/tests/ui/const-generics/infer/one-param-uninferred.stderr b/tests/ui/const-generics/infer/one-param-uninferred.stderr index f3aa7973e67d1..a78da09502918 100644 --- a/tests/ui/const-generics/infer/one-param-uninferred.stderr +++ b/tests/ui/const-generics/infer/one-param-uninferred.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | let _: [u8; 17] = foo(); | ^^^ cannot infer the value of the const parameter `M` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/one-param-uninferred.rs:2:1 + | +LL | fn foo() -> [u8; N] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `foo` --> $DIR/one-param-uninferred.rs:2:24 | diff --git a/tests/ui/const-generics/infer/uninferred-consts.stderr b/tests/ui/const-generics/infer/uninferred-consts.stderr index 839fb25c4e1e6..5d78ddf5cb07f 100644 --- a/tests/ui/const-generics/infer/uninferred-consts.stderr +++ b/tests/ui/const-generics/infer/uninferred-consts.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | Foo.foo(); | ^^^ cannot infer the value of the const parameter `A` declared on the method `foo` | +note: type must be known for type parameter in this + --> $DIR/uninferred-consts.rs:6:5 + | +LL | fn foo(self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `Foo::foo` --> $DIR/uninferred-consts.rs:6:12 | @@ -20,6 +25,11 @@ error[E0284]: type annotations needed LL | Foo.foo(); | ^^^ cannot infer the value of the const parameter `B` declared on the method `foo` | +note: type must be known for type parameter in this + --> $DIR/uninferred-consts.rs:6:5 + | +LL | fn foo(self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `Foo::foo` --> $DIR/uninferred-consts.rs:6:28 | diff --git a/tests/ui/const-generics/issues/issue-83249.stderr b/tests/ui/const-generics/issues/issue-83249.stderr index 2668348613a40..61330b7840b1c 100644 --- a/tests/ui/const-generics/issues/issue-83249.stderr +++ b/tests/ui/const-generics/issues/issue-83249.stderr @@ -6,6 +6,11 @@ LL | let _ = foo([0; 1]); | | | required by a bound introduced by this call | +note: type must be known for type parameter in this + --> $DIR/issue-83249.rs:12:1 + | +LL | fn foo(_: [u8; T::N]) -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `Foo` help: the trait `Foo` is implemented for `u8` --> $DIR/issue-83249.rs:8:1 diff --git a/tests/ui/const-generics/parent_generics_of_encoding_impl_trait.stderr b/tests/ui/const-generics/parent_generics_of_encoding_impl_trait.stderr index 4809f7d37dd31..0b07c2ca0918f 100644 --- a/tests/ui/const-generics/parent_generics_of_encoding_impl_trait.stderr +++ b/tests/ui/const-generics/parent_generics_of_encoding_impl_trait.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | generics_of_parent_impl_trait::foo([()]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/auxiliary/generics_of_parent_impl_trait.rs:5:1 + | +LL | pub fn foo(foo: impl Into<[(); N + 1]>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `foo` --> $DIR/auxiliary/generics_of_parent_impl_trait.rs:5:12 | diff --git a/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr index c80efd6df8a89..abbff837c4ef8 100644 --- a/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr +++ b/tests/ui/const-generics/try-from-with-const-genericsrs-98299.stderr @@ -6,6 +6,11 @@ LL | SmallCString::try_from(p).map(|cstr| cstr); | | | type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/try-from-with-const-genericsrs-98299.rs:9:1 + | +LL | pub struct SmallCString {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `SmallCString` --> $DIR/try-from-with-const-genericsrs-98299.rs:9:25 | diff --git a/tests/ui/const-generics/unify_with_nested_expr.stderr b/tests/ui/const-generics/unify_with_nested_expr.stderr index b1aecdb3cb5a7..6878eaa31326e 100644 --- a/tests/ui/const-generics/unify_with_nested_expr.stderr +++ b/tests/ui/const-generics/unify_with_nested_expr.stderr @@ -4,6 +4,13 @@ error[E0284]: type annotations needed LL | bar(); | ^^^ cannot infer the value of the const parameter `N` declared on the function `bar` | +note: type must be known for type parameter in this + --> $DIR/unify_with_nested_expr.rs:12:1 + | +LL | / fn bar() +LL | | where +LL | | [(); N + 1]:, + | |_________________^ note: required by a const generic parameter in `bar` --> $DIR/unify_with_nested_expr.rs:12:8 | diff --git a/tests/ui/consts/issue-64662.stderr b/tests/ui/consts/issue-64662.stderr index 21a419711a989..dfb8359a87f32 100644 --- a/tests/ui/consts/issue-64662.stderr +++ b/tests/ui/consts/issue-64662.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | A = foo(), | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/issue-64662.rs:6:1 + | +LL | const fn foo() -> isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | A = foo::(), @@ -15,6 +20,11 @@ error[E0282]: type annotations needed LL | B = foo(), | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/issue-64662.rs:6:1 + | +LL | const fn foo() -> isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | B = foo::(), diff --git a/tests/ui/delegation/generics/impl-to-trait-method.stderr b/tests/ui/delegation/generics/impl-to-trait-method.stderr index 74ccf61bea703..eaee8ee1c5cfc 100644 --- a/tests/ui/delegation/generics/impl-to-trait-method.stderr +++ b/tests/ui/delegation/generics/impl-to-trait-method.stderr @@ -51,6 +51,12 @@ error[E0282]: type annotations needed | LL | reuse Trait::foo { &self.0 } | ^^^ cannot infer type for type parameter `T` declared on the trait `Trait` + | +note: type must be known for type parameter in this + --> $DIR/impl-to-trait-method.rs:30:5 + | +LL | trait Trait { + | ^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/delegation/generics/trait-impl-wrong-args-count.stderr b/tests/ui/delegation/generics/trait-impl-wrong-args-count.stderr index 00dfedef47b5a..07e69b53c496d 100644 --- a/tests/ui/delegation/generics/trait-impl-wrong-args-count.stderr +++ b/tests/ui/delegation/generics/trait-impl-wrong-args-count.stderr @@ -31,6 +31,11 @@ error[E0284]: type annotations needed LL | reuse to_reuse::bar2; | ^^^^ cannot infer the value of the const parameter `X` declared on the function `bar2` | +note: type must be known for type parameter in this + --> $DIR/trait-impl-wrong-args-count.rs:9:9 + | +LL | pub fn bar2(x: &super::XX) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `bar2` --> $DIR/trait-impl-wrong-args-count.rs:9:39 | @@ -47,6 +52,11 @@ error[E0284]: type annotations needed LL | reuse to_reuse::bar2; | ^^^^ cannot infer the value of the const parameter `Y` declared on the function `bar2` | +note: type must be known for type parameter in this + --> $DIR/trait-impl-wrong-args-count.rs:9:9 + | +LL | pub fn bar2(x: &super::XX) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `bar2` --> $DIR/trait-impl-wrong-args-count.rs:9:55 | @@ -134,6 +144,12 @@ error[E0282]: type annotations needed | LL | reuse >::foo as bar2; | ^^^ cannot infer type of the type parameter `X` declared on the associated function `foo` + | +note: type must be known for type parameter in this + --> $DIR/trait-impl-wrong-args-count.rs:88:9 + | +LL | fn foo() {} + | ^^^^^^^^^^^^^^ error[E0107]: associated function takes at most 2 generic arguments but 3 generic arguments were supplied --> $DIR/trait-impl-wrong-args-count.rs:105:40 diff --git a/tests/ui/error-codes/E0283.stderr b/tests/ui/error-codes/E0283.stderr index 29baae5f133a2..fcd0f278caa4a 100644 --- a/tests/ui/error-codes/E0283.stderr +++ b/tests/ui/error-codes/E0283.stderr @@ -20,6 +20,8 @@ error[E0283]: type annotations needed LL | let bar = foo_impl.into() * 1u32; | ^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL note: multiple `impl`s satisfying `Impl: Into<_>` found --> $DIR/E0283.rs:17:1 | diff --git a/tests/ui/for-loop-while/for-loop-unconstrained-element-type.stderr b/tests/ui/for-loop-while/for-loop-unconstrained-element-type.stderr index 3b3fa6e7b5c66..265df8fe6b06e 100644 --- a/tests/ui/for-loop-while/for-loop-unconstrained-element-type.stderr +++ b/tests/ui/for-loop-while/for-loop-unconstrained-element-type.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | for i in Vec::new() {} | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec` | +note: type must be known for type parameter in this + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL help: consider specifying the generic argument | LL | for i in Vec::::new() {} diff --git a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.next.stderr b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.next.stderr index d6294efbd2803..933c7df0852cb 100644 --- a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.next.stderr +++ b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.next.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | cmp_eq | ^^^^^^ cannot infer type of the type parameter `A` declared on the function `cmp_eq` | +note: type must be known for type parameter in this + --> $DIR/ambig-hr-projection-issue-93340.rs:10:1 + | +LL | fn cmp_eq<'a, 'b, A: Scalar, B: Scalar, O: Scalar>(a: A::RefType<'a>, b: B::RefType<'b>) -> O { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic arguments | LL | cmp_eq:: diff --git a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.old.stderr b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.old.stderr index 58ed71fad4a66..5a52432caf4ff 100644 --- a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.old.stderr +++ b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.old.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed LL | cmp_eq | ^^^^^^ cannot infer type of the type parameter `A` declared on the function `cmp_eq` | +note: type must be known for type parameter in this + --> $DIR/ambig-hr-projection-issue-93340.rs:10:1 + | +LL | fn cmp_eq<'a, 'b, A: Scalar, B: Scalar, O: Scalar>(a: A::RefType<'a>, b: B::RefType<'b>) -> O { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `Scalar` note: required by a bound in `cmp_eq` --> $DIR/ambig-hr-projection-issue-93340.rs:10:22 diff --git a/tests/ui/generic-associated-types/bugs/issue-88382.stderr b/tests/ui/generic-associated-types/bugs/issue-88382.stderr index dcadd5ce8deb8..63b4354fc828c 100644 --- a/tests/ui/generic-associated-types/bugs/issue-88382.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-88382.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed LL | do_something(SomeImplementation(), test); | ^^^^ cannot infer type of the type parameter `I` declared on the function `test` | +note: type must be known for type parameter in this + --> $DIR/issue-88382.rs:29:1 + | +LL | fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `Iterable` help: the trait `Iterable` is implemented for `SomeImplementation` --> $DIR/issue-88382.rs:13:1 diff --git a/tests/ui/generic-associated-types/bugs/issue-91762.stderr b/tests/ui/generic-associated-types/bugs/issue-91762.stderr index b4ca65889ada0..267dfac697b13 100644 --- a/tests/ui/generic-associated-types/bugs/issue-91762.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-91762.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | ret = ::fmap(arg); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the associated function `fmap` | +note: type must be known for type parameter in this + --> $DIR/issue-91762.rs:13:5 + | +LL | fn fmap(this: Self::With) -> Self::With; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: cannot satisfy `<>::Base as Functor>::With<_> == Self` help: consider specifying the generic arguments | diff --git a/tests/ui/generic-const-items/inference-failure.stderr b/tests/ui/generic-const-items/inference-failure.stderr index 594743a47f424..cae620a017b7c 100644 --- a/tests/ui/generic-const-items/inference-failure.stderr +++ b/tests/ui/generic-const-items/inference-failure.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed for `Option<_>` LL | let _ = NONE; | ^ ---- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/inference-failure.rs:4:1 + | +LL | const NONE: Option = None::; + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving this pattern a type, where the type for type parameter `T` is specified | LL | let _: Option = NONE; @@ -14,6 +19,12 @@ error[E0282]: type annotations needed | LL | let _ = IGNORE; | ^^^^^^ cannot infer type for type parameter `T` declared on the constant `IGNORE` + | +note: type must be known for type parameter in this + --> $DIR/inference-failure.rs:5:1 + | +LL | const IGNORE: () = (); + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/generic-const-items/parameter-defaults.stderr b/tests/ui/generic-const-items/parameter-defaults.stderr index 9bf1f6412f59b..5ab06f7f98bf6 100644 --- a/tests/ui/generic-const-items/parameter-defaults.stderr +++ b/tests/ui/generic-const-items/parameter-defaults.stderr @@ -16,6 +16,11 @@ error[E0282]: type annotations needed for `Option<_>` LL | fn body0() { let _ = NONE; } | ^ ---- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/parameter-defaults.rs:10:1 + | +LL | const NONE: Option = None::; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving this pattern a type, where the type for type parameter `T` is specified | LL | fn body0() { let _: Option = NONE; } @@ -27,6 +32,11 @@ error[E0282]: type annotations needed for `Option<_>` LL | fn body1() { let _ = Host::NADA; } | ^ ---------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/parameter-defaults.rs:14:5 + | +LL | const NADA: Option = None::; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving this pattern a type, where the type for type parameter `T` is specified | LL | fn body1() { let _: Option = Host::NADA; } diff --git a/tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr b/tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr index b6c6e74f26052..d1895d20484b2 100644 --- a/tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr +++ b/tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr @@ -6,6 +6,11 @@ LL | if false { is_trait(foo()) } else { Default::default() } | | | cannot infer type of the type parameter `U` declared on the function `is_trait` | +note: type must be known for type parameter in this + --> $DIR/auto-trait-selection-freeze.rs:11:1 + | +LL | fn is_trait, U: Default>(_: T) -> U { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `impl Sized: Trait<_>` found --> $DIR/auto-trait-selection-freeze.rs:16:1 | diff --git a/tests/ui/impl-trait/auto-trait-selection.old.stderr b/tests/ui/impl-trait/auto-trait-selection.old.stderr index 8e44100177154..e33c2e388317b 100644 --- a/tests/ui/impl-trait/auto-trait-selection.old.stderr +++ b/tests/ui/impl-trait/auto-trait-selection.old.stderr @@ -6,6 +6,11 @@ LL | if false { is_trait(foo()) } else { Default::default() } | | | cannot infer type of the type parameter `U` declared on the function `is_trait` | +note: type must be known for type parameter in this + --> $DIR/auto-trait-selection.rs:7:1 + | +LL | fn is_trait, U: Default>(_: T) -> U { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `impl Sized: Trait<_>` found --> $DIR/auto-trait-selection.rs:12:1 | diff --git a/tests/ui/impl-trait/cross-return-site-inference.stderr b/tests/ui/impl-trait/cross-return-site-inference.stderr index 5512c234af985..f211e989c4401 100644 --- a/tests/ui/impl-trait/cross-return-site-inference.stderr +++ b/tests/ui/impl-trait/cross-return-site-inference.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | Ok(()) | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/result.rs:LL:COL help: consider specifying the generic arguments | LL | Ok::<(), E>(()) diff --git a/tests/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr b/tests/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr index 06b5ae6e3b01b..28d4d30f44433 100644 --- a/tests/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr +++ b/tests/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr @@ -3,6 +3,12 @@ error[E0282]: type annotations needed | LL | ().foo(|| ()) | ^^^ cannot infer type for type parameter `T` declared on the trait `Foo` + | +note: type must be known for type parameter in this + --> $DIR/fully-qualified-path-impl-trait.rs:1:1 + | +LL | trait Foo { + | ^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/fallback_inference.stderr b/tests/ui/impl-trait/fallback_inference.stderr index 4f8121ae879e6..1cd2accf30305 100644 --- a/tests/ui/impl-trait/fallback_inference.stderr +++ b/tests/ui/impl-trait/fallback_inference.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | PhantomData | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `PhantomData` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/marker.rs:LL:COL help: consider specifying the generic argument | LL | PhantomData:: diff --git a/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr b/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr index 14baf94598577..ee9d29b7b7694 100644 --- a/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr +++ b/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr @@ -4,6 +4,13 @@ error[E0283]: type annotations needed LL | ().publish_typed(); | ^^^^^^^^^^^^^ cannot infer type of the type parameter `F` declared on the method `publish_typed` | +note: type must be known for type parameter in this + --> $DIR/not-inferred-generic.rs:2:5 + | +LL | / fn publish_typed(&self) -> impl Sized +LL | | where +LL | | F: Clone; + | |_________________^ = note: the type must implement `Clone` = note: opaque types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` note: required by a bound in `TypedClient::publish_typed::{anon_assoc#0}` diff --git a/tests/ui/inference/cannot-infer-async.stderr b/tests/ui/inference/cannot-infer-async.stderr index 346109fd5c018..d824bb99a1db9 100644 --- a/tests/ui/inference/cannot-infer-async.stderr +++ b/tests/ui/inference/cannot-infer-async.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | Ok(()) | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/result.rs:LL:COL help: consider specifying the generic arguments | LL | Ok::<(), E>(()) diff --git a/tests/ui/inference/cannot-infer-closure-circular.stderr b/tests/ui/inference/cannot-infer-closure-circular.stderr index ee17f7737cf30..c9160d1ddabd6 100644 --- a/tests/ui/inference/cannot-infer-closure-circular.stderr +++ b/tests/ui/inference/cannot-infer-closure-circular.stderr @@ -7,6 +7,8 @@ LL | let v = r?; LL | Ok(v) | ----- type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/result.rs:LL:COL help: consider giving this closure parameter an explicit type, where the type for type parameter `E` is specified | LL | let x = |r: Result<_, E>| { diff --git a/tests/ui/inference/cannot-infer-closure.stderr b/tests/ui/inference/cannot-infer-closure.stderr index 507a70c1bac46..3a8304c7df768 100644 --- a/tests/ui/inference/cannot-infer-closure.stderr +++ b/tests/ui/inference/cannot-infer-closure.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | Ok(b) | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/result.rs:LL:COL help: consider specifying the generic arguments | LL | Ok::<(), E>(b) diff --git a/tests/ui/inference/dont-collect-stmts-from-parent-body.stderr b/tests/ui/inference/dont-collect-stmts-from-parent-body.stderr index f82527273fbee..f9bd6f8002aca 100644 --- a/tests/ui/inference/dont-collect-stmts-from-parent-body.stderr +++ b/tests/ui/inference/dont-collect-stmts-from-parent-body.stderr @@ -13,6 +13,11 @@ error[E0282]: type annotations needed LL | Type | ^^^^ cannot infer type of the type parameter `T` declared on the struct `Type` | +note: type must be known for type parameter in this + --> $DIR/dont-collect-stmts-from-parent-body.rs:3:1 + | +LL | struct Type; + | ^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | Type:: diff --git a/tests/ui/inference/erase-type-params-in-label.stderr b/tests/ui/inference/erase-type-params-in-label.stderr index 5056d63586861..69083ef7475a6 100644 --- a/tests/ui/inference/erase-type-params-in-label.stderr +++ b/tests/ui/inference/erase-type-params-in-label.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed for `Foo` LL | let foo = foo(1, ""); | ^^^ ---------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/erase-type-params-in-label.rs:25:1 + | +LL | fn foo(t: T, k: K) -> Foo { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `Default` note: required by a bound in `foo` --> $DIR/erase-type-params-in-label.rs:25:17 @@ -21,6 +26,11 @@ error[E0283]: type annotations needed for `Bar` LL | let bar = bar(1, ""); | ^^^ ---------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/erase-type-params-in-label.rs:14:1 + | +LL | fn bar(t: T, k: K) -> Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `Default` note: required by a bound in `bar` --> $DIR/erase-type-params-in-label.rs:14:17 diff --git a/tests/ui/inference/issue-104649.stderr b/tests/ui/inference/issue-104649.stderr index 27382e301341f..ecd72cf486343 100644 --- a/tests/ui/inference/issue-104649.stderr +++ b/tests/ui/inference/issue-104649.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed for `A $DIR/issue-104649.rs:1:1 + | +LL | type Result = ::std::result::Result; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving `a` an explicit type, where the type for type parameter `E` is specified | LL | let a: A, _>> = A(Result::Ok(Result::Ok(()))); diff --git a/tests/ui/inference/issue-12028.stderr b/tests/ui/inference/issue-12028.stderr index 0d8ef1c938d4c..c4906081a13f6 100644 --- a/tests/ui/inference/issue-12028.stderr +++ b/tests/ui/inference/issue-12028.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | self.input_stream(&mut stream); | ^^^^^^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/issue-12028.rs:20:1 + | +LL | trait StreamHash: Hash { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: cannot satisfy `<_ as StreamHasher>::S == ::S` help: try using a fully qualified path to specify the expected types | diff --git a/tests/ui/inference/issue-71732.stderr b/tests/ui/inference/issue-71732.stderr index e791316948560..96be307a49402 100644 --- a/tests/ui/inference/issue-71732.stderr +++ b/tests/ui/inference/issue-71732.stderr @@ -6,6 +6,8 @@ LL | .get(&"key".into()) | | | cannot infer type of the type parameter `Q` declared on the method `get` | +note: type must be known for type parameter in this + --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL = note: multiple `impl`s satisfying `String: Borrow<_>` found in the following crates: `alloc`, `core`: - impl Borrow for String; - impl Borrow for T diff --git a/tests/ui/inference/issue-72690.stderr b/tests/ui/inference/issue-72690.stderr index 4926cf9e981ba..4c5accc66752a 100644 --- a/tests/ui/inference/issue-72690.stderr +++ b/tests/ui/inference/issue-72690.stderr @@ -14,6 +14,8 @@ error[E0283]: type annotations needed LL | String::from("x".as_ref()); | ^^^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: - impl AsRef for str; - impl AsRef for str; @@ -42,6 +44,8 @@ error[E0283]: type annotations needed LL | |x| String::from("x".as_ref()); | ^^^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: - impl AsRef for str; - impl AsRef for str; @@ -60,6 +64,8 @@ error[E0283]: type annotations needed for `&_` LL | let _ = "x".as_ref(); | ^ ------ type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: - impl AsRef for str; - impl AsRef for str; @@ -87,6 +93,8 @@ error[E0283]: type annotations needed LL | String::from("x".as_ref()); | ^^^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: - impl AsRef for str; - impl AsRef for str; @@ -115,6 +123,8 @@ error[E0283]: type annotations needed LL | String::from("x".as_ref()); | ^^^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: - impl AsRef for str; - impl AsRef for str; @@ -143,6 +153,8 @@ error[E0283]: type annotations needed LL | String::from("x".as_ref()); | ^^^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: - impl AsRef for str; - impl AsRef for str; @@ -171,6 +183,8 @@ error[E0283]: type annotations needed LL | String::from("x".as_ref()); | ^^^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: - impl AsRef for str; - impl AsRef for str; @@ -199,6 +213,8 @@ error[E0283]: type annotations needed LL | String::from("x".as_ref()); | ^^^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: - impl AsRef for str; - impl AsRef for str; @@ -227,6 +243,8 @@ error[E0283]: type annotations needed LL | String::from("x".as_ref()); | ^^^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`: - impl AsRef for str; - impl AsRef for str; diff --git a/tests/ui/inference/issue-80816.rs b/tests/ui/inference/issue-80816.rs index 4d319b44987e2..c4004cfcec9ab 100644 --- a/tests/ui/inference/issue-80816.rs +++ b/tests/ui/inference/issue-80816.rs @@ -22,7 +22,7 @@ impl Deref for DirectDeref> { } } -pub trait Access { +pub trait Access { //~ NOTE: type must be known for type parameter in this type Guard: Deref; fn load(&self) -> Self::Guard { unimplemented!() @@ -30,7 +30,7 @@ pub trait Access { } impl, P: Deref> Access for P { //~^ NOTE: required for `Arc>>` to implement `Access<_>` - //~| NOTE unsatisfied trait bound introduced here + //~| NOTE: unsatisfied trait bound introduced here type Guard = A::Guard; } impl Access for ArcSwapAny { diff --git a/tests/ui/inference/issue-80816.stderr b/tests/ui/inference/issue-80816.stderr index bca7cd4c3adbb..70e44523e61c1 100644 --- a/tests/ui/inference/issue-80816.stderr +++ b/tests/ui/inference/issue-80816.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed LL | let guard: Guard> = s.load(); | ^^^^ | +note: type must be known for type parameter in this + --> $DIR/issue-80816.rs:25:1 + | +LL | pub trait Access { + | ^^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `ArcSwapAny>: Access<_>` found --> $DIR/issue-80816.rs:36:1 | diff --git a/tests/ui/inference/issue-83606.stderr b/tests/ui/inference/issue-83606.stderr index 97ccad9e785e3..b71a233e476ca 100644 --- a/tests/ui/inference/issue-83606.stderr +++ b/tests/ui/inference/issue-83606.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed for `[usize; _]` LL | let _ = foo("foo"); | ^ ---------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/issue-83606.rs:3:1 + | +LL | fn foo(_: impl std::fmt::Display) -> [usize; N] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a const generic parameter in `foo` --> $DIR/issue-83606.rs:3:8 | diff --git a/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr index c61ca699b0d35..acff1781c6948 100644 --- a/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr +++ b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | Err(MyError); | ^^^ cannot infer type of the type parameter `T` declared on the enum `Result` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/result.rs:LL:COL help: consider specifying the generic arguments | LL | Err::(MyError); @@ -15,6 +17,8 @@ error[E0282]: type annotations needed LL | Ok(()); | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/result.rs:LL:COL help: consider specifying the generic arguments | LL | Ok::<(), E>(()); @@ -68,6 +72,8 @@ error[E0282]: type annotations needed LL | Err(MyError); | ^^^ cannot infer type of the type parameter `T` declared on the enum `Result` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/result.rs:LL:COL help: consider specifying the generic arguments | LL | Err::(MyError); @@ -79,6 +85,13 @@ error[E0282]: type annotations needed LL | with_closure(|x: u32, y| {}); | ^ | +note: type must be known for type parameter in this + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:49:1 + | +LL | / fn with_closure(_: F) -> i32 +LL | | where +LL | | F: FnOnce(A, B), + | |____________________^ help: consider giving this closure parameter an explicit type | LL | with_closure(|x: u32, y: /* Type */| {}); diff --git a/tests/ui/inference/issue-86162-1.stderr b/tests/ui/inference/issue-86162-1.stderr index d36ea12f6f041..f2e7c2c9e6009 100644 --- a/tests/ui/inference/issue-86162-1.stderr +++ b/tests/ui/inference/issue-86162-1.stderr @@ -6,6 +6,11 @@ LL | foo(gen()); //<- Do not suggest `foo::()`! | | | required by a bound introduced by this call | +note: type must be known for type parameter in this + --> $DIR/issue-86162-1.rs:3:1 + | +LL | fn foo(x: impl Clone) {} + | ^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `Clone` note: required by a bound in `foo` --> $DIR/issue-86162-1.rs:3:16 diff --git a/tests/ui/inference/issue-86162-2.stderr b/tests/ui/inference/issue-86162-2.stderr index adbc585d46924..0314ba852c4fa 100644 --- a/tests/ui/inference/issue-86162-2.stderr +++ b/tests/ui/inference/issue-86162-2.stderr @@ -6,6 +6,11 @@ LL | Foo::bar(gen()); //<- Do not suggest `Foo::bar::()`! | | | required by a bound introduced by this call | +note: type must be known for type parameter in this + --> $DIR/issue-86162-2.rs:8:5 + | +LL | fn bar(x: impl Clone) {} + | ^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `Clone` note: required by a bound in `Foo::bar` --> $DIR/issue-86162-2.rs:8:20 diff --git a/tests/ui/inference/multiple-impl-apply.stderr b/tests/ui/inference/multiple-impl-apply.stderr index 1a81955e1e88c..2bc1886654656 100644 --- a/tests/ui/inference/multiple-impl-apply.stderr +++ b/tests/ui/inference/multiple-impl-apply.stderr @@ -4,6 +4,8 @@ error[E0283]: type annotations needed LL | let y = x.into(); | ^ ---- type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL note: multiple `impl`s satisfying `_: From` found --> $DIR/multiple-impl-apply.rs:14:1 | diff --git a/tests/ui/inference/need_type_info/channel.stderr b/tests/ui/inference/need_type_info/channel.stderr index e33ace0338d50..7f149b2f5617e 100644 --- a/tests/ui/inference/need_type_info/channel.stderr +++ b/tests/ui/inference/need_type_info/channel.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | channel(); | ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `channel` | +note: type must be known for type parameter in this + --> $SRC_DIR/std/src/sync/mpsc.rs:LL:COL help: consider specifying the generic argument | LL | channel::(); @@ -15,6 +17,8 @@ error[E0282]: type annotations needed LL | channel(); | ^^^^^^^ cannot infer type of the type parameter `T` declared on the function `channel` | +note: type must be known for type parameter in this + --> $SRC_DIR/std/src/sync/mpsc.rs:LL:COL help: consider specifying the generic argument | LL | channel::(); diff --git a/tests/ui/inference/need_type_info/expr-struct-type-relative-enum.stderr b/tests/ui/inference/need_type_info/expr-struct-type-relative-enum.stderr index dfbdc3266c56c..1147cb3381cbb 100644 --- a/tests/ui/inference/need_type_info/expr-struct-type-relative-enum.stderr +++ b/tests/ui/inference/need_type_info/expr-struct-type-relative-enum.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | needs_infer(); | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `needs_infer` | +note: type must be known for type parameter in this + --> $DIR/expr-struct-type-relative-enum.rs:7:1 + | +LL | fn needs_infer() {} + | ^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | needs_infer::(); diff --git a/tests/ui/inference/need_type_info/expr-struct-type-relative-gat.stderr b/tests/ui/inference/need_type_info/expr-struct-type-relative-gat.stderr index c72529f71c2a3..33d4f6828ec30 100644 --- a/tests/ui/inference/need_type_info/expr-struct-type-relative-gat.stderr +++ b/tests/ui/inference/need_type_info/expr-struct-type-relative-gat.stderr @@ -3,6 +3,12 @@ error[E0282]: type annotations needed | LL | Self::Output::Simple {}; | ^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the associated type `Output` + | +note: type must be known for type parameter in this + --> $DIR/expr-struct-type-relative-gat.rs:2:5 + | +LL | type Output; + | ^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/inference/need_type_info/expr-struct-type-relative.stderr b/tests/ui/inference/need_type_info/expr-struct-type-relative.stderr index 333c93859b57f..cedeed8a24060 100644 --- a/tests/ui/inference/need_type_info/expr-struct-type-relative.stderr +++ b/tests/ui/inference/need_type_info/expr-struct-type-relative.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | needs_infer(); | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `needs_infer` | +note: type must be known for type parameter in this + --> $DIR/expr-struct-type-relative.rs:9:1 + | +LL | fn needs_infer() {} + | ^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | needs_infer::(); diff --git a/tests/ui/inference/need_type_info/issue-103053.stderr b/tests/ui/inference/need_type_info/issue-103053.stderr index ed389393abc91..257070de43292 100644 --- a/tests/ui/inference/need_type_info/issue-103053.stderr +++ b/tests/ui/inference/need_type_info/issue-103053.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | None; | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/option.rs:LL:COL help: consider specifying the generic argument | LL | None::; diff --git a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr index bf67c10098d56..ec0c34bd80312 100644 --- a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr +++ b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr @@ -6,6 +6,11 @@ LL | (S {}).owo(None) | | | required by a bound introduced by this call | +note: type must be known for type parameter in this + --> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:6:5 + | +LL | fn owo(&self, _: Option<&impl T>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `T` note: required by a bound in `S::owo` --> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:6:35 diff --git a/tests/ui/inference/need_type_info/self-ty-in-path.stderr b/tests/ui/inference/need_type_info/self-ty-in-path.stderr index d651927788ea3..8f759a852d124 100644 --- a/tests/ui/inference/need_type_info/self-ty-in-path.stderr +++ b/tests/ui/inference/need_type_info/self-ty-in-path.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | Self::func_a(); | ^^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the associated function `func_a` | +note: type must be known for type parameter in this + --> $DIR/self-ty-in-path.rs:5:5 + | +LL | fn func_a() {} + | ^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | Self::func_a::(); diff --git a/tests/ui/inference/need_type_info/type-alias-indirect.stderr b/tests/ui/inference/need_type_info/type-alias-indirect.stderr index 535c0044aec03..dc510aaf7b38d 100644 --- a/tests/ui/inference/need_type_info/type-alias-indirect.stderr +++ b/tests/ui/inference/need_type_info/type-alias-indirect.stderr @@ -3,6 +3,12 @@ error[E0282]: type annotations needed | LL | IndirectAlias::new(); | ^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `IndirectAlias` + | +note: type must be known for type parameter in this + --> $DIR/type-alias-indirect.rs:12:1 + | +LL | type IndirectAlias = Ty>; + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/inference/need_type_info/type-alias.stderr b/tests/ui/inference/need_type_info/type-alias.stderr index 47393557828fd..c2e7bfbfc0aa1 100644 --- a/tests/ui/inference/need_type_info/type-alias.stderr +++ b/tests/ui/inference/need_type_info/type-alias.stderr @@ -3,18 +3,36 @@ error[E0282]: type annotations needed | LL | DirectAlias::new() | ^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `DirectAlias` + | +note: type must be known for type parameter in this + --> $DIR/type-alias.rs:10:1 + | +LL | type DirectAlias = Ty; + | ^^^^^^^^^^^^^^^^^^^ error[E0282]: type annotations needed --> $DIR/type-alias.rs:18:5 | LL | IndirectAlias::new(); | ^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `IndirectAlias` + | +note: type must be known for type parameter in this + --> $DIR/type-alias.rs:16:1 + | +LL | type IndirectAlias = Ty>; + | ^^^^^^^^^^^^^^^^^^^^^ error[E0282]: type annotations needed --> $DIR/type-alias.rs:32:5 | LL | DirectButWithDefaultAlias::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `DirectButWithDefaultAlias` + | +note: type must be known for type parameter in this + --> $DIR/type-alias.rs:30:1 + | +LL | type DirectButWithDefaultAlias = TyDefault; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/inference/question-mark-type-infer.stderr b/tests/ui/inference/question-mark-type-infer.stderr index b531d42ff93cf..8ff0cce5c5fd1 100644 --- a/tests/ui/inference/question-mark-type-infer.stderr +++ b/tests/ui/inference/question-mark-type-infer.stderr @@ -4,6 +4,8 @@ error[E0283]: type annotations needed LL | l.iter().map(f).collect()? | ^^^^^^^ cannot infer type of the type parameter `B` declared on the method `collect` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL = note: the type must implement `FromIterator>` note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL @@ -18,6 +20,8 @@ error[E0283]: type annotations needed LL | let x = l.iter().map(f).collect()?; | ^^^^^^^ cannot infer type of the type parameter `B` declared on the method `collect` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL = note: the type must implement `FromIterator>` note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL @@ -32,6 +36,8 @@ error[E0283]: type annotations needed LL | let x: Vec = l.iter().map(f).collect()?; | ^^^^^^^ cannot infer type of the type parameter `B` declared on the method `collect` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL = note: the type must implement `FromIterator>` note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL diff --git a/tests/ui/inference/question-mark-type-inference-in-chain.rs b/tests/ui/inference/question-mark-type-inference-in-chain.rs index f3e36b7c40167..086519c686a9d 100644 --- a/tests/ui/inference/question-mark-type-inference-in-chain.rs +++ b/tests/ui/inference/question-mark-type-inference-in-chain.rs @@ -42,6 +42,7 @@ pub fn error2(lines: &[&str]) -> Result> { //~^ ERROR: type annotations needed //~| NOTE: cannot infer type of the type parameter `B` //~| NOTE: the type must implement `FromIterator>` + //~| NOTE: type must be known for type parameter in this //~| NOTE: required by a bound in `collect` //~| HELP: consider specifying the generic argument tags.sort(); diff --git a/tests/ui/inference/question-mark-type-inference-in-chain.stderr b/tests/ui/inference/question-mark-type-inference-in-chain.stderr index af8a5c8aebadc..f3abb4095605f 100644 --- a/tests/ui/inference/question-mark-type-inference-in-chain.stderr +++ b/tests/ui/inference/question-mark-type-inference-in-chain.stderr @@ -18,6 +18,8 @@ error[E0283]: type annotations needed LL | let mut tags: Vec = lines.iter().map(|e| parse(e)).collect()?; | ^^^^^^^ cannot infer type of the type parameter `B` declared on the method `collect` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL = note: the type must implement `FromIterator>` note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL @@ -27,7 +29,7 @@ LL | let mut tags: Vec = lines.iter().map(|e| parse(e)).collect:: $DIR/question-mark-type-inference-in-chain.rs:53:20 + --> $DIR/question-mark-type-inference-in-chain.rs:54:20 | LL | let mut tags = lines.iter().map(|e| parse(e)).collect::>()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `Vec>` @@ -35,7 +37,7 @@ LL | let mut tags = lines.iter().map(|e| parse(e)).collect::>()?; = help: the nightly-only, unstable trait `Try` is not implemented for `Vec>` error[E0277]: a value of type `std::result::Result, AnotherError>` cannot be built from an iterator over elements of type `std::result::Result` - --> $DIR/question-mark-type-inference-in-chain.rs:72:20 + --> $DIR/question-mark-type-inference-in-chain.rs:73:20 | LL | .collect::>>()?; | ------- ^^^^^^^^^^^^^^^^^^^^ value of type `std::result::Result, AnotherError>` cannot be built from `std::iter::Iterator>` @@ -47,7 +49,7 @@ help: the trait `FromIterator>` is not implemented --> $SRC_DIR/core/src/result.rs:LL:COL = help: for that trait implementation, expected `AnotherError`, found `Error` note: the method call chain might not have had the expected associated types - --> $DIR/question-mark-type-inference-in-chain.rs:69:10 + --> $DIR/question-mark-type-inference-in-chain.rs:70:10 | LL | let mut tags = lines | ----- this expression has type `&[&str]` diff --git a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr index 5c4a1a7582931..0b3890d60dbb5 100644 --- a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr +++ b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed for `Result<_, (((..., ..., ..., ...), ... LL | let y = Err(x); | ^ ------ type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/result.rs:LL:COL = note: the full name for the type has been written to '$TEST_BUILD_DIR/really-long-type-in-let-binding-without-sufficient-type-info.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console help: consider giving `y` an explicit type, where the type for type parameter `T` is specified diff --git a/tests/ui/inference/useless-turbofish-suggestion.stderr b/tests/ui/inference/useless-turbofish-suggestion.stderr index 25b05801aa470..94aff59b46621 100644 --- a/tests/ui/inference/useless-turbofish-suggestion.stderr +++ b/tests/ui/inference/useless-turbofish-suggestion.stderr @@ -10,6 +10,11 @@ error[E0282]: type annotations needed LL | S.f(42); | ^ cannot infer type of the type parameter `B` declared on the method `f` | +note: type must be known for type parameter in this + --> $DIR/useless-turbofish-suggestion.rs:13:5 + | +LL | fn f(self, _a: A) -> B { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic arguments | LL | S.f::(42); diff --git a/tests/ui/issues/issue-17551.stderr b/tests/ui/issues/issue-17551.stderr index b9cb76fc298d9..50e6a1f27132e 100644 --- a/tests/ui/issues/issue-17551.stderr +++ b/tests/ui/issues/issue-17551.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed for `B<_>` LL | let foo = B(marker::PhantomData); | ^^^ ------------------- type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/marker.rs:LL:COL help: consider giving `foo` an explicit type, where the type for type parameter `T` is specified | LL | let foo: B = B(marker::PhantomData); diff --git a/tests/ui/issues/issue-23046.stderr b/tests/ui/issues/issue-23046.stderr index f70ac0c9f388a..f481f768a51fc 100644 --- a/tests/ui/issues/issue-23046.stderr +++ b/tests/ui/issues/issue-23046.stderr @@ -4,6 +4,12 @@ error[E0282]: type annotations needed for `Expr<'_, _>` LL | let ex = |x| { | ^ | +note: type must be known for type parameter in this + --> $DIR/issue-23046.rs:11:1 + | +LL | / pub fn let_<'var, VAR, F: for<'v> Fn(Expr<'v, VAR>) -> Expr<'v, VAR>> +LL | | (a: Expr<'var, VAR>, b: F) -> Expr<'var, VAR> { + | |____________________________________________________________________^ help: consider giving this closure parameter an explicit type, where the type for type parameter `VAR` is specified | LL | let ex = |x: Expr<'_, VAR>| { diff --git a/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr index a5f1b76702f57..8fa943578956d 100644 --- a/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr +++ b/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed for `Vec<_>` LL | let mut x = Vec::new(); | ^^^^^ ---------- type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL help: consider giving `x` an explicit type, where the type for type parameter `T` is specified | LL | let mut x: Vec = Vec::new(); diff --git a/tests/ui/missing/missing-items/missing-type-parameter.stderr b/tests/ui/missing/missing-items/missing-type-parameter.stderr index 658e2c8e85eed..a3a42047179fe 100644 --- a/tests/ui/missing/missing-items/missing-type-parameter.stderr +++ b/tests/ui/missing/missing-items/missing-type-parameter.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | foo(); | ^^^ cannot infer type of the type parameter `X` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/missing-type-parameter.rs:1:1 + | +LL | fn foo() { } + | ^^^^^^^^^^^ help: consider specifying the generic argument | LL | foo::(); diff --git a/tests/ui/parser/issue-12187-1.stderr b/tests/ui/parser/issue-12187-1.stderr index ee5d1c0b2f16b..c4b45a1890659 100644 --- a/tests/ui/parser/issue-12187-1.stderr +++ b/tests/ui/parser/issue-12187-1.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed for `&_` LL | let &v = new(); | ^^ ----- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/issue-12187-1.rs:1:1 + | +LL | fn new() -> &'static T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving this pattern a type, where the type for type parameter `T` is specified | LL | let &v: &_ = new(); diff --git a/tests/ui/parser/issue-12187-2.stderr b/tests/ui/parser/issue-12187-2.stderr index 67d18cf137be9..56bcf2380ac8e 100644 --- a/tests/ui/parser/issue-12187-2.stderr +++ b/tests/ui/parser/issue-12187-2.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed for `&_` LL | let &v = new(); | ^^ ----- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/issue-12187-2.rs:1:1 + | +LL | fn new<'r, T>() -> &'r T { + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving this pattern a type, where the type for type parameter `T` is specified | LL | let &v: &_ = new(); diff --git a/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr index 0cd7ebe7494ff..4b63615c531d2 100644 --- a/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr +++ b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed for `[Foo<{integer}>; _]` LL | let b = [Foo(PhantomData); _]; | ^ ---------------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/copy-check-deferred-after-fallback.rs:32:1 + | +LL | fn tie_and_make_goal>(_: &T, _: &[Foo; N]) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving `b` an explicit type, where the value of const parameter `N` is specified | LL | let b: [Foo<{integer}>; N] = [Foo(PhantomData); _]; diff --git a/tests/ui/repeat-expr/copy-check-inference-side-effects.stderr b/tests/ui/repeat-expr/copy-check-inference-side-effects.stderr index bf4ae9b60bb31..93d6532c5a49b 100644 --- a/tests/ui/repeat-expr/copy-check-inference-side-effects.stderr +++ b/tests/ui/repeat-expr/copy-check-inference-side-effects.stderr @@ -7,6 +7,11 @@ LL | LL | let b /* : [String; ?x] */ = ["string".to_string(); _]; | -------------------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/copy-check-inference-side-effects.rs:10:1 + | +LL | fn unify(_: &[Foo; 2], _: &[String; N]) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving `a` an explicit type, where the value of const parameter `N` is specified | LL | let a: [Foo; 2] /* : [Foo; 2] */ = [Foo::<_>; 2]; @@ -18,6 +23,11 @@ error[E0282]: type annotations needed for `[String; _]` LL | let b /* : [String; ?x] */ = ["string".to_string(); _]; | ^ -------------------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/copy-check-inference-side-effects.rs:10:1 + | +LL | fn unify(_: &[Foo; 2], _: &[String; N]) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving `b` an explicit type, where the value of const parameter `N` is specified | LL | let b: [_; N] /* : [String; ?x] */ = ["string".to_string(); _]; diff --git a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr index ba44beb76dbb7..9784d661c75fc 100644 --- a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr +++ b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr @@ -7,6 +7,11 @@ LL | LL | extract(x).max(2); | ---------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/copy-inference-side-effects-are-lazy.rs:12:1 + | +LL | fn extract(_: [Foo; N]) -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving `x` an explicit type, where the type for type parameter `T` is specified | LL | let x: [Foo; 2] = [Foo(PhantomData); 2]; diff --git a/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.stderr b/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.stderr index bf1e46e4ef829..4858070fee4cd 100644 --- a/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.stderr +++ b/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed for `&[Foo<_>; _]` LL | let x = &[Foo::<_>; _]; | ^ -------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/no-conservative-copy-impl-requirement.rs:10:1 + | +LL | fn unify(_: &[Foo; N]) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider giving `x` an explicit type, where the value of const parameter `N` is specified | LL | let x: &[Foo; N] = &[Foo::<_>; _]; diff --git a/tests/ui/return/tail-expr-as-potential-return.stderr b/tests/ui/return/tail-expr-as-potential-return.stderr index be3d4b5116f2d..2a498055f9806 100644 --- a/tests/ui/return/tail-expr-as-potential-return.stderr +++ b/tests/ui/return/tail-expr-as-potential-return.stderr @@ -53,6 +53,11 @@ error[E0282]: type annotations needed LL | Receiver.generic(); | ^^^^^^^ cannot infer type of the type parameter `T` declared on the method `generic` | +note: type must be known for type parameter in this + --> $DIR/tail-expr-as-potential-return.rs:54:5 + | +LL | fn generic(self) -> Option { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | Receiver.generic::(); diff --git a/tests/ui/span/type-annotations-needed-expr.stderr b/tests/ui/span/type-annotations-needed-expr.stderr index a548df052b822..144825c7b6309 100644 --- a/tests/ui/span/type-annotations-needed-expr.stderr +++ b/tests/ui/span/type-annotations-needed-expr.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | let _ = (vec![1,2,3]).into_iter().sum() as f64; | ^^^ cannot infer type of the type parameter `S` declared on the method `sum` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL help: consider specifying the generic argument | LL | let _ = (vec![1,2,3]).into_iter().sum::() as f64; diff --git a/tests/ui/suggestions/fn-needing-specified-return-type-param.stderr b/tests/ui/suggestions/fn-needing-specified-return-type-param.stderr index 47a7ac895bf69..8a83d04a20743 100644 --- a/tests/ui/suggestions/fn-needing-specified-return-type-param.stderr +++ b/tests/ui/suggestions/fn-needing-specified-return-type-param.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | let _ = f; | ^ cannot infer type of the type parameter `A` declared on the function `f` | +note: type must be known for type parameter in this + --> $DIR/fn-needing-specified-return-type-param.rs:1:1 + | +LL | fn f() -> A { unimplemented!() } + | ^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | let _ = f::; diff --git a/tests/ui/suggestions/types/into-inference-needs-type.stderr b/tests/ui/suggestions/types/into-inference-needs-type.stderr index 5fbc281072047..7f70c92f7d0e5 100644 --- a/tests/ui/suggestions/types/into-inference-needs-type.stderr +++ b/tests/ui/suggestions/types/into-inference-needs-type.stderr @@ -4,6 +4,8 @@ error[E0283]: type annotations needed LL | .into()?; | ^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: the type must implement `From, {closure@$DIR/into-inference-needs-type.rs:10:14: 10:17}>, fn(Option<&str>) -> Option> {Option::>::Some}>>` = note: required for `FilterMap, {closure@$DIR/into-inference-needs-type.rs:10:14: 10:17}>, fn(Option<&str>) -> Option> {Option::>::Some}>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types diff --git a/tests/ui/trait-bounds/argument-with-unnecessary-method-call.stderr b/tests/ui/trait-bounds/argument-with-unnecessary-method-call.stderr index 870a865f02dd6..b6479c08ec107 100644 --- a/tests/ui/trait-bounds/argument-with-unnecessary-method-call.stderr +++ b/tests/ui/trait-bounds/argument-with-unnecessary-method-call.stderr @@ -6,6 +6,11 @@ LL | qux(Bar.into()); | | | required by a bound introduced by this call | +note: type must be known for type parameter in this + --> $DIR/argument-with-unnecessary-method-call.rs:6:1 + | +LL | fn qux(_: impl From) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `From` note: required by a bound in `qux` --> $DIR/argument-with-unnecessary-method-call.rs:6:16 diff --git a/tests/ui/trait-bounds/projection-predicate-not-satisfied-69455.stderr b/tests/ui/trait-bounds/projection-predicate-not-satisfied-69455.stderr index 48b3ba7061be3..4d608755a9263 100644 --- a/tests/ui/trait-bounds/projection-predicate-not-satisfied-69455.stderr +++ b/tests/ui/trait-bounds/projection-predicate-not-satisfied-69455.stderr @@ -6,6 +6,11 @@ LL | println!("{}", 23u64.test(xs.iter().sum())); | | | type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/projection-predicate-not-satisfied-69455.rs:5:1 + | +LL | pub trait Test { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: cannot satisfy `>::Output == _` help: consider specifying the generic argument | @@ -20,6 +25,11 @@ LL | println!("{}", 23u64.test(xs.iter().sum())); | | | required by a bound introduced by this call | +note: type must be known for type parameter in this + --> $DIR/projection-predicate-not-satisfied-69455.rs:5:1 + | +LL | pub trait Test { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `u64: Test<_>` found --> $DIR/projection-predicate-not-satisfied-69455.rs:11:1 | diff --git a/tests/ui/traits/copy-guessing.stderr b/tests/ui/traits/copy-guessing.stderr index cae91579ee0eb..0aba1cb2918b1 100644 --- a/tests/ui/traits/copy-guessing.stderr +++ b/tests/ui/traits/copy-guessing.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed for `Option<_>` LL | let n = None; | ^ ---- type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/option.rs:LL:COL help: consider giving `n` an explicit type, where the type for type parameter `T` is specified | LL | let n: Option = None; diff --git a/tests/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr b/tests/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr index 139488d79f13b..73559809a28b3 100644 --- a/tests/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr +++ b/tests/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed LL | thing.method(42); | ^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:3:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:7:1 | diff --git a/tests/ui/traits/issue-77982.stderr b/tests/ui/traits/issue-77982.stderr index b1baabc4394b0..3a5affd107188 100644 --- a/tests/ui/traits/issue-77982.stderr +++ b/tests/ui/traits/issue-77982.stderr @@ -6,6 +6,8 @@ LL | opts.get(opt.as_ref()); | | | cannot infer type of the type parameter `Q` declared on the method `get` | +note: type must be known for type parameter in this + --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL = note: multiple `impl`s satisfying `String: Borrow<_>` found in the following crates: `alloc`, `core`: - impl Borrow for String; - impl Borrow for T @@ -25,6 +27,8 @@ LL | opts.get(opt.as_ref()); | | | cannot infer type of the type parameter `Q` declared on the method `get` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `String: AsRef<_>` found in the following crates: `alloc`, `std`: - impl AsRef for String; - impl AsRef for String; @@ -43,6 +47,8 @@ LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect( | | | type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: multiple `impl`s satisfying `u32: From<_>` found in the `core` crate: - impl From for u32; - impl From for u32; @@ -62,6 +68,11 @@ error[E0283]: type annotations needed for `Box<_>` LL | let _ = ().foo(); | ^ --- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/issue-77982.rs:20:1 + | +LL | trait Foo<'a, T: ?Sized> { + | ^^^^^^^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `(): Foo<'_, _>` found --> $DIR/issue-77982.rs:32:1 | @@ -80,6 +91,11 @@ error[E0283]: type annotations needed for `Box<_>` LL | let _ = (&()).bar(); | ^ --- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/issue-77982.rs:26:1 + | +LL | trait Bar<'a, T: ?Sized> { + | ^^^^^^^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `&(): Bar<'_, _>` found --> $DIR/issue-77982.rs:35:1 | diff --git a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr index 12984c7936c9a..7aba83402ba63 100644 --- a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr +++ b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr @@ -6,6 +6,12 @@ LL | test(22, std::default::Default::default()); | | | cannot infer type of the type parameter `U` declared on the function `test` | +note: type must be known for type parameter in this + --> $DIR/multidispatch-convert-ambig-dest.rs:20:1 + | +LL | / fn test(_: T, _: U) +LL | | where T : Convert + | |____________________^ note: multiple `impl`s satisfying `i32: Convert<_>` found --> $DIR/multidispatch-convert-ambig-dest.rs:8:1 | diff --git a/tests/ui/traits/next-solver/well-formed-in-relate.stderr b/tests/ui/traits/next-solver/well-formed-in-relate.stderr index 264ab9bebbb92..16c3119dfd239 100644 --- a/tests/ui/traits/next-solver/well-formed-in-relate.stderr +++ b/tests/ui/traits/next-solver/well-formed-in-relate.stderr @@ -7,6 +7,11 @@ LL | let x; LL | x = unconstrained_map(); | ------------------- type must be known at this point | +note: type must be known for type parameter in this + --> $DIR/well-formed-in-relate.rs:21:1 + | +LL | fn unconstrained_map U, U>() -> as Mirror>::Assoc { todo!() } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: multiple `impl`s satisfying `_: Fn()` found in the following crates: `alloc`, `core`: - impl Fn for &F where A: std::marker::Tuple, F: Fn, F: ?Sized; diff --git a/tests/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr b/tests/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr index 7a2db203ac3f8..a46f7a269fef4 100644 --- a/tests/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr +++ b/tests/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed LL | a.method(); | ^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:8:1 + | +LL | trait V { + | ^^^^^^^^^^ note: multiple `impl`s satisfying `B: I<_>` found --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:5:1 | diff --git a/tests/ui/traits/overflow-computing-ambiguity.stderr b/tests/ui/traits/overflow-computing-ambiguity.stderr index f52f2e60757cc..564c4245102a3 100644 --- a/tests/ui/traits/overflow-computing-ambiguity.stderr +++ b/tests/ui/traits/overflow-computing-ambiguity.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed LL | hello(); | ^^^^^ cannot infer type of the type parameter `T` declared on the function `hello` | +note: type must be known for type parameter in this + --> $DIR/overflow-computing-ambiguity.rs:12:1 + | +LL | fn hello() {} + | ^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `Hello` help: the following types implement trait `Hello` --> $DIR/overflow-computing-ambiguity.rs:8:1 diff --git a/tests/ui/traits/suggest-fully-qualified-closure.stderr b/tests/ui/traits/suggest-fully-qualified-closure.stderr index 8975d04d5b3ed..2e1662d3f97fd 100644 --- a/tests/ui/traits/suggest-fully-qualified-closure.stderr +++ b/tests/ui/traits/suggest-fully-qualified-closure.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed LL | q.lol(||()); | ^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-closure.rs:6:1 + | +LL | trait MyTrait { + | ^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Qqq: MyTrait<_>` found --> $DIR/suggest-fully-qualified-closure.rs:12:1 | diff --git a/tests/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr b/tests/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr index 0996227e69701..cd5f7ad3b6ca0 100644 --- a/tests/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr +++ b/tests/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed LL | thing.method(); | ^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 | @@ -24,6 +29,11 @@ error[E0283]: type annotations needed LL | thing.mut_method(); | ^^^^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 | @@ -44,6 +54,11 @@ error[E0283]: type annotations needed LL | thing.by_self(); | ^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:19:1 + | +LL | trait MethodRef { + | ^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:22:1 | @@ -64,6 +79,11 @@ error[E0283]: type annotations needed LL | deref_to.method(); | ^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 | @@ -84,6 +104,11 @@ error[E0283]: type annotations needed LL | deref_to.mut_method(); | ^^^^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 | @@ -104,6 +129,11 @@ error[E0283]: type annotations needed LL | deref_to.by_self(); | ^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:19:1 + | +LL | trait MethodRef { + | ^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:22:1 | @@ -124,6 +154,11 @@ error[E0283]: type annotations needed LL | deref_deref_to.method(); | ^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 | @@ -144,6 +179,11 @@ error[E0283]: type annotations needed LL | deref_deref_to.mut_method(); | ^^^^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:10:1 | @@ -164,6 +204,11 @@ error[E0283]: type annotations needed LL | deref_deref_to.by_self(); | ^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:19:1 + | +LL | trait MethodRef { + | ^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:22:1 | diff --git a/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr b/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr index 629904815f312..213ebfa6d2afc 100644 --- a/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr +++ b/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr @@ -4,6 +4,11 @@ error[E0283]: type annotations needed LL | ref_thing.method(); | ^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 | @@ -24,6 +29,11 @@ error[E0283]: type annotations needed LL | ref_thing.by_self(); | ^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:20:1 + | +LL | trait MethodRef { + | ^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1 | @@ -44,6 +54,11 @@ error[E0283]: type annotations needed LL | mut_thing.method(); | ^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 | @@ -64,6 +79,11 @@ error[E0283]: type annotations needed LL | mut_thing.mut_method(); | ^^^^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 | @@ -84,6 +104,11 @@ error[E0283]: type annotations needed LL | mut_thing.by_self(); | ^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:20:1 + | +LL | trait MethodRef { + | ^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1 | @@ -104,6 +129,11 @@ error[E0283]: type annotations needed LL | deref_to.method(); | ^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 | @@ -124,6 +154,11 @@ error[E0283]: type annotations needed LL | deref_to.mut_method(); | ^^^^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 | @@ -144,6 +179,11 @@ error[E0283]: type annotations needed LL | deref_to.by_self(); | ^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:20:1 + | +LL | trait MethodRef { + | ^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1 | @@ -164,6 +204,11 @@ error[E0283]: type annotations needed LL | deref_deref_to.method(); | ^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 | @@ -184,6 +229,11 @@ error[E0283]: type annotations needed LL | deref_deref_to.mut_method(); | ^^^^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:5:1 + | +LL | trait Method { + | ^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `Thing: Method<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:10:1 | @@ -204,6 +254,11 @@ error[E0283]: type annotations needed LL | deref_deref_to.by_self(); | ^^^^^^^ | +note: type must be known for type parameter in this + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:20:1 + | +LL | trait MethodRef { + | ^^^^^^^^^^^^^^^^^^ note: multiple `impl`s satisfying `&Thing: MethodRef<_>` found --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:23:1 | diff --git a/tests/ui/type-alias-impl-trait/incomplete-inference.stderr b/tests/ui/type-alias-impl-trait/incomplete-inference.stderr index 0b2bac0a153f9..dca3437ccd1fe 100644 --- a/tests/ui/type-alias-impl-trait/incomplete-inference.stderr +++ b/tests/ui/type-alias-impl-trait/incomplete-inference.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | None | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/option.rs:LL:COL help: consider specifying the generic argument | LL | None:: diff --git a/tests/ui/type-inference/or_else-multiple-type-params.stderr b/tests/ui/type-inference/or_else-multiple-type-params.stderr index 9bcd07f8bf164..ac24007bda85d 100644 --- a/tests/ui/type-inference/or_else-multiple-type-params.stderr +++ b/tests/ui/type-inference/or_else-multiple-type-params.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed for `Result` LL | .or_else(|err| { | ^^^^^ | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/result.rs:LL:COL help: try giving this closure an explicit return type | LL | .or_else(|err| -> Result<_, F> { diff --git a/tests/ui/type-inference/send-with-unspecified-type.stderr b/tests/ui/type-inference/send-with-unspecified-type.stderr index 85692e8ad0cd9..c3564173c992c 100644 --- a/tests/ui/type-inference/send-with-unspecified-type.stderr +++ b/tests/ui/type-inference/send-with-unspecified-type.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | tx.send(Foo{ foo: PhantomData }); | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `PhantomData` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/marker.rs:LL:COL help: consider specifying the generic argument | LL | tx.send(Foo{ foo: PhantomData:: }); diff --git a/tests/ui/type-inference/sort_by_key.stderr b/tests/ui/type-inference/sort_by_key.stderr index 74d89b2459f95..e107dd2945c94 100644 --- a/tests/ui/type-inference/sort_by_key.stderr +++ b/tests/ui/type-inference/sort_by_key.stderr @@ -6,6 +6,8 @@ LL | lst.sort_by_key(|&(v, _)| v.iter().sum()); | | | type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/alloc/src/slice.rs:LL:COL = note: the type must implement `Ord` note: required by a bound in `slice::::sort_by_key` --> $SRC_DIR/alloc/src/slice.rs:LL:COL diff --git a/tests/ui/type-inference/type-inference-none-in-generic-ref.stderr b/tests/ui/type-inference/type-inference-none-in-generic-ref.stderr index d671c189b3730..fbc7acfe85db2 100644 --- a/tests/ui/type-inference/type-inference-none-in-generic-ref.stderr +++ b/tests/ui/type-inference/type-inference-none-in-generic-ref.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | S { o: &None }; | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `S` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/option.rs:LL:COL help: consider specifying the generic argument | LL | S:: { o: &None }; diff --git a/tests/ui/type-inference/type-inference-unconstrained-none.stderr b/tests/ui/type-inference/type-inference-unconstrained-none.stderr index 54260c03b76a1..b2891408a839f 100644 --- a/tests/ui/type-inference/type-inference-unconstrained-none.stderr +++ b/tests/ui/type-inference/type-inference-unconstrained-none.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | format!("{:?}", None); | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/option.rs:LL:COL help: consider specifying the generic argument | LL | format!("{:?}", None::); @@ -15,6 +17,8 @@ error[E0282]: type annotations needed LL | None; | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/option.rs:LL:COL help: consider specifying the generic argument | LL | None::; diff --git a/tests/ui/type-inference/unbounded-associated-type.stderr b/tests/ui/type-inference/unbounded-associated-type.stderr index c9dfa0bf587f7..2869d758b4e0f 100644 --- a/tests/ui/type-inference/unbounded-associated-type.stderr +++ b/tests/ui/type-inference/unbounded-associated-type.stderr @@ -4,6 +4,8 @@ error[E0282]: type annotations needed LL | S(std::marker::PhantomData).foo(); | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `PhantomData` | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/marker.rs:LL:COL help: consider specifying the generic argument | LL | S(std::marker::PhantomData::).foo(); diff --git a/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr b/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr index e8bbdaaacbf72..396b3c4587a92 100644 --- a/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr +++ b/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | foo(); | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/unbounded-type-param-in-fn-with-assoc-type.rs:3:1 + | +LL | fn foo() -> (T, U) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying the generic arguments | LL | foo::(); diff --git a/tests/ui/type-inference/unbounded-type-param-in-fn.stderr b/tests/ui/type-inference/unbounded-type-param-in-fn.stderr index 31e6e805e6c9d..e83a5b7b8f9e6 100644 --- a/tests/ui/type-inference/unbounded-type-param-in-fn.stderr +++ b/tests/ui/type-inference/unbounded-type-param-in-fn.stderr @@ -4,6 +4,11 @@ error[E0282]: type annotations needed LL | foo(); | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/unbounded-type-param-in-fn.rs:1:1 + | +LL | fn foo() -> T { + | ^^^^^^^^^^^^^^^^ help: consider specifying the generic argument | LL | foo::(); diff --git a/tests/ui/type/type-annotation-needed.rs b/tests/ui/type/type-annotation-needed.rs index a063ad77742a1..783c46d10d0ca 100644 --- a/tests/ui/type/type-annotation-needed.rs +++ b/tests/ui/type/type-annotation-needed.rs @@ -1,6 +1,7 @@ fn foo>(x: i32) {} //~^ NOTE required by //~| NOTE required by +//~| NOTE type must be known for type parameter in this fn main() { foo(42); diff --git a/tests/ui/type/type-annotation-needed.stderr b/tests/ui/type/type-annotation-needed.stderr index 78726643a3ab0..b72c382044e9b 100644 --- a/tests/ui/type/type-annotation-needed.stderr +++ b/tests/ui/type/type-annotation-needed.stderr @@ -1,9 +1,14 @@ error[E0283]: type annotations needed - --> $DIR/type-annotation-needed.rs:6:5 + --> $DIR/type-annotation-needed.rs:7:5 | LL | foo(42); | ^^^ cannot infer type of the type parameter `T` declared on the function `foo` | +note: type must be known for type parameter in this + --> $DIR/type-annotation-needed.rs:1:1 + | +LL | fn foo>(x: i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the type must implement `Into` note: required by a bound in `foo` --> $DIR/type-annotation-needed.rs:1:11 diff --git a/tests/ui/type/type-check/unknown_type_for_closure.stderr b/tests/ui/type/type-check/unknown_type_for_closure.stderr index 387ba4db9d30f..11be4f3b8bc38 100644 --- a/tests/ui/type/type-check/unknown_type_for_closure.stderr +++ b/tests/ui/type/type-check/unknown_type_for_closure.stderr @@ -27,6 +27,8 @@ error[E0282]: type annotations needed LL | let x = || -> Vec<_> { Vec::new() }; | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec` | +note: type must be known for type parameter in this + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL help: consider specifying the generic argument | LL | let x = || -> Vec<_> { Vec::::new() }; diff --git a/tests/ui/typeck/type-inference-for-associated-types-69683.stderr b/tests/ui/typeck/type-inference-for-associated-types-69683.stderr index 5d49d442c55d0..4a3d6a2b8d334 100644 --- a/tests/ui/typeck/type-inference-for-associated-types-69683.stderr +++ b/tests/ui/typeck/type-inference-for-associated-types-69683.stderr @@ -4,6 +4,11 @@ error[E0284]: type annotations needed LL | 0u16.foo(b); | ^^^ | +note: type must be known for type parameter in this + --> $DIR/type-inference-for-associated-types-69683.rs:14:1 + | +LL | trait Foo + | ^^^^^^^^^^^^ = note: cannot satisfy `>::Array == [u8; 3]` help: try using a fully qualified path to specify the expected types | @@ -17,6 +22,11 @@ error[E0283]: type annotations needed LL | 0u16.foo(b); | ^^^ | +note: type must be known for type parameter in this + --> $DIR/type-inference-for-associated-types-69683.rs:14:1 + | +LL | trait Foo + | ^^^^^^^^^^^^ note: multiple `impl`s satisfying `u8: Element<_>` found --> $DIR/type-inference-for-associated-types-69683.rs:6:1 | diff --git a/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr b/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr index 6860b0b2f7ee5..f8cf41dc3e2e3 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr @@ -7,6 +7,8 @@ LL | let mut closure0 = None; LL | return c(); | - type must be known at this point | +note: type must be known for type parameter in this + --> $SRC_DIR/core/src/option.rs:LL:COL help: consider giving `closure0` an explicit type, where the type for type parameter `T` is specified | LL | let mut closure0: Option = None;