From 479ce39939014f0071f8600fa4ce150e33cb7d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 25 Aug 2019 21:58:59 -0700 Subject: [PATCH] Add explanation to type mismatch involving type params and assoc types --- src/librustc/traits/mod.rs | 10 +- src/librustc/traits/util.rs | 25 +++-- src/librustc/ty/error.rs | 96 ++++++++++++++++++- ...ssociated-const-generic-obligations.stderr | 2 + .../associated-types-eq-3.stderr | 2 + .../associated-types-issue-20346.stderr | 2 + ...ated-types-multiple-types-one-trait.stderr | 4 + .../reordered-type-param.stderr | 2 + src/test/ui/hrtb/issue-62203-hrtb-ice.stderr | 2 + .../bound-normalization-fail.stderr | 4 + src/test/ui/impl-trait/equality2.stderr | 2 + .../impl-generic-mismatch-ab.stderr | 2 + .../universal-mismatched-type.stderr | 2 + .../universal-two-impl-traits.stderr | 2 + src/test/ui/issues/issue-13853.stderr | 2 + src/test/ui/issues/issue-20225.stderr | 6 ++ src/test/ui/issues/issue-24204.stderr | 1 + src/test/ui/issues/issue-2951.stderr | 2 + src/test/ui/issues/issue-32323.stderr | 2 + .../ui/mismatched_types/issue-35030.stderr | 2 + .../specialization-default-projection.stderr | 4 + .../specialization-default-types.stderr | 4 + .../struct-path-self-type-mismatch.stderr | 4 + .../enum-variant-generic-args.stderr | 12 +++ src/test/ui/type/type-parameter-names.stderr | 2 + .../type-params-in-different-spaces-1.stderr | 2 + .../type-params-in-different-spaces-3.stderr | 2 + 27 files changed, 180 insertions(+), 22 deletions(-) diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index d2683090add..7154962b592 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -655,11 +655,11 @@ pub struct VtableTraitAliasData<'tcx, N> { } /// Creates predicate obligations from the generic bounds. -pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, - param_env: ty::ParamEnv<'tcx>, - generic_bounds: &ty::InstantiatedPredicates<'tcx>) - -> PredicateObligations<'tcx> -{ +pub fn predicates_for_generics<'tcx>( + cause: ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + generic_bounds: &ty::InstantiatedPredicates<'tcx>, +) -> PredicateObligations<'tcx> { util::predicates_for_generics(cause, 0, param_env, generic_bounds) } diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 3d36790c94b..3e5520dd465 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -513,20 +513,19 @@ pub fn impl_trait_ref_and_oblig<'a, 'tcx>( } /// See [`super::obligations_for_generics`]. -pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, - recursion_depth: usize, - param_env: ty::ParamEnv<'tcx>, - generic_bounds: &ty::InstantiatedPredicates<'tcx>) - -> Vec> -{ - debug!("predicates_for_generics(generic_bounds={:?})", - generic_bounds); +pub fn predicates_for_generics<'tcx>( + cause: ObligationCause<'tcx>, + recursion_depth: usize, + param_env: ty::ParamEnv<'tcx>, + generic_bounds: &ty::InstantiatedPredicates<'tcx>, +) -> Vec> { + debug!("predicates_for_generics(generic_bounds={:?})", generic_bounds); - generic_bounds.predicates.iter().map(|predicate| { - Obligation { cause: cause.clone(), - recursion_depth, - param_env, - predicate: predicate.clone() } + generic_bounds.predicates.iter().map(|predicate| Obligation { + cause: cause.clone(), + recursion_depth, + param_env, + predicate: predicate.clone(), }).collect() } diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index 62910ec3204..993d627d6e1 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -275,10 +275,10 @@ impl<'tcx> TyCtxt<'tcx> { `.await`ing on both of them"); } } - if let (ty::Infer(ty::IntVar(_)), ty::Float(_)) = - (&values.found.sty, &values.expected.sty) // Issue #53280 - { - if let Ok(snippet) = self.sess.source_map().span_to_snippet(sp) { + match (&values.expected.sty, &values.found.sty) { + (ty::Float(_), ty::Infer(ty::IntVar(_))) => if let Ok( // Issue #53280 + snippet, + ) = self.sess.source_map().span_to_snippet(sp) { if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') { db.span_suggestion( sp, @@ -287,8 +287,96 @@ impl<'tcx> TyCtxt<'tcx> { Applicability::MachineApplicable ); } + }, + (ty::Param(_), ty::Param(_)) => { + db.note("a type parameter was expected, but a different one was found; \ + you might be missing a type parameter or trait bound"); + db.note("for more information, visit \ + https://doc.rust-lang.org/book/ch10-02-traits.html\ + #traits-as-parameters"); } + (ty::Projection(_), ty::Projection(_)) => { + db.note("an associated type was expected, but a different one was found"); + } + (ty::Param(_), ty::Projection(_)) | (ty::Projection(_), ty::Param(_)) => { + db.note("you might be missing a type parameter or trait bound"); + } + (ty::Param(_), _) | (_, ty::Param(_)) => { + db.help("type parameters must be constrained to match other types"); + if self.sess.teach(&db.get_code().unwrap()) { + db.help("given a type parameter `T` and a method `foo`: +``` +trait Trait { fn foo(&self) -> T; } +``` +the only ways to implement method `foo` are: +- constrain `T` with an explicit type: +``` +impl Trait for X { + fn foo(&self) -> String { String::new() } +} +``` +- add a trait bound to `T` and call a method on that trait that returns `Self`: +``` +impl Trait for X { + fn foo(&self) -> T { ::default() } +} +``` +- change `foo` to return an argument of type `T`: +``` +impl Trait for X { + fn foo(&self, x: T) -> T { x } +} +```"); + } + db.note("for more information, visit \ + https://doc.rust-lang.org/book/ch10-02-traits.html\ + #traits-as-parameters"); + } + (ty::Projection(_), _) => { + db.note(&format!( + "consider constraining the associated type `{}` to `{}` or calling a \ + method that returns `{}`", + values.expected, + values.found, + values.expected, + )); + if self.sess.teach(&db.get_code().unwrap()) { + db.help("given an associated type `T` and a method `foo`: +``` +trait Trait { + type T; + fn foo(&self) -> Self::T; +} +``` +the only way of implementing method `foo` is to constrain `T` with an explicit associated type: +``` +impl Trait for X { + type T = String; + fn foo(&self) -> Self::T { String::new() } +} +```"); + } + db.note("for more information, visit \ + https://doc.rust-lang.org/book/ch19-03-advanced-traits.html"); + } + (_, ty::Projection(_)) => { + db.note(&format!( + "consider constraining the associated type `{}` to `{}`", + values.found, + values.expected, + )); + db.note("for more information, visit \ + https://doc.rust-lang.org/book/ch19-03-advanced-traits.html"); + } + _ => {} } + debug!( + "note_and_explain_type_err expected={:?} ({:?}) found={:?} ({:?})", + values.expected, + values.expected.sty, + values.found, + values.found.sty, + ); }, CyclicTy(ty) => { // Watch out for various cases of cyclic types and try to explain. diff --git a/src/test/ui/associated-const/associated-const-generic-obligations.stderr b/src/test/ui/associated-const/associated-const-generic-obligations.stderr index eeee26a7567..ca6118cb3ba 100644 --- a/src/test/ui/associated-const/associated-const-generic-obligations.stderr +++ b/src/test/ui/associated-const/associated-const-generic-obligations.stderr @@ -9,6 +9,8 @@ LL | const FROM: &'static str = "foo"; | = note: expected type `::Out` found type `&'static str` + = note: consider constraining the associated type `::Out` to `&'static str` or calling a method that returns `::Out` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to previous error diff --git a/src/test/ui/associated-types/associated-types-eq-3.stderr b/src/test/ui/associated-types/associated-types-eq-3.stderr index 0f8c5257d44..c9d88b7af07 100644 --- a/src/test/ui/associated-types/associated-types-eq-3.stderr +++ b/src/test/ui/associated-types/associated-types-eq-3.stderr @@ -6,6 +6,8 @@ LL | let _: Bar = x.boo(); | = note: expected type `Bar` found type `::A` + = note: consider constraining the associated type `::A` to `Bar` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0271]: type mismatch resolving `::A == Bar` --> $DIR/associated-types-eq-3.rs:38:5 diff --git a/src/test/ui/associated-types/associated-types-issue-20346.stderr b/src/test/ui/associated-types/associated-types-issue-20346.stderr index 7d6c025d69d..e037bd851ca 100644 --- a/src/test/ui/associated-types/associated-types-issue-20346.stderr +++ b/src/test/ui/associated-types/associated-types-issue-20346.stderr @@ -9,6 +9,8 @@ LL | is_iterator_of::, _>(&adapter); | = note: expected type `T` found type `std::option::Option` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr index 4a2a6d03c60..d6328a64c7c 100644 --- a/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr +++ b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr @@ -9,6 +9,8 @@ LL | fn want_y>(t: &T) { } | = note: expected type `::Y` found type `i32` + = note: consider constraining the associated type `::Y` to `i32` or calling a method that returns `::Y` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0271]: type mismatch resolving `::X == u32` --> $DIR/associated-types-multiple-types-one-trait.rs:18:5 @@ -21,6 +23,8 @@ LL | fn want_x>(t: &T) { } | = note: expected type `::X` found type `u32` + = note: consider constraining the associated type `::X` to `u32` or calling a method that returns `::X` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to 2 previous errors diff --git a/src/test/ui/compare-method/reordered-type-param.stderr b/src/test/ui/compare-method/reordered-type-param.stderr index a33908c01c8..8176e96d6de 100644 --- a/src/test/ui/compare-method/reordered-type-param.stderr +++ b/src/test/ui/compare-method/reordered-type-param.stderr @@ -9,6 +9,8 @@ LL | fn b(&self, _x: G) -> G { panic!() } | = note: expected type `fn(&E, F) -> F` found type `fn(&E, G) -> G` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr index c2d0e0c2a26..fd6fce938b2 100644 --- a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr +++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr @@ -6,6 +6,8 @@ LL | let v = Unit2.m( | = note: expected type `Unit4` found type `<_ as Ty<'_>>::V` + = note: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0271]: type mismatch resolving `<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as std::ops::FnOnce<((&u8,),)>>::Output == Unit3` --> $DIR/issue-62203-hrtb-ice.rs:38:19 diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index 2c4c61a0957..99c6a8cdd6d 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -14,6 +14,8 @@ LL | fn foo_fail() -> impl FooLike { | = note: expected type `()` found type `::Assoc` + = note: consider constraining the associated type `::Assoc` to `()` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: the return type of a function must have a statically known size error: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope @@ -30,6 +32,8 @@ LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike { | = note: expected type `()` found type `>::Assoc` + = note: consider constraining the associated type `>::Assoc` to `()` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: the return type of a function must have a statically known size error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-trait/equality2.stderr b/src/test/ui/impl-trait/equality2.stderr index 3e6181adec0..e30e2626e9f 100644 --- a/src/test/ui/impl-trait/equality2.stderr +++ b/src/test/ui/impl-trait/equality2.stderr @@ -15,6 +15,8 @@ LL | let _: i32 = Leak::leak(hide(0_i32)); | = note: expected type `i32` found type `::T` + = note: consider constraining the associated type `::T` to `i32` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0308]: mismatched types --> $DIR/equality2.rs:38:10 diff --git a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr index 357e6b026e2..e4d0a731ebf 100644 --- a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr +++ b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr @@ -9,6 +9,8 @@ LL | fn foo(&self, a: &impl Debug, b: &B) { } | = note: expected type `fn(&(), &B, &impl Debug)` found type `fn(&(), &impl Debug, &B)` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/impl-trait/universal-mismatched-type.stderr b/src/test/ui/impl-trait/universal-mismatched-type.stderr index d223b9672cf..d92c3f034e5 100644 --- a/src/test/ui/impl-trait/universal-mismatched-type.stderr +++ b/src/test/ui/impl-trait/universal-mismatched-type.stderr @@ -8,6 +8,8 @@ LL | x | = note: expected type `std::string::String` found type `impl Debug` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/impl-trait/universal-two-impl-traits.stderr b/src/test/ui/impl-trait/universal-two-impl-traits.stderr index 145d6a8431b..98a70f268cf 100644 --- a/src/test/ui/impl-trait/universal-two-impl-traits.stderr +++ b/src/test/ui/impl-trait/universal-two-impl-traits.stderr @@ -6,6 +6,8 @@ LL | a = y; | = note: expected type `impl Debug` (type parameter) found type `impl Debug` (type parameter) + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/issues/issue-13853.stderr b/src/test/ui/issues/issue-13853.stderr index c57ca3e25d9..3f2d0aa87ad 100644 --- a/src/test/ui/issues/issue-13853.stderr +++ b/src/test/ui/issues/issue-13853.stderr @@ -9,6 +9,8 @@ LL | self.iter() | = note: expected type `I` found type `std::slice::Iter<'_, N>` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0599]: no method named `iter` found for type `&G` in the current scope --> $DIR/issue-13853.rs:27:23 diff --git a/src/test/ui/issues/issue-20225.stderr b/src/test/ui/issues/issue-20225.stderr index 5ab23cb55bc..4c464e6d4f6 100644 --- a/src/test/ui/issues/issue-20225.stderr +++ b/src/test/ui/issues/issue-20225.stderr @@ -6,6 +6,8 @@ LL | extern "rust-call" fn call(&self, (_,): (T,)) {} | = note: expected type `extern "rust-call" fn(&Foo, (&'a T,))` found type `extern "rust-call" fn(&Foo, (T,))` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/issue-20225.rs:12:3 @@ -15,6 +17,8 @@ LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} | = note: expected type `extern "rust-call" fn(&mut Foo, (&'a T,))` found type `extern "rust-call" fn(&mut Foo, (T,))` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0053]: method `call_once` has an incompatible type for trait --> $DIR/issue-20225.rs:20:3 @@ -24,6 +28,8 @@ LL | extern "rust-call" fn call_once(self, (_,): (T,)) {} | = note: expected type `extern "rust-call" fn(Foo, (&'a T,))` found type `extern "rust-call" fn(Foo, (T,))` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-24204.stderr b/src/test/ui/issues/issue-24204.stderr index eb9aada389f..9658f6980be 100644 --- a/src/test/ui/issues/issue-24204.stderr +++ b/src/test/ui/issues/issue-24204.stderr @@ -9,6 +9,7 @@ LL | fn test>(b: i32) -> T where T::A: MultiDispatch { T::n | = note: expected type `<::A as MultiDispatch>::O` found type `T` + = note: you might be missing a type parameter or trait bound error: aborting due to previous error diff --git a/src/test/ui/issues/issue-2951.stderr b/src/test/ui/issues/issue-2951.stderr index 58e28c1a9dc..a6ccc4835fa 100644 --- a/src/test/ui/issues/issue-2951.stderr +++ b/src/test/ui/issues/issue-2951.stderr @@ -6,6 +6,8 @@ LL | xx = y; | = note: expected type `T` found type `U` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/issues/issue-32323.stderr b/src/test/ui/issues/issue-32323.stderr index 6256dc0c550..9c11a02923c 100644 --- a/src/test/ui/issues/issue-32323.stderr +++ b/src/test/ui/issues/issue-32323.stderr @@ -8,6 +8,8 @@ LL | pub fn f<'a, T: Tr<'a>>() -> >::Out {} | = note: expected type `>::Out` found type `()` + = note: consider constraining the associated type `>::Out` to `()` or calling a method that returns `>::Out` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to previous error diff --git a/src/test/ui/mismatched_types/issue-35030.stderr b/src/test/ui/mismatched_types/issue-35030.stderr index f0306701613..4a9afb9d249 100644 --- a/src/test/ui/mismatched_types/issue-35030.stderr +++ b/src/test/ui/mismatched_types/issue-35030.stderr @@ -6,6 +6,8 @@ LL | Some(true) | = note: expected type `bool` (type parameter) found type `bool` (bool) + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/specialization/specialization-default-projection.stderr b/src/test/ui/specialization/specialization-default-projection.stderr index ab0bdc44cff..43cebd7f9c2 100644 --- a/src/test/ui/specialization/specialization-default-projection.stderr +++ b/src/test/ui/specialization/specialization-default-projection.stderr @@ -9,6 +9,8 @@ LL | () | = note: expected type `::Assoc` found type `()` + = note: consider constraining the associated type `::Assoc` to `()` or calling a method that returns `::Assoc` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0308]: mismatched types --> $DIR/specialization-default-projection.rs:28:5 @@ -23,6 +25,8 @@ LL | generic::<()>() | = note: expected type `()` found type `<() as Foo>::Assoc` + = note: consider constraining the associated type `<() as Foo>::Assoc` to `()` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to 2 previous errors diff --git a/src/test/ui/specialization/specialization-default-types.stderr b/src/test/ui/specialization/specialization-default-types.stderr index 1192b0e5cfa..932087421fb 100644 --- a/src/test/ui/specialization/specialization-default-types.stderr +++ b/src/test/ui/specialization/specialization-default-types.stderr @@ -8,6 +8,8 @@ LL | Box::new(self) | = note: expected type `::Output` found type `std::boxed::Box` + = note: consider constraining the associated type `::Output` to `std::boxed::Box` or calling a method that returns `::Output` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error[E0308]: mismatched types --> $DIR/specialization-default-types.rs:25:5 @@ -19,6 +21,8 @@ LL | Example::generate(t) | = note: expected type `std::boxed::Box` found type `::Output` + = note: consider constraining the associated type `::Output` to `std::boxed::Box` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to 2 previous errors diff --git a/src/test/ui/structs/struct-path-self-type-mismatch.stderr b/src/test/ui/structs/struct-path-self-type-mismatch.stderr index 72c6d7ae22b..b905cd1a294 100644 --- a/src/test/ui/structs/struct-path-self-type-mismatch.stderr +++ b/src/test/ui/structs/struct-path-self-type-mismatch.stderr @@ -12,6 +12,8 @@ LL | inner: u | = note: expected type `T` found type `U` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0308]: mismatched types --> $DIR/struct-path-self-type-mismatch.rs:13:9 @@ -27,6 +29,8 @@ LL | | } | = note: expected type `Foo` found type `Foo` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr index ee73622cb7b..a0a617fdbbc 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr +++ b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr @@ -6,6 +6,8 @@ LL | Self::TSVariant(()); | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:15:27 @@ -27,6 +29,8 @@ LL | Self::<()>::TSVariant(()); | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:20:16 @@ -48,6 +52,8 @@ LL | Self::SVariant { v: () }; | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:28:26 @@ -63,6 +69,8 @@ LL | Self::SVariant::<()> { v: () }; | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:31:16 @@ -78,6 +86,8 @@ LL | Self::<()>::SVariant { v: () }; | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:34:16 @@ -99,6 +109,8 @@ LL | Self::<()>::SVariant::<()> { v: () }; | = note: expected type `T` found type `()` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:41:26 diff --git a/src/test/ui/type/type-parameter-names.stderr b/src/test/ui/type/type-parameter-names.stderr index 9acae5c376d..3397eec9e05 100644 --- a/src/test/ui/type/type-parameter-names.stderr +++ b/src/test/ui/type/type-parameter-names.stderr @@ -8,6 +8,8 @@ LL | x | = note: expected type `Bar` found type `Foo` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/type/type-params-in-different-spaces-1.stderr b/src/test/ui/type/type-params-in-different-spaces-1.stderr index 0448a28ea8e..a10bf4e0b77 100644 --- a/src/test/ui/type/type-params-in-different-spaces-1.stderr +++ b/src/test/ui/type/type-params-in-different-spaces-1.stderr @@ -6,6 +6,8 @@ LL | *self + rhs | = note: expected type `Self` found type `T` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error diff --git a/src/test/ui/type/type-params-in-different-spaces-3.stderr b/src/test/ui/type/type-params-in-different-spaces-3.stderr index e25f79947c7..9f0fa5a0ea1 100644 --- a/src/test/ui/type/type-params-in-different-spaces-3.stderr +++ b/src/test/ui/type/type-params-in-different-spaces-3.stderr @@ -8,6 +8,8 @@ LL | u | = note: expected type `Self` found type `X` + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to previous error