From bd8b46800d152ce14029be5df784c1abaa8febd1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar>
Date: Wed, 18 Oct 2023 22:10:48 +0000
Subject: [PATCH] Tweak wording of type errors involving type params

Fix #78206.
---
 .../infer/error_reporting/note_and_explain.rs | 23 +++++++++++++++----
 .../tests/ui/builtin_type_shadow.stderr       |  2 +-
 .../ui/associated-type-bounds/elision.stderr  |  2 +-
 .../associated-types-issue-20346.stderr       |  2 +-
 .../hr-associated-type-projection-1.stderr    |  4 +++-
 .../issues/issue-67945-1.full.stderr          |  2 +-
 .../issue-68648-2.stderr                      |  2 +-
 .../issue-68656-unsized-values.stderr         |  2 +-
 .../issue-88360.stderr                        |  2 +-
 .../missing-bounds.stderr                     |  6 ++---
 .../arg-position-impl-trait-too-long.stderr   |  2 +-
 .../method-signature-matches.lt.stderr        |  2 +-
 .../in-trait/specialization-broken.stderr     |  2 +-
 .../universal-mismatched-type.stderr          |  2 +-
 tests/ui/inference/issue-107090.stderr        |  2 +-
 tests/ui/issues/issue-20225.stderr            |  6 ++---
 tests/ui/issues/issue-51154.stderr            |  2 +-
 tests/ui/issues/issue-69306.stderr            | 12 +++++-----
 .../start_lang_item_args.main_ret.stderr      |  2 +-
 tests/ui/mismatched_types/issue-35030.stderr  |  2 +-
 tests/ui/return/return-impl-trait-bad.stderr  |  8 +++----
 tests/ui/return/return-impl-trait.stderr      |  4 ++--
 ...n-unconstrained-borrowed-type-param.stderr |  2 +-
 .../expected-boxed-future-isnt-pinned.stderr  |  4 ++--
 .../restrict-existing-type-bounds.stderr      |  4 ++--
 ...missing-associated-type-restriction.stderr |  2 +-
 tests/ui/traits/issue-52893.stderr            |  2 +-
 .../traits/new-solver/object-unsafety.stderr  |  2 +-
 .../enum-variant-generic-args.stderr          | 12 +++++-----
 .../ui/typeck/bad-index-due-to-nested.stderr  |  4 ++--
 tests/ui/typeck/issue-13853.stderr            |  2 +-
 31 files changed, 72 insertions(+), 55 deletions(-)

diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
index 8ecf63ec665..3da6d8a89e1 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs
@@ -85,8 +85,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                     {
                         let p_def_id = tcx.generics_of(body_owner_def_id).type_param(p, tcx).def_id;
                         let p_span = tcx.def_span(p_def_id);
+                        let expected = match (values.expected.kind(), values.found.kind()) {
+                            (ty::Param(_), _) => "expected ",
+                            (_, ty::Param(_)) => "found ",
+                            _ => "",
+                        };
                         if !sp.contains(p_span) {
-                            diag.span_label(p_span, "this type parameter");
+                            diag.span_label(p_span, format!("{expected}this type parameter"));
                         }
                         let hir = tcx.hir();
                         let mut note = true;
@@ -168,8 +173,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                     | (ty::Dynamic(..) | ty::Alias(ty::Opaque, ..), ty::Param(p)) => {
                         let generics = tcx.generics_of(body_owner_def_id);
                         let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
+                        let expected = match (values.expected.kind(), values.found.kind()) {
+                            (ty::Param(_), _) => "expected ",
+                            (_, ty::Param(_)) => "found ",
+                            _ => "",
+                        };
                         if !sp.contains(p_span) {
-                            diag.span_label(p_span, "this type parameter");
+                            diag.span_label(p_span, format!("{expected}this type parameter"));
                         }
                         diag.help("type parameters must be constrained to match other types");
                         if tcx.sess.teach(&diag.get_code().unwrap()) {
@@ -209,7 +219,7 @@ impl<T> Trait<T> for X {
                         let generics = tcx.generics_of(body_owner_def_id);
                         let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
                         if !sp.contains(p_span) {
-                            diag.span_label(p_span, "this type parameter");
+                            diag.span_label(p_span, "expected this type parameter");
                         }
                         diag.help(format!(
                             "every closure has a distinct type and so could not always match the \
@@ -219,8 +229,13 @@ impl<T> Trait<T> for X {
                     (ty::Param(p), _) | (_, ty::Param(p)) => {
                         let generics = tcx.generics_of(body_owner_def_id);
                         let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
+                        let expected = match (values.expected.kind(), values.found.kind()) {
+                            (ty::Param(_), _) => "expected ",
+                            (_, ty::Param(_)) => "found ",
+                            _ => "",
+                        };
                         if !sp.contains(p_span) {
-                            diag.span_label(p_span, "this type parameter");
+                            diag.span_label(p_span, format!("{expected}this type parameter"));
                         }
                     }
                     (ty::Alias(ty::Projection | ty::Inherent, proj_ty), _)
diff --git a/src/tools/clippy/tests/ui/builtin_type_shadow.stderr b/src/tools/clippy/tests/ui/builtin_type_shadow.stderr
index cb8462182b8..e051c00eb8d 100644
--- a/src/tools/clippy/tests/ui/builtin_type_shadow.stderr
+++ b/src/tools/clippy/tests/ui/builtin_type_shadow.stderr
@@ -13,7 +13,7 @@ error[E0308]: mismatched types
 LL | fn foo<u32>(a: u32) -> u32 {
    |        ---             --- expected `u32` because of return type
    |        |
-   |        this type parameter
+   |        expected this type parameter
 LL |     42
    |     ^^ expected type parameter `u32`, found integer
    |
diff --git a/tests/ui/associated-type-bounds/elision.stderr b/tests/ui/associated-type-bounds/elision.stderr
index cc10bbcc0b5..a29e32a784f 100644
--- a/tests/ui/associated-type-bounds/elision.stderr
+++ b/tests/ui/associated-type-bounds/elision.stderr
@@ -17,7 +17,7 @@ LL | fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()>
    |                           -----------------------------      --------------   ^^^^^^^^ expected `Option<&()>`, found `Option<impl Iterator<Item = &'_ ()>>`
    |                           |                                  |
    |                           |                                  expected `Option<&()>` because of return type
-   |                           this type parameter
+   |                           found this type parameter
    |
    = note: expected enum `Option<&()>`
               found enum `Option<impl Iterator<Item = &'_ ()>>`
diff --git a/tests/ui/associated-types/associated-types-issue-20346.stderr b/tests/ui/associated-types/associated-types-issue-20346.stderr
index b1708b96e52..f384079862f 100644
--- a/tests/ui/associated-types/associated-types-issue-20346.stderr
+++ b/tests/ui/associated-types/associated-types-issue-20346.stderr
@@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<
   --> $DIR/associated-types-issue-20346.rs:34:36
    |
 LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) {
-   |                 - this type parameter
+   |                 - found this type parameter
 ...
 LL |     is_iterator_of::<Option<T>, _>(&adapter);
    |     ------------------------------ ^^^^^^^^ type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>`
diff --git a/tests/ui/associated-types/hr-associated-type-projection-1.stderr b/tests/ui/associated-types/hr-associated-type-projection-1.stderr
index dd0389c34e6..425cfdca01d 100644
--- a/tests/ui/associated-types/hr-associated-type-projection-1.stderr
+++ b/tests/ui/associated-types/hr-associated-type-projection-1.stderr
@@ -2,7 +2,9 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
   --> $DIR/hr-associated-type-projection-1.rs:13:33
    |
 LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
-   |      - this type parameter      ^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type
+   |      -                          ^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type
+   |      |
+   |      expected this type parameter
    |
    = note: expected type parameter `T`
              found associated type `<T as Deref>::Target`
diff --git a/tests/ui/const-generics/issues/issue-67945-1.full.stderr b/tests/ui/const-generics/issues/issue-67945-1.full.stderr
index 8879aec35e5..ee17ec3c698 100644
--- a/tests/ui/const-generics/issues/issue-67945-1.full.stderr
+++ b/tests/ui/const-generics/issues/issue-67945-1.full.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-67945-1.rs:10:20
    |
 LL | struct Bug<S> {
-   |            - this type parameter
+   |            - expected this type parameter
 ...
 LL |         let x: S = MaybeUninit::uninit();
    |                -   ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found `MaybeUninit<_>`
diff --git a/tests/ui/generic-associated-types/issue-68648-2.stderr b/tests/ui/generic-associated-types/issue-68648-2.stderr
index b2bef19eb5e..0514e7bd6f6 100644
--- a/tests/ui/generic-associated-types/issue-68648-2.stderr
+++ b/tests/ui/generic-associated-types/issue-68648-2.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-68648-2.rs:12:17
    |
 LL | fn bug<'a, T: Fun<F<'a> = T>>(t: T) -> T::F<'a> {
-   |            - this type parameter
+   |            - expected this type parameter
 LL |     T::identity(())
    |     ----------- ^^ expected type parameter `T`, found `()`
    |     |
diff --git a/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr b/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr
index f0212e985a9..20c07db4c04 100644
--- a/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr
+++ b/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr
@@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
   --> $DIR/issue-68656-unsized-values.rs:13:21
    |
 LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<T> for T {
-   |      - this type parameter
+   |      - expected this type parameter
 LL |     type Item<'a> = T;
    |                     ^ expected type parameter `T`, found associated type
    |
diff --git a/tests/ui/generic-associated-types/issue-88360.stderr b/tests/ui/generic-associated-types/issue-88360.stderr
index 520aeff1894..ad40ee18001 100644
--- a/tests/ui/generic-associated-types/issue-88360.stderr
+++ b/tests/ui/generic-associated-types/issue-88360.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-88360.rs:15:9
    |
 LL | trait SuperTrait<T>
-   |                  - this type parameter
+   |                  - found this type parameter
 ...
 LL |     fn copy(&self) -> Self::Gat<'_> where T: Copy {
    |                       ------------- expected `&T` because of return type
diff --git a/tests/ui/generic-associated-types/missing-bounds.stderr b/tests/ui/generic-associated-types/missing-bounds.stderr
index 535edec575a..1d7d80d1b07 100644
--- a/tests/ui/generic-associated-types/missing-bounds.stderr
+++ b/tests/ui/generic-associated-types/missing-bounds.stderr
@@ -14,7 +14,7 @@ error[E0308]: mismatched types
   --> $DIR/missing-bounds.rs:11:11
    |
 LL | impl<B> Add for A<B> where B: Add {
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         A(self.0 + rhs.0)
    |         - ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type
@@ -44,7 +44,7 @@ error[E0308]: mismatched types
   --> $DIR/missing-bounds.rs:21:14
    |
 LL | impl<B: Add> Add for C<B> {
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         Self(self.0 + rhs.0)
    |         ---- ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type
@@ -80,7 +80,7 @@ error[E0308]: mismatched types
   --> $DIR/missing-bounds.rs:42:14
    |
 LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         Self(self.0 + rhs.0)
    |         ---- ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type
diff --git a/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr b/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr
index 40446a3d339..d5086c7bc51 100644
--- a/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr
+++ b/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr
@@ -7,7 +7,7 @@ LL | |         &mut Header,
 LL | |         &mut [EntryMetadata],
 LL | |         &mut [Entry<C::EncodedKey, C::EncodedValue>]
 LL | |     ) -> R,
-   | |__________- this type parameter
+   | |__________- expected this type parameter
 LL |   ) {
 LL |       let () = y;
    |           ^^   - this expression has type `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R`
diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr
index 59139e4d5ae..874a1b95a43 100644
--- a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr
+++ b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr
@@ -6,7 +6,7 @@ LL |     fn early<'late, T>(_: &'late ()) {}
    |                     |     |
    |                     |     expected type parameter `T`, found `()`
    |                     |     help: change the parameter type to match the trait: `&T`
-   |                     this type parameter
+   |                     expected this type parameter
    |
 note: type in trait
   --> $DIR/method-signature-matches.rs:52:28
diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr
index 1d169b5d690..25c0adeddbd 100644
--- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr
+++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr
@@ -2,7 +2,7 @@ error[E0053]: method `bar` has an incompatible type for trait
   --> $DIR/specialization-broken.rs:15:22
    |
 LL | default impl<U> Foo for U
-   |              - this type parameter
+   |              - found this type parameter
 ...
 LL |     fn bar(&self) -> U {
    |                      ^
diff --git a/tests/ui/impl-trait/universal-mismatched-type.stderr b/tests/ui/impl-trait/universal-mismatched-type.stderr
index a56e542d834..82e0f23964f 100644
--- a/tests/ui/impl-trait/universal-mismatched-type.stderr
+++ b/tests/ui/impl-trait/universal-mismatched-type.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL | fn foo(x: impl Debug) -> String {
    |           ----------     ------ expected `String` because of return type
    |           |
-   |           this type parameter
+   |           found this type parameter
 LL |     x
    |     ^ expected `String`, found type parameter `impl Debug`
    |
diff --git a/tests/ui/inference/issue-107090.stderr b/tests/ui/inference/issue-107090.stderr
index 6233b629ad6..55825f7765b 100644
--- a/tests/ui/inference/issue-107090.stderr
+++ b/tests/ui/inference/issue-107090.stderr
@@ -70,7 +70,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-107090.rs:22:5
    |
 LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
-   |                       - this type parameter                                             ------- expected `&'out T` because of return type
+   |                       - expected this type parameter                                    ------- expected `&'out T` because of return type
 LL |
 LL |     sadness.cast()
    |     ^^^^^^^^^^^^^^ expected `&T`, found `&Foo<'_, '_, T>`
diff --git a/tests/ui/issues/issue-20225.stderr b/tests/ui/issues/issue-20225.stderr
index b1c15672051..b34aa8e1ff5 100644
--- a/tests/ui/issues/issue-20225.stderr
+++ b/tests/ui/issues/issue-20225.stderr
@@ -2,7 +2,7 @@ error[E0053]: method `call` has an incompatible type for trait
   --> $DIR/issue-20225.rs:6:43
    |
 LL | impl<'a, T> Fn<(&'a T,)> for Foo {
-   |          - this type parameter
+   |          - found this type parameter
 LL |   extern "rust-call" fn call(&self, (_,): (T,)) {}
    |                                           ^^^^
    |                                           |
@@ -16,7 +16,7 @@ error[E0053]: method `call_mut` has an incompatible type for trait
   --> $DIR/issue-20225.rs:11:51
    |
 LL | impl<'a, T> FnMut<(&'a T,)> for Foo {
-   |          - this type parameter
+   |          - found this type parameter
 LL |   extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
    |                                                   ^^^^
    |                                                   |
@@ -30,7 +30,7 @@ error[E0053]: method `call_once` has an incompatible type for trait
   --> $DIR/issue-20225.rs:18:47
    |
 LL | impl<'a, T> FnOnce<(&'a T,)> for Foo {
-   |          - this type parameter
+   |          - found this type parameter
 ...
 LL |   extern "rust-call" fn call_once(self, (_,): (T,)) {}
    |                                               ^^^^
diff --git a/tests/ui/issues/issue-51154.stderr b/tests/ui/issues/issue-51154.stderr
index 002d5ccdc67..5ae8e067807 100644
--- a/tests/ui/issues/issue-51154.stderr
+++ b/tests/ui/issues/issue-51154.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-51154.rs:2:30
    |
 LL | fn foo<F: FnMut()>() {
-   |        - this type parameter
+   |        - expected this type parameter
 LL |     let _: Box<F> = Box::new(|| ());
    |                     -------- ^^^^^ expected type parameter `F`, found closure
    |                     |
diff --git a/tests/ui/issues/issue-69306.stderr b/tests/ui/issues/issue-69306.stderr
index 570677298ff..6fc5c33af6a 100644
--- a/tests/ui/issues/issue-69306.stderr
+++ b/tests/ui/issues/issue-69306.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:5:28
    |
 LL | impl<T> S0<T> {
-   |      - this type parameter
+   |      - expected this type parameter
 LL |     const C: S0<u8> = Self(0);
    |                       ---- ^ expected type parameter `T`, found integer
    |                       |
@@ -20,7 +20,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:5:23
    |
 LL | impl<T> S0<T> {
-   |      - this type parameter
+   |      - found this type parameter
 LL |     const C: S0<u8> = Self(0);
    |                       ^^^^^^^ expected `S0<u8>`, found `S0<T>`
    |
@@ -31,7 +31,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:10:14
    |
 LL | impl<T> S0<T> {
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         Self(0);
    |         ---- ^ expected type parameter `T`, found integer
@@ -50,7 +50,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:27:14
    |
 LL | impl<T> Foo<T> for <S0<T> as Fun>::Out {
-   |      - this type parameter
+   |      - expected this type parameter
 LL |     fn foo() {
 LL |         Self(0);
    |         ---- ^ expected type parameter `T`, found integer
@@ -69,7 +69,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:33:32
    |
 LL | impl<T> S1<T, u8> {
-   |      - this type parameter
+   |      - expected this type parameter
 LL |     const C: S1<u8, u8> = Self(0, 1);
    |                           ---- ^ expected type parameter `T`, found integer
    |                           |
@@ -87,7 +87,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-69306.rs:33:27
    |
 LL | impl<T> S1<T, u8> {
-   |      - this type parameter
+   |      - found this type parameter
 LL |     const C: S1<u8, u8> = Self(0, 1);
    |                           ^^^^^^^^^^ expected `S1<u8, u8>`, found `S1<T, u8>`
    |
diff --git a/tests/ui/lang-items/start_lang_item_args.main_ret.stderr b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
index 4582b69850c..25570f96053 100644
--- a/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
+++ b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
@@ -4,7 +4,7 @@ error[E0308]: lang item `start` function has wrong type
 LL | fn start<T>(_main: fn() -> u16, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
    |          -         ^^^^^^^^^^^ expected type parameter `T`, found `u16`
    |          |
-   |          this type parameter
+   |          expected this type parameter
    |
    = note: expected signature `fn(fn() -> T, _, _, _) -> _`
               found signature `fn(fn() -> u16, _, _, _) -> _`
diff --git a/tests/ui/mismatched_types/issue-35030.stderr b/tests/ui/mismatched_types/issue-35030.stderr
index de4e067fead..881ff909722 100644
--- a/tests/ui/mismatched_types/issue-35030.stderr
+++ b/tests/ui/mismatched_types/issue-35030.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-35030.rs:9:14
    |
 LL | impl<bool> Parser<bool> for bool {
-   |      ---- this type parameter
+   |      ---- expected this type parameter
 LL |     fn parse(text: &str) -> Option<bool> {
 LL |         Some(true)
    |         ---- ^^^^ expected type parameter `bool`, found `bool`
diff --git a/tests/ui/return/return-impl-trait-bad.stderr b/tests/ui/return/return-impl-trait-bad.stderr
index 237b85ee66a..a015b9f53af 100644
--- a/tests/ui/return/return-impl-trait-bad.stderr
+++ b/tests/ui/return/return-impl-trait-bad.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL | fn bad_echo<T>(_t: T) -> T {
    |             -            - expected `T` because of return type
    |             |
-   |             this type parameter
+   |             expected this type parameter
 LL |     "this should not suggest impl Trait"
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
    |
@@ -17,7 +17,7 @@ error[E0308]: mismatched types
 LL | fn bad_echo_2<T: Trait>(_t: T) -> T {
    |               -                   - expected `T` because of return type
    |               |
-   |               this type parameter
+   |               expected this type parameter
 LL |     "this will not suggest it, because that would probably be wrong"
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
    |
@@ -30,7 +30,7 @@ error[E0308]: mismatched types
 LL | fn other_bounds_bad<T>() -> T
    |                     -       - expected `T` because of return type
    |                     |
-   |                     this type parameter
+   |                     expected this type parameter
 ...
 LL |     "don't suggest this, because Option<T> places additional constraints"
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
@@ -46,7 +46,7 @@ LL | fn used_in_trait<T>() -> T
    |                  |       |
    |                  |       expected `T` because of return type
    |                  |       help: consider using an impl return type: `impl Send`
-   |                  this type parameter
+   |                  expected this type parameter
 ...
 LL |     "don't suggest this, because the generic param is used in the bound."
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
diff --git a/tests/ui/return/return-impl-trait.stderr b/tests/ui/return/return-impl-trait.stderr
index 43d40972fca..707f014a16f 100644
--- a/tests/ui/return/return-impl-trait.stderr
+++ b/tests/ui/return/return-impl-trait.stderr
@@ -5,7 +5,7 @@ LL | fn bar<T: Trait + std::marker::Sync>() -> T
    |        -                                  -
    |        |                                  |
    |        |                                  expected `T` because of return type
-   |        this type parameter                help: consider using an impl return type: `impl Trait + std::marker::Sync + Send`
+   |        expected this type parameter       help: consider using an impl return type: `impl Trait + std::marker::Sync + Send`
 ...
 LL |     ()
    |     ^^ expected type parameter `T`, found `()`
@@ -21,7 +21,7 @@ LL | fn other_bounds<T>() -> T
    |                 |       |
    |                 |       expected `T` because of return type
    |                 |       help: consider using an impl return type: `impl Trait`
-   |                 this type parameter
+   |                 expected this type parameter
 ...
 LL |     ()
    |     ^^ expected type parameter `T`, found `()`
diff --git a/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr b/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
index 0716005c679..8c973995c34 100644
--- a/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
+++ b/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL | fn wat<T>(t: &T) -> T {
    |        -            - expected `T` because of return type
    |        |
-   |        this type parameter
+   |        expected this type parameter
 LL |     t.clone()
    |     ^^^^^^^^^ expected type parameter `T`, found `&T`
    |
diff --git a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
index 5093448d2ca..7c81825e576 100644
--- a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
+++ b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/expected-boxed-future-isnt-pinned.rs:11:5
    |
 LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
-   |        - this type parameter                            ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
+   |        - found this type parameter                      ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
 LL |     // We could instead use an `async` block, but this way we have no std spans.
 LL |     x
    |     ^ expected `Pin<Box<...>>`, found type parameter `F`
@@ -30,7 +30,7 @@ error[E0308]: mismatched types
   --> $DIR/expected-boxed-future-isnt-pinned.rs:19:14
    |
 LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
-   |        - this type parameter
+   |        - found this type parameter
 LL |     Pin::new(x)
    |     -------- ^ expected `Box<dyn Future<Output = ...> + Send>`, found type parameter `F`
    |     |
diff --git a/tests/ui/suggestions/restrict-existing-type-bounds.stderr b/tests/ui/suggestions/restrict-existing-type-bounds.stderr
index 14a244b790a..fe8338c18c2 100644
--- a/tests/ui/suggestions/restrict-existing-type-bounds.stderr
+++ b/tests/ui/suggestions/restrict-existing-type-bounds.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/restrict-existing-type-bounds.rs:13:12
    |
 LL | impl<T: TryAdd> TryAdd for Option<T> {
-   |      - this type parameter
+   |      - found this type parameter
 ...
 LL |         Ok(self)
    |         -- ^^^^ expected `Option<<T as TryAdd>::Output>`, found `Option<T>`
@@ -29,7 +29,7 @@ error[E0308]: mismatched types
   --> $DIR/restrict-existing-type-bounds.rs:26:12
    |
 LL | impl<T: TryAdd<Error = X>> TryAdd for Other<T> {
-   |      - this type parameter
+   |      - found this type parameter
 ...
 LL |         Ok(self)
    |         -- ^^^^ expected `Other<<T as TryAdd>::Output>`, found `Other<T>`
diff --git a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr
index 7deb9a4342d..980c2455c8e 100644
--- a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr
+++ b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr
@@ -124,7 +124,7 @@ error[E0308]: mismatched types
   --> $DIR/trait-with-missing-associated-type-restriction.rs:31:9
    |
 LL | fn baz<D: std::fmt::Debug, T: Trait<A = D>>(x: T) {
-   |        - this type parameter
+   |        - found this type parameter
 LL |     qux(x.func())
    |     --- ^^^^^^^^ expected `usize`, found type parameter `D`
    |     |
diff --git a/tests/ui/traits/issue-52893.stderr b/tests/ui/traits/issue-52893.stderr
index db807a38830..c57921a08aa 100644
--- a/tests/ui/traits/issue-52893.stderr
+++ b/tests/ui/traits/issue-52893.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-52893.rs:53:22
    |
 LL | impl<F, Name, P> AddClass<Name, F> for Class<P>
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         builder.push(output);
    |                 ---- ^^^^^^ expected type parameter `F`, found `Class<P>`
diff --git a/tests/ui/traits/new-solver/object-unsafety.stderr b/tests/ui/traits/new-solver/object-unsafety.stderr
index bb7c68b8941..914a8f9d4c5 100644
--- a/tests/ui/traits/new-solver/object-unsafety.stderr
+++ b/tests/ui/traits/new-solver/object-unsafety.stderr
@@ -42,7 +42,7 @@ error[E0308]: mismatched types
 LL | pub fn copy_any<T>(t: &T) -> T {
    |                 -            - expected `T` because of return type
    |                 |
-   |                 this type parameter
+   |                 expected this type parameter
 LL |     copy::<dyn Setup<From=T>>(t)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
    |
diff --git a/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr b/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr
index e24cb11288e..96a5c132763 100644
--- a/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr
+++ b/tests/ui/type-alias-enum-variants/enum-variant-generic-args.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/enum-variant-generic-args.rs:13:25
    |
 LL | impl<T> Enum<T> {
-   |      - this type parameter
+   |      - expected this type parameter
 LL |     fn ts_variant() {
 LL |         Self::TSVariant(());
    |         --------------- ^^ expected type parameter `T`, found `()`
@@ -50,7 +50,7 @@ error[E0308]: mismatched types
   --> $DIR/enum-variant-generic-args.rs:17:31
    |
 LL | impl<T> Enum<T> {
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         Self::<()>::TSVariant(());
    |         --------------------- ^^ expected type parameter `T`, found `()`
@@ -98,7 +98,7 @@ error[E0308]: mismatched types
   --> $DIR/enum-variant-generic-args.rs:26:29
    |
 LL | impl<T> Enum<T> {
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         Self::SVariant { v: () };
    |                             ^^ expected type parameter `T`, found `()`
@@ -125,7 +125,7 @@ error[E0308]: mismatched types
   --> $DIR/enum-variant-generic-args.rs:28:35
    |
 LL | impl<T> Enum<T> {
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         Self::SVariant::<()> { v: () };
    |                                   ^^ expected type parameter `T`, found `()`
@@ -158,7 +158,7 @@ error[E0308]: mismatched types
   --> $DIR/enum-variant-generic-args.rs:31:35
    |
 LL | impl<T> Enum<T> {
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         Self::<()>::SVariant { v: () };
    |                                   ^^ expected type parameter `T`, found `()`
@@ -206,7 +206,7 @@ error[E0308]: mismatched types
   --> $DIR/enum-variant-generic-args.rs:34:41
    |
 LL | impl<T> Enum<T> {
-   |      - this type parameter
+   |      - expected this type parameter
 ...
 LL |         Self::<()>::SVariant::<()> { v: () };
    |                                         ^^ expected type parameter `T`, found `()`
diff --git a/tests/ui/typeck/bad-index-due-to-nested.stderr b/tests/ui/typeck/bad-index-due-to-nested.stderr
index f9cdb280e27..0b705d467ff 100644
--- a/tests/ui/typeck/bad-index-due-to-nested.stderr
+++ b/tests/ui/typeck/bad-index-due-to-nested.stderr
@@ -40,7 +40,7 @@ error[E0308]: mismatched types
   --> $DIR/bad-index-due-to-nested.rs:20:9
    |
 LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
-   |              - this type parameter
+   |              - found this type parameter
 LL |     map[k]
    |         ^ expected `&K`, found type parameter `K`
    |
@@ -55,7 +55,7 @@ error[E0308]: mismatched types
   --> $DIR/bad-index-due-to-nested.rs:20:5
    |
 LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
-   |                 - this type parameter               ----- expected `&'a V` because of return type
+   |                 - found this type parameter         ----- expected `&'a V` because of return type
 LL |     map[k]
    |     ^^^^^^ expected `&V`, found type parameter `V`
    |
diff --git a/tests/ui/typeck/issue-13853.stderr b/tests/ui/typeck/issue-13853.stderr
index 8ecb8b68016..0683c782933 100644
--- a/tests/ui/typeck/issue-13853.stderr
+++ b/tests/ui/typeck/issue-13853.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
   --> $DIR/issue-13853.rs:14:9
    |
 LL |     fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I
-   |                  - this type parameter              - expected `I` because of return type
+   |                  - expected this type parameter     - expected `I` because of return type
 ...
 LL |         self.iter()
    |         ^^^^^^^^^^^ expected type parameter `I`, found `Iter<'_, N>`