about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkadmin <julianknodt@gmail.com>2022-02-01 15:28:31 +0000
committerkadmin <julianknodt@gmail.com>2022-02-01 20:19:54 +0000
commit78fb74a6005642bca0a3da7016f9edbbd99f1846 (patch)
tree2ff2ca55b6f13a1be720ea1752ef134be40f1d1d
parentc654e4d6f4abd794707c9e4e046b2e7f852e642f (diff)
downloadrust-78fb74a6005642bca0a3da7016f9edbbd99f1846.tar.gz
rust-78fb74a6005642bca0a3da7016f9edbbd99f1846.zip
Fix w/ comments
-rw-r--r--compiler/rustc_hir/src/hir.rs6
-rw-r--r--compiler/rustc_infer/src/infer/at.rs12
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/mod.rs1
-rw-r--r--compiler/rustc_infer/src/infer/mod.rs1
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs25
-rw-r--r--compiler/rustc_trait_selection/src/traits/project.rs81
-rw-r--r--compiler/rustc_typeck/src/astconv/mod.rs12
-rw-r--r--compiler/rustc_typeck/src/collect/type_of.rs64
-rw-r--r--src/test/ui/associated-consts/assoc-const-eq-missing.rs26
-rw-r--r--src/test/ui/associated-consts/assoc-const-eq-missing.stderr21
-rw-r--r--src/test/ui/associated-consts/assoc-const-ty-mismatch.rs4
-rw-r--r--src/test/ui/associated-consts/assoc-const-ty-mismatch.stderr20
-rw-r--r--src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr4
-rw-r--r--src/test/ui/associated-types/associated-types-eq-3.stderr4
-rw-r--r--src/test/ui/associated-types/associated-types-eq-hr.stderr8
-rw-r--r--src/test/ui/associated-types/associated-types-issue-20346.stderr4
-rw-r--r--src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr8
-rw-r--r--src/test/ui/associated-types/hr-associated-type-projection-1.stderr4
-rw-r--r--src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr7
-rw-r--r--src/test/ui/associated-types/issue-44153.stderr2
-rw-r--r--src/test/ui/associated-types/issue-72806.stderr2
-rw-r--r--src/test/ui/associated-types/issue-87261.stderr77
-rw-r--r--src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr2
-rw-r--r--src/test/ui/error-codes/E0271.stderr2
-rw-r--r--src/test/ui/generator/type-mismatch-signature-deduction.stderr2
-rw-r--r--src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr4
-rw-r--r--src/test/ui/generic-associated-types/issue-74684-2.stderr2
-rw-r--r--src/test/ui/hrtb/issue-62203-hrtb-ice.stderr6
-rw-r--r--src/test/ui/impl-trait/bound-normalization-fail.stderr12
-rw-r--r--src/test/ui/impl-trait/issues/issue-70877.stderr9
-rw-r--r--src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr2
-rw-r--r--src/test/ui/issues/issue-31173.stderr4
-rw-r--r--src/test/ui/issues/issue-33941.stderr8
-rw-r--r--src/test/ui/issues/issue-39970.stderr2
-rw-r--r--src/test/ui/issues/issue-67039-unsound-pin-partialeq.stderr4
-rw-r--r--src/test/ui/never_type/fallback-closure-wrap.fallback.stderr4
-rw-r--r--src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.stderr2
-rw-r--r--src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-63355.stderr8
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-89686.stderr12
40 files changed, 281 insertions, 199 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index a0ed72c9e9e..68fdbaa6aa0 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -2165,6 +2165,12 @@ impl TypeBinding<'_> {
             _ => panic!("expected equality type binding for parenthesized generic args"),
         }
     }
+    pub fn opt_const(&self) -> Option<&'_ AnonConst> {
+        match self.kind {
+            TypeBindingKind::Equality { term: Term::Const(ref c) } => Some(c),
+            _ => None,
+        }
+    }
 }
 
 #[derive(Debug)]
diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs
index aa74a92ad1f..147061dafeb 100644
--- a/compiler/rustc_infer/src/infer/at.rs
+++ b/compiler/rustc_infer/src/infer/at.rs
@@ -288,13 +288,21 @@ impl<'tcx> ToTrace<'tcx> for &'tcx Const<'tcx> {
 
 impl<'tcx> ToTrace<'tcx> for ty::Term<'tcx> {
     fn to_trace(
-        _: TyCtxt<'tcx>,
+        tcx: TyCtxt<'tcx>,
         cause: &ObligationCause<'tcx>,
         a_is_expected: bool,
         a: Self,
         b: Self,
     ) -> TypeTrace<'tcx> {
-        TypeTrace { cause: cause.clone(), values: Terms(ExpectedFound::new(a_is_expected, a, b)) }
+        match (a, b) {
+            (ty::Term::Ty(a), ty::Term::Ty(b)) => {
+                ToTrace::to_trace(tcx, cause, a_is_expected, a, b)
+            }
+            (ty::Term::Const(a), ty::Term::Const(b)) => {
+                ToTrace::to_trace(tcx, cause, a_is_expected, a, b)
+            }
+            (_, _) => todo!(),
+        }
     }
 }
 
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index 24a5f55d53c..1eb8190bd7d 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -2127,7 +2127,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
             infer::Types(exp_found) => self.expected_found_str_ty(exp_found),
             infer::Regions(exp_found) => self.expected_found_str(exp_found),
             infer::Consts(exp_found) => self.expected_found_str(exp_found),
-            infer::Terms(exp_found) => self.expected_found_str(exp_found),
             infer::TraitRefs(exp_found) => {
                 let pretty_exp_found = ty::error::ExpectedFound {
                     expected: exp_found.expected.print_only_trait_path(),
diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
index 330c99f6073..266eec08ceb 100644
--- a/compiler/rustc_infer/src/infer/mod.rs
+++ b/compiler/rustc_infer/src/infer/mod.rs
@@ -371,7 +371,6 @@ pub enum ValuePairs<'tcx> {
     Types(ExpectedFound<Ty<'tcx>>),
     Regions(ExpectedFound<ty::Region<'tcx>>),
     Consts(ExpectedFound<&'tcx ty::Const<'tcx>>),
-    Terms(ExpectedFound<ty::Term<'tcx>>),
     TraitRefs(ExpectedFound<ty::TraitRef<'tcx>>),
     PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>),
 }
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
index f16601dd08e..d06e8496f59 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
@@ -1356,11 +1356,26 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
                     normalized_ty,
                     data.term,
                 ) {
-                    values = Some(infer::ValuePairs::Terms(ExpectedFound::new(
-                        is_normalized_ty_expected,
-                        normalized_ty,
-                        data.term,
-                    )));
+                    values = Some(match (normalized_ty, data.term) {
+                        (ty::Term::Ty(normalized_ty), ty::Term::Ty(ty)) => {
+                            infer::ValuePairs::Types(ExpectedFound::new(
+                                is_normalized_ty_expected,
+                                normalized_ty,
+                                ty,
+                            ))
+                        }
+                        (ty::Term::Const(normalized_ct), ty::Term::Const(ct)) => {
+                            infer::ValuePairs::Consts(ExpectedFound::new(
+                                is_normalized_ty_expected,
+                                normalized_ct,
+                                ct,
+                            ))
+                        }
+                        (_, _) => span_bug!(
+                            obligation.cause.span,
+                            "found const or type where other expected"
+                        ),
+                    });
                     err_buf = error;
                     err = &err_buf;
                 }
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
index 11cde60f075..bad4ee30424 100644
--- a/compiler/rustc_trait_selection/src/traits/project.rs
+++ b/compiler/rustc_trait_selection/src/traits/project.rs
@@ -199,61 +199,30 @@ fn project_and_unify_type<'cx, 'tcx>(
     let mut obligations = vec![];
 
     let infcx = selcx.infcx();
-    match obligation.predicate.term {
-        ty::Term::Ty(obligation_pred_ty) => {
-            let normalized_ty = match opt_normalize_projection_type(
-                selcx,
-                obligation.param_env,
-                obligation.predicate.projection_ty,
-                obligation.cause.clone(),
-                obligation.recursion_depth,
-                &mut obligations,
-            ) {
-                Ok(Some(n)) => n.ty().unwrap(),
-                Ok(None) => return Ok(Ok(None)),
-                Err(InProgress) => return Ok(Err(InProgress)),
-            };
-            debug!(?normalized_ty, ?obligations, "project_and_unify_type result");
-            match infcx
-                .at(&obligation.cause, obligation.param_env)
-                .eq(normalized_ty, obligation_pred_ty)
-            {
-                Ok(InferOk { obligations: inferred_obligations, value: () }) => {
-                    obligations.extend(inferred_obligations);
-                    Ok(Ok(Some(obligations)))
-                }
-                Err(err) => {
-                    debug!("project_and_unify_type: equating types encountered error {:?}", err);
-                    Err(MismatchedProjectionTypes { err })
-                }
-            }
+    let normalized = match opt_normalize_projection_type(
+        selcx,
+        obligation.param_env,
+        obligation.predicate.projection_ty,
+        obligation.cause.clone(),
+        obligation.recursion_depth,
+        &mut obligations,
+    ) {
+        Ok(Some(n)) => n,
+        Ok(None) => return Ok(Ok(None)),
+        Err(InProgress) => return Ok(Err(InProgress)),
+    };
+    debug!(?normalized, ?obligations, "project_and_unify_type result");
+    match infcx
+        .at(&obligation.cause, obligation.param_env)
+        .eq(normalized, obligation.predicate.term)
+    {
+        Ok(InferOk { obligations: inferred_obligations, value: () }) => {
+            obligations.extend(inferred_obligations);
+            Ok(Ok(Some(obligations)))
         }
-        ty::Term::Const(obligation_pred_const) => {
-            let normalized_const = match opt_normalize_projection_type(
-                selcx,
-                obligation.param_env,
-                obligation.predicate.projection_ty,
-                obligation.cause.clone(),
-                obligation.recursion_depth,
-                &mut obligations,
-            ) {
-                Ok(Some(n)) => n.ct().unwrap(),
-                Ok(None) => return Ok(Ok(None)),
-                Err(InProgress) => return Ok(Err(InProgress)),
-            };
-            match infcx
-                .at(&obligation.cause, obligation.param_env)
-                .eq(normalized_const, obligation_pred_const)
-            {
-                Ok(InferOk { obligations: inferred_obligations, value: () }) => {
-                    obligations.extend(inferred_obligations);
-                    Ok(Ok(Some(obligations)))
-                }
-                Err(err) => {
-                    debug!("project_and_unify_type: equating consts encountered error {:?}", err);
-                    Err(MismatchedProjectionTypes { err })
-                }
-            }
+        Err(err) => {
+            debug!("project_and_unify_type: equating types encountered error {:?}", err);
+            Err(MismatchedProjectionTypes { err })
         }
     }
 }
@@ -934,6 +903,8 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
             // created (and hence the new ones will quickly be
             // discarded as duplicated). But when doing trait
             // evaluation this is not the case, and dropping the trait
+            // evaluations can causes ICEs (e.g., #43132).
+            debug!(?ty, "found normalized ty");
             obligations.extend(ty.obligations);
             return Ok(Some(ty.value));
         }
@@ -1127,6 +1098,8 @@ fn project<'cx, 'tcx>(
             Ok(Projected::Progress(confirm_candidate(selcx, obligation, candidate)))
         }
         ProjectionCandidateSet::None => Ok(Projected::NoProgress(
+            // FIXME(associated_const_generics): this may need to change in the future?
+            // need to investigate whether or not this is fine.
             selcx
                 .tcx()
                 .mk_projection(obligation.predicate.item_def_id, obligation.predicate.substs)
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs
index 06d472214e4..5eb9664e1d7 100644
--- a/compiler/rustc_typeck/src/astconv/mod.rs
+++ b/compiler/rustc_typeck/src/astconv/mod.rs
@@ -1244,17 +1244,23 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                 // the "projection predicate" for:
                 //
                 // `<T as Iterator>::Item = u32`
-                let def_kind = tcx.def_kind(projection_ty.skip_binder().item_def_id);
+                let assoc_item_def_id = projection_ty.skip_binder().item_def_id;
+                let def_kind = tcx.def_kind(assoc_item_def_id);
                 match (def_kind, term) {
                     (hir::def::DefKind::AssocTy, ty::Term::Ty(_))
                     | (hir::def::DefKind::AssocConst, ty::Term::Const(_)) => (),
                     (_, _) => {
+                        let got = if let ty::Term::Ty(_) = term { "type" } else { "const" };
+                        let expected = def_kind.descr(assoc_item_def_id);
                         tcx.sess
                             .struct_span_err(
                                 binding.span,
-                                "type/const mismatch in equality bind of associated field",
+                                &format!("mismatch in bind of {expected}, got {got}"),
+                            )
+                            .span_note(
+                                tcx.def_span(assoc_item_def_id),
+                                &format!("{expected} defined here does not match {got}"),
                             )
-                            .span_label(binding.span, "type/const Mismatch")
                             .emit();
                     }
                 }
diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs
index 63a8cab3def..7990c14f773 100644
--- a/compiler/rustc_typeck/src/collect/type_of.rs
+++ b/compiler/rustc_typeck/src/collect/type_of.rs
@@ -161,40 +161,26 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
             // We've encountered an `AnonConst` in some path, so we need to
             // figure out which generic parameter it corresponds to and return
             // the relevant type.
-            let filtered = path
-                .segments
-                .iter()
-                .filter_map(|seg| seg.args.map(|args| (args.args, seg)))
-                .find_map(|(args, seg)| {
-                    args.iter()
-                        .filter(|arg| arg.is_ty_or_const())
-                        .position(|arg| arg.id() == hir_id)
-                        .map(|index| (index, seg))
-                });
-            // FIXME(associated_const_equality): recursively search through the bindings instead
-            // of just top level.
+            let filtered = path.segments.iter().find_map(|seg| {
+                seg.args?
+                    .args
+                    .iter()
+                    .filter(|arg| arg.is_ty_or_const())
+                    .position(|arg| arg.id() == hir_id)
+                    .map(|index| (index, seg))
+            });
 
+            // FIXME(associated_const_generics): can we blend this with iteration above?
             let (arg_index, segment) = match filtered {
                 None => {
-                    let binding_filtered = path
-                        .segments
-                        .iter()
-                        .filter_map(|seg| seg.args.map(|args| (args.bindings, seg)))
-                        .find_map(|(bindings, seg)| {
-                            bindings
-                                .iter()
-                                .filter_map(|binding| {
-                                    if let hir::TypeBindingKind::Equality { term: Term::Const(c) } =
-                                        binding.kind
-                                    {
-                                        Some(c)
-                                    } else {
-                                        None
-                                    }
-                                })
-                                .position(|ct| ct.hir_id == hir_id)
-                                .map(|idx| (idx, seg))
-                        });
+                    let binding_filtered = path.segments.iter().find_map(|seg| {
+                        seg.args?
+                            .bindings
+                            .iter()
+                            .filter_map(TypeBinding::opt_const)
+                            .position(|ct| ct.hir_id == hir_id)
+                            .map(|idx| (idx, seg))
+                    });
                     match binding_filtered {
                         Some(inner) => inner,
                         None => {
@@ -518,20 +504,10 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
                   path
                       .segments
                       .iter()
-                      .filter_map(|seg| seg.args.map(|args| (args.bindings, seg)))
-                      .find_map(|(bindings, seg)| {
-                          bindings
+                      .find_map(|seg| {
+                          seg.args?.bindings
                               .iter()
-                              .filter_map(|binding| {
-                                  if let hir::TypeBindingKind::Equality { term: Term::Const(c) } =
-                                      binding.kind
-                                  {
-                                          Some((binding, c))
-                                  } else {
-                                      None
-                                  }
-                              })
-                              .find_map(|(binding, ct)| if ct.hir_id == hir_id {
+                              .find_map(|binding| if binding.opt_const()?.hir_id == hir_id {
                                 Some((binding, seg))
                               } else {
                                 None
diff --git a/src/test/ui/associated-consts/assoc-const-eq-missing.rs b/src/test/ui/associated-consts/assoc-const-eq-missing.rs
new file mode 100644
index 00000000000..5e029a12df2
--- /dev/null
+++ b/src/test/ui/associated-consts/assoc-const-eq-missing.rs
@@ -0,0 +1,26 @@
+#![feature(associated_const_equality)]
+#![allow(unused)]
+
+pub trait Foo {
+  const N: usize;
+}
+
+pub struct Bar;
+
+impl Foo for Bar {
+  const N: usize = 3;
+}
+
+
+fn foo1<F: Foo<Z=3>>() {}
+//~^ ERROR associated type
+fn foo2<F: Foo<Z=usize>>() {}
+//~^ ERROR associated type
+fn foo3<F: Foo<Z=5>>() {}
+//~^ ERROR associated type
+
+fn main() {
+  foo1::<Bar>();
+  foo2::<Bar>();
+  foo3::<Bar>();
+}
diff --git a/src/test/ui/associated-consts/assoc-const-eq-missing.stderr b/src/test/ui/associated-consts/assoc-const-eq-missing.stderr
new file mode 100644
index 00000000000..b4bd6456c85
--- /dev/null
+++ b/src/test/ui/associated-consts/assoc-const-eq-missing.stderr
@@ -0,0 +1,21 @@
+error[E0220]: associated type `Z` not found for `Foo`
+  --> $DIR/assoc-const-eq-missing.rs:15:16
+   |
+LL | fn foo1<F: Foo<Z=3>>() {}
+   |                ^ associated type `Z` not found
+
+error[E0220]: associated type `Z` not found for `Foo`
+  --> $DIR/assoc-const-eq-missing.rs:17:16
+   |
+LL | fn foo2<F: Foo<Z=usize>>() {}
+   |                ^ associated type `Z` not found
+
+error[E0220]: associated type `Z` not found for `Foo`
+  --> $DIR/assoc-const-eq-missing.rs:19:16
+   |
+LL | fn foo3<F: Foo<Z=5>>() {}
+   |                ^ associated type `Z` not found
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0220`.
diff --git a/src/test/ui/associated-consts/assoc-const-ty-mismatch.rs b/src/test/ui/associated-consts/assoc-const-ty-mismatch.rs
index c48f4c63b02..c3293156345 100644
--- a/src/test/ui/associated-consts/assoc-const-ty-mismatch.rs
+++ b/src/test/ui/associated-consts/assoc-const-ty-mismatch.rs
@@ -21,9 +21,9 @@ impl FooTy for Bar {
 
 
 fn foo<F: Foo<N=usize>>() {}
-//~^ ERROR type/const mismatch
+//~^ ERROR mismatch in
 fn foo2<F: FooTy<T=3usize>>() {}
-//~^ ERROR type/const mismatch
+//~^ ERROR mismatch in
 
 fn main() {
   foo::<Bar>();
diff --git a/src/test/ui/associated-consts/assoc-const-ty-mismatch.stderr b/src/test/ui/associated-consts/assoc-const-ty-mismatch.stderr
index 71f8375d4e6..703245145ce 100644
--- a/src/test/ui/associated-consts/assoc-const-ty-mismatch.stderr
+++ b/src/test/ui/associated-consts/assoc-const-ty-mismatch.stderr
@@ -1,14 +1,26 @@
-error: type/const mismatch in equality bind of associated field
+error: mismatch in bind of associated constant, got type
   --> $DIR/assoc-const-ty-mismatch.rs:23:15
    |
 LL | fn foo<F: Foo<N=usize>>() {}
-   |               ^^^^^^^ type/const Mismatch
+   |               ^^^^^^^
+   |
+note: associated constant defined here does not match type
+  --> $DIR/assoc-const-ty-mismatch.rs:5:3
+   |
+LL |   const N: usize;
+   |   ^^^^^^^^^^^^^^^
 
-error: type/const mismatch in equality bind of associated field
+error: mismatch in bind of associated type, got const
   --> $DIR/assoc-const-ty-mismatch.rs:25:18
    |
 LL | fn foo2<F: FooTy<T=3usize>>() {}
-   |                  ^^^^^^^^ type/const Mismatch
+   |                  ^^^^^^^^
+   |
+note: associated type defined here does not match const
+  --> $DIR/assoc-const-ty-mismatch.rs:9:3
+   |
+LL |   type T;
+   |   ^^^^^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr
index c14fd7c9ee8..0cccc6b38a3 100644
--- a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr
+++ b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<ModelT as Vehicle>::Color == Blue`
 LL | fn b() { blue_car(ModelT); }
    |          ^^^^^^^^ type mismatch resolving `<ModelT as Vehicle>::Color == Blue`
    |
-note: expected struct `Blue`, found struct `Black`
+note: expected this to be `Blue`
   --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:16:40
    |
 LL | impl Vehicle for ModelT { type Color = Black; }
@@ -21,7 +21,7 @@ error[E0271]: type mismatch resolving `<ModelU as Vehicle>::Color == Black`
 LL | fn c() { black_car(ModelU); }
    |          ^^^^^^^^^ type mismatch resolving `<ModelU as Vehicle>::Color == Black`
    |
-note: expected struct `Black`, found struct `Blue`
+note: expected this to be `Black`
   --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:21:40
    |
 LL | impl Vehicle for ModelU { type Color = Blue; }
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 64f7a575cd5..521907a6044 100644
--- a/src/test/ui/associated-types/associated-types-eq-3.stderr
+++ b/src/test/ui/associated-types/associated-types-eq-3.stderr
@@ -19,7 +19,7 @@ error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
 LL |     foo1(a);
    |     ^^^^ type mismatch resolving `<isize as Foo>::A == Bar`
    |
-note: expected struct `Bar`, found `usize`
+note: expected this to be `Bar`
   --> $DIR/associated-types-eq-3.rs:12:14
    |
 LL |     type A = usize;
@@ -36,7 +36,7 @@ error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
 LL |     baz(&a);
    |         ^^ type mismatch resolving `<isize as Foo>::A == Bar`
    |
-note: expected struct `Bar`, found `usize`
+note: expected this to be `Bar`
   --> $DIR/associated-types-eq-3.rs:12:14
    |
 LL |     type A = usize;
diff --git a/src/test/ui/associated-types/associated-types-eq-hr.stderr b/src/test/ui/associated-types/associated-types-eq-hr.stderr
index cc69c92b930..1329e1382fd 100644
--- a/src/test/ui/associated-types/associated-types-eq-hr.stderr
+++ b/src/test/ui/associated-types/associated-types-eq-hr.stderr
@@ -4,11 +4,13 @@ error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize
 LL |     foo::<UintStruct>();
    |     ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
    |
-note: expected `isize`, found `usize`
+note: expected this to be `&isize`
   --> $DIR/associated-types-eq-hr.rs:26:14
    |
 LL |     type A = &'a usize;
    |              ^^^^^^^^^
+   = note: expected reference `&isize`
+              found reference `&usize`
 note: required by a bound in `foo`
   --> $DIR/associated-types-eq-hr.rs:45:36
    |
@@ -24,11 +26,13 @@ error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>
 LL |     bar::<IntStruct>();
    |     ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
    |
-note: expected `usize`, found `isize`
+note: expected this to be `&usize`
   --> $DIR/associated-types-eq-hr.rs:14:14
    |
 LL |     type A = &'a isize;
    |              ^^^^^^^^^
+   = note: expected reference `&usize`
+              found reference `&isize`
 note: required by a bound in `bar`
   --> $DIR/associated-types-eq-hr.rs:52:36
    |
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 4e4b8be462b..516057e53d2 100644
--- a/src/test/ui/associated-types/associated-types-issue-20346.stderr
+++ b/src/test/ui/associated-types/associated-types-issue-20346.stderr
@@ -7,12 +7,12 @@ LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) {
 LL |     is_iterator_of::<Option<T>, _>(&adapter);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>`
    |
-note: expected enum `Option`, found type parameter `T`
+note: expected this to be `Option<T>`
   --> $DIR/associated-types-issue-20346.rs:23:17
    |
 LL |     type Item = T;
    |                 ^
-   = note: expected type `Option<T>`
+   = note: expected enum `Option<T>`
               found type `T`
 note: required by a bound in `is_iterator_of`
   --> $DIR/associated-types-issue-20346.rs:15:34
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 eba9483ff22..922cf88a049 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
@@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<T as Foo>::Y == i32`
 LL |     want_y(t);
    |     ^^^^^^ expected `i32`, found associated type
    |
-   = note: expected type `i32`
-              found type `<T as Foo>::Y`
+   = note:         expected type `i32`
+           found associated type `<T as Foo>::Y`
 note: required by a bound in `want_y`
   --> $DIR/associated-types-multiple-types-one-trait.rs:44:17
    |
@@ -22,8 +22,8 @@ error[E0271]: type mismatch resolving `<T as Foo>::X == u32`
 LL |     want_x(t);
    |     ^^^^^^ expected `u32`, found associated type
    |
-   = note: expected type `u32`
-              found type `<T as Foo>::X`
+   = note:         expected type `u32`
+           found associated type `<T as Foo>::X`
 note: required by a bound in `want_x`
   --> $DIR/associated-types-multiple-types-one-trait.rs:42:17
    |
diff --git a/src/test/ui/associated-types/hr-associated-type-projection-1.stderr b/src/test/ui/associated-types/hr-associated-type-projection-1.stderr
index 6c1881fcd29..9c29e969de8 100644
--- a/src/test/ui/associated-types/hr-associated-type-projection-1.stderr
+++ b/src/test/ui/associated-types/hr-associated-type-projection-1.stderr
@@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
 LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
    |      - this type parameter      ^^^^^^^^^^^^^^^^^ expected associated type, found type parameter `T`
    |
-   = note: expected type `<T as Deref>::Target`
-              found type `T`
+   = note: expected associated type `<T as Deref>::Target`
+               found type parameter `T`
 help: consider further restricting this bound
    |
 LL | impl<T: Copy + std::ops::Deref + Deref<Target = T>> UnsafeCopy<'_, T> for T {
diff --git a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr
index 28ef77ae137..283ecea735d 100644
--- a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr
+++ b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr
@@ -1,11 +1,14 @@
 error[E0271]: type mismatch resolving `<impl Bar as Foo>::Item == i32`
   --> $DIR/impl-trait-return-missing-constraint.rs:25:13
    |
+LL | fn bar() -> impl Bar {
+   |             -------- the found opaque type
+...
 LL | fn baz() -> impl Bar<Item = i32> {
    |             ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found associated type
    |
-   = note: expected type `i32`
-              found type `<impl Bar as Foo>::Item`
+   = note:         expected type `i32`
+           found associated type `<impl Bar as Foo>::Item`
 help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32`
    |
 LL | fn bar() -> impl Bar<Item = i32> {
diff --git a/src/test/ui/associated-types/issue-44153.stderr b/src/test/ui/associated-types/issue-44153.stderr
index 9244b4821f3..200efbe02e6 100644
--- a/src/test/ui/associated-types/issue-44153.stderr
+++ b/src/test/ui/associated-types/issue-44153.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<() as Array>::Element == &()`
 LL |     <() as Visit>::visit();
    |     ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Array>::Element == &()`
    |
-note: expected `&()`, found `()`
+note: expected this to be `&()`
   --> $DIR/issue-44153.rs:10:20
    |
 LL |     type Element = ();
diff --git a/src/test/ui/associated-types/issue-72806.stderr b/src/test/ui/associated-types/issue-72806.stderr
index 67b1295d0fe..e95943f34d5 100644
--- a/src/test/ui/associated-types/issue-72806.stderr
+++ b/src/test/ui/associated-types/issue-72806.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == char`
 LL |     type Sibling = Foo2;
    |                    ^^^^ type mismatch resolving `<Foo2 as Bar2>::Ok == char`
    |
-note: expected `char`, found `u32`
+note: expected this to be `char`
   --> $DIR/issue-72806.rs:18:15
    |
 LL |     type Ok = u32;
diff --git a/src/test/ui/associated-types/issue-87261.stderr b/src/test/ui/associated-types/issue-87261.stderr
index e387d34266e..c00b48abc1c 100644
--- a/src/test/ui/associated-types/issue-87261.stderr
+++ b/src/test/ui/associated-types/issue-87261.stderr
@@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<A as Trait>::Associated == ()`
 LL |     accepts_trait(a);
    |     ^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<A as Trait>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<A as Trait>::Associated`
 note: required by a bound in `accepts_trait`
   --> $DIR/issue-87261.rs:43:27
    |
@@ -22,8 +22,8 @@ error[E0271]: type mismatch resolving `<B as Trait>::Associated == ()`
 LL |     accepts_trait(b);
    |     ^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<B as Trait>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<B as Trait>::Associated`
    = help: consider constraining the associated type `<B as Trait>::Associated` to `()`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 note: required by a bound in `accepts_trait`
@@ -38,8 +38,8 @@ error[E0271]: type mismatch resolving `<C as Trait>::Associated == ()`
 LL |     accepts_trait(c);
    |     ^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<C as Trait>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<C as Trait>::Associated`
 note: required by a bound in `accepts_trait`
   --> $DIR/issue-87261.rs:43:27
    |
@@ -56,8 +56,8 @@ error[E0271]: type mismatch resolving `<D as Trait>::Associated == ()`
 LL |     accepts_trait(d);
    |     ^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<D as Trait>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<D as Trait>::Associated`
    = help: consider constraining the associated type `<D as Trait>::Associated` to `()`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 note: required by a bound in `accepts_trait`
@@ -72,8 +72,8 @@ error[E0271]: type mismatch resolving `<E as GenericTrait<()>>::Associated == ()
 LL |     accepts_generic_trait(e);
    |     ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<E as GenericTrait<()>>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<E as GenericTrait<()>>::Associated`
 note: required by a bound in `accepts_generic_trait`
   --> $DIR/issue-87261.rs:44:46
    |
@@ -90,8 +90,8 @@ error[E0271]: type mismatch resolving `<F as GenericTrait<()>>::Associated == ()
 LL |     accepts_generic_trait(f);
    |     ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<F as GenericTrait<()>>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<F as GenericTrait<()>>::Associated`
 note: required by a bound in `accepts_generic_trait`
   --> $DIR/issue-87261.rs:44:46
    |
@@ -108,8 +108,8 @@ error[E0271]: type mismatch resolving `<G as GenericTrait<()>>::Associated == ()
 LL |     accepts_generic_trait(g);
    |     ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<G as GenericTrait<()>>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<G as GenericTrait<()>>::Associated`
    = help: consider constraining the associated type `<G as GenericTrait<()>>::Associated` to `()`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 note: required by a bound in `accepts_generic_trait`
@@ -121,11 +121,14 @@ LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
 error[E0271]: type mismatch resolving `<impl Trait as Trait>::Associated == ()`
   --> $DIR/issue-87261.rs:79:5
    |
+LL | fn returns_opaque() -> impl Trait + 'static {
+   |                        -------------------- the found opaque type
+...
 LL |     accepts_trait(returns_opaque());
    |     ^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<impl Trait as Trait>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<impl Trait as Trait>::Associated`
 note: required by a bound in `accepts_trait`
   --> $DIR/issue-87261.rs:43:27
    |
@@ -139,11 +142,14 @@ LL | fn returns_opaque() -> impl Trait<Associated = ()> + 'static {
 error[E0271]: type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()`
   --> $DIR/issue-87261.rs:82:5
    |
+LL | fn returns_opaque_derived() -> impl DerivedTrait + 'static {
+   |                                --------------------------- the found opaque type
+...
 LL |     accepts_trait(returns_opaque_derived());
    |     ^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<impl DerivedTrait as Trait>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<impl DerivedTrait as Trait>::Associated`
 note: required by a bound in `accepts_trait`
   --> $DIR/issue-87261.rs:43:27
    |
@@ -157,11 +163,14 @@ LL | fn returns_opaque_derived() -> impl DerivedTrait<Associated = ()> + 'static
 error[E0271]: type mismatch resolving `<impl Foo + Trait as Trait>::Associated == ()`
   --> $DIR/issue-87261.rs:85:5
    |
+LL | fn returns_opaque_foo() -> impl Trait + Foo {
+   |                            ---------------- the found opaque type
+...
 LL |     accepts_trait(returns_opaque_foo());
    |     ^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<impl Foo + Trait as Trait>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<impl Foo + Trait as Trait>::Associated`
 note: required by a bound in `accepts_trait`
   --> $DIR/issue-87261.rs:43:27
    |
@@ -175,11 +184,14 @@ LL | fn returns_opaque_foo() -> impl Trait<Associated = ()> + Foo {
 error[E0271]: type mismatch resolving `<impl Foo + DerivedTrait as Trait>::Associated == ()`
   --> $DIR/issue-87261.rs:88:5
    |
+LL | fn returns_opaque_derived_foo() -> impl DerivedTrait + Foo {
+   |                                    ----------------------- the found opaque type
+...
 LL |     accepts_trait(returns_opaque_derived_foo());
    |     ^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<impl Foo + DerivedTrait as Trait>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<impl Foo + DerivedTrait as Trait>::Associated`
    = help: consider constraining the associated type `<impl Foo + DerivedTrait as Trait>::Associated` to `()`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 note: required by a bound in `accepts_trait`
@@ -191,11 +203,14 @@ LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
 error[E0271]: type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()`
   --> $DIR/issue-87261.rs:91:5
    |
+LL | fn returns_opaque_generic() -> impl GenericTrait<()> + 'static {
+   |                                ------------------------------- the found opaque type
+...
 LL |     accepts_generic_trait(returns_opaque_generic());
    |     ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<impl GenericTrait<()> as GenericTrait<()>>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<impl GenericTrait<()> as GenericTrait<()>>::Associated`
 note: required by a bound in `accepts_generic_trait`
   --> $DIR/issue-87261.rs:44:46
    |
@@ -209,11 +224,14 @@ LL | fn returns_opaque_generic() -> impl GenericTrait<(), Associated = ()> + 'st
 error[E0271]: type mismatch resolving `<impl Foo + GenericTrait<()> as GenericTrait<()>>::Associated == ()`
   --> $DIR/issue-87261.rs:94:5
    |
+LL | fn returns_opaque_generic_foo() -> impl GenericTrait<()> + Foo {
+   |                                    --------------------------- the found opaque type
+...
 LL |     accepts_generic_trait(returns_opaque_generic_foo());
    |     ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<impl Foo + GenericTrait<()> as GenericTrait<()>>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<impl Foo + GenericTrait<()> as GenericTrait<()>>::Associated`
 note: required by a bound in `accepts_generic_trait`
   --> $DIR/issue-87261.rs:44:46
    |
@@ -227,11 +245,14 @@ LL | fn returns_opaque_generic_foo() -> impl GenericTrait<(), Associated = ()> +
 error[E0271]: type mismatch resolving `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated == ()`
   --> $DIR/issue-87261.rs:97:5
    |
+LL | fn returns_opaque_generic_duplicate() -> impl GenericTrait<()> + GenericTrait<u8> {
+   |                                          ---------------------------------------- the found opaque type
+...
 LL |     accepts_generic_trait(returns_opaque_generic_duplicate());
    |     ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
    |
-   = note: expected type `()`
-              found type `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated`
+   = note:    expected unit type `()`
+           found associated type `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated`
    = help: consider constraining the associated type `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated` to `()`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 note: required by a bound in `accepts_generic_trait`
diff --git a/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr b/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr
index 9fd474edff9..9afbe82c321 100644
--- a/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr
+++ b/src/test/ui/associated-types/point-at-type-on-obligation-failure.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
 LL |     type Sibling = Foo2;
    |                    ^^^^ type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
    |
-note: expected `()`, found `u32`
+note: expected this to be `()`
   --> $DIR/point-at-type-on-obligation-failure.rs:18:15
    |
 LL |     type Ok = u32;
diff --git a/src/test/ui/error-codes/E0271.stderr b/src/test/ui/error-codes/E0271.stderr
index ba5632f47a7..9c9c7237d71 100644
--- a/src/test/ui/error-codes/E0271.stderr
+++ b/src/test/ui/error-codes/E0271.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<i8 as Trait>::AssociatedType == u32`
 LL |     foo(3_i8);
    |     ^^^ type mismatch resolving `<i8 as Trait>::AssociatedType == u32`
    |
-note: expected `u32`, found `&str`
+note: expected this to be `u32`
   --> $DIR/E0271.rs:7:43
    |
 LL | impl Trait for i8 { type AssociatedType = &'static str; }
diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.stderr b/src/test/ui/generator/type-mismatch-signature-deduction.stderr
index 3b447a17d52..3f1f33a3b12 100644
--- a/src/test/ui/generator/type-mismatch-signature-deduction.stderr
+++ b/src/test/ui/generator/type-mismatch-signature-deduction.stderr
@@ -19,7 +19,7 @@ LL | fn foo() -> impl Generator<Return = i32> {
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found enum `Result`
    |
    = note: expected type `i32`
-              found type `Result<{integer}, _>`
+              found enum `Result<{integer}, _>`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr b/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr
index ee72c8f5d23..8e0f2371601 100644
--- a/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr
+++ b/src/test/ui/generic-associated-types/issue-68656-unsized-values.stderr
@@ -6,8 +6,8 @@ LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<T> for T {
 LL |     type Item<'a> = T;
    |                     ^ expected type parameter `T`, found associated type
    |
-   = note: expected type `T`
-              found type `<T as Deref>::Target`
+   = note: expected type parameter `T`
+             found associated type `<T as Deref>::Target`
 note: required by a bound in `UnsafeCopy::Item`
   --> $DIR/issue-68656-unsized-values.rs:6:36
    |
diff --git a/src/test/ui/generic-associated-types/issue-74684-2.stderr b/src/test/ui/generic-associated-types/issue-74684-2.stderr
index 7ca54373392..f0e03e73f0b 100644
--- a/src/test/ui/generic-associated-types/issue-74684-2.stderr
+++ b/src/test/ui/generic-associated-types/issue-74684-2.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<{integer} as Fun>::F<'_> == [u8]`
 LL |     bug(Box::new(x));
    |     ^^^ type mismatch resolving `<{integer} as Fun>::F<'_> == [u8]`
    |
-note: expected slice `[u8]`, found `i32`
+note: expected this to be `[u8]`
   --> $DIR/issue-74684-2.rs:10:18
    |
 LL |     type F<'a> = i32;
diff --git a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr
index 7a788fbd856..0ebba37e4ec 100644
--- a/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr
+++ b/src/test/ui/hrtb/issue-62203-hrtb-ice.stderr
@@ -4,13 +4,13 @@ error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb
 LL |     let v = Unit2.m(
    |                   ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
    |
-note: expected associated type, found struct `Unit4`
+note: expected this to be `<_ as Ty<'_>>::V`
   --> $DIR/issue-62203-hrtb-ice.rs:21:14
    |
 LL |     type O = T::Output;
    |              ^^^^^^^^^
-   = note: expected type `<_ as Ty<'_>>::V`
-              found type `Unit4`
+   = note: expected associated type `<_ as Ty<'_>>::V`
+                       found struct `Unit4`
    = help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` or calling a method that returns `<_ as Ty<'_>>::V`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
 note: required by a bound in `T1::m`
diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr
index 788c7419559..afa21c1a858 100644
--- a/src/test/ui/impl-trait/bound-normalization-fail.stderr
+++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr
@@ -4,13 +4,13 @@ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as imp
 LL |     fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> {
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc`
    |
-note: expected associated type, found `()`
+note: expected this to be `<T as impl_trait::Trait>::Assoc`
   --> $DIR/bound-normalization-fail.rs:14:19
    |
 LL |     type Output = T;
    |                   ^
-   = note: expected type `<T as impl_trait::Trait>::Assoc`
-              found type `()`
+   = note: expected associated type `<T as impl_trait::Trait>::Assoc`
+                    found unit type `()`
 help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc` to `()`
    |
 LL |     fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> {
@@ -28,13 +28,13 @@ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lif
 LL |     fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> {
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc`
    |
-note: expected associated type, found `()`
+note: expected this to be `<T as lifetimes::Trait<'static>>::Assoc`
   --> $DIR/bound-normalization-fail.rs:14:19
    |
 LL |     type Output = T;
    |                   ^
-   = note: expected type `<T as lifetimes::Trait<'static>>::Assoc`
-              found type `()`
+   = note: expected associated type `<T as lifetimes::Trait<'static>>::Assoc`
+                    found unit type `()`
 help: consider constraining the associated type `<T as lifetimes::Trait<'static>>::Assoc` to `()`
    |
 LL |     fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> {
diff --git a/src/test/ui/impl-trait/issues/issue-70877.stderr b/src/test/ui/impl-trait/issues/issue-70877.stderr
index c187ca6ada8..fe48e92da5e 100644
--- a/src/test/ui/impl-trait/issues/issue-70877.stderr
+++ b/src/test/ui/impl-trait/issues/issue-70877.stderr
@@ -1,16 +1,19 @@
 error[E0271]: type mismatch resolving `<Bar as Iterator>::Item == Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
   --> $DIR/issue-70877.rs:7:12
    |
+LL | type FooRet = impl std::fmt::Debug;
+   |               -------------------- the found opaque type
+...
 LL | type Foo = impl Iterator<Item = FooItem>;
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Bar as Iterator>::Item == Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
    |
-note: expected enum `Option`, found opaque type
+note: expected this to be `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
   --> $DIR/issue-70877.rs:13:17
    |
 LL |     type Item = FooItem;
    |                 ^^^^^^^
-   = note: expected type `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
-              found type `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> impl Debug + 'static)>`
+   = note: expected struct `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
+              found struct `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> impl Debug + 'static)>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
index bf5a182803a..65daabe419d 100644
--- a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
+++ b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<() as Super>::Assoc == ()`
 LL | fn test() -> impl Test {
    |              ^^^^^^^^^ type mismatch resolving `<() as Super>::Assoc == ()`
    |
-note: expected `()`, found `u8`
+note: expected this to be `()`
   --> $DIR/projection-mismatch-in-impl-where-clause.rs:6:18
    |
 LL |     type Assoc = u8;
diff --git a/src/test/ui/issues/issue-31173.stderr b/src/test/ui/issues/issue-31173.stderr
index 6d77ab01e83..982b6118ce6 100644
--- a/src/test/ui/issues/issue-31173.stderr
+++ b/src/test/ui/issues/issue-31173.stderr
@@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<TakeWhile<&mut std::vec::IntoIter<u8>, [
 LL |         .cloned()
    |          ^^^^^^ expected reference, found `u8`
    |
-   = note: expected type `&_`
-              found type `u8`
+   = note: expected reference `&_`
+                   found type `u8`
 note: required by a bound in `cloned`
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
    |
diff --git a/src/test/ui/issues/issue-33941.stderr b/src/test/ui/issues/issue-33941.stderr
index 5b86981ec78..c6650d60c21 100644
--- a/src/test/ui/issues/issue-33941.stderr
+++ b/src/test/ui/issues/issue-33941.stderr
@@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _,
 LL |     for _ in HashMap::new().iter().cloned() {}
    |                                    ^^^^^^ expected reference, found tuple
    |
-   = note: expected type `&_`
-              found type `(&_, &_)`
+   = note: expected reference `&_`
+                  found tuple `(&_, &_)`
 note: required by a bound in `cloned`
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
    |
@@ -18,8 +18,8 @@ error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _,
 LL |     for _ in HashMap::new().iter().cloned() {}
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
    |
-   = note: expected type `(&_, &_)`
-              found type `&_`
+   = note:  expected tuple `(&_, &_)`
+           found reference `&_`
    = note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
    = note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
 
diff --git a/src/test/ui/issues/issue-39970.stderr b/src/test/ui/issues/issue-39970.stderr
index 73fca41b0c0..1f64a90bc1c 100644
--- a/src/test/ui/issues/issue-39970.stderr
+++ b/src/test/ui/issues/issue-39970.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()`
 LL |     <() as Visit>::visit();
    |     ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()`
    |
-note: expected `()`, found `&()`
+note: expected this to be `()`
   --> $DIR/issue-39970.rs:10:20
    |
 LL |     type Element = &'a ();
diff --git a/src/test/ui/issues/issue-67039-unsound-pin-partialeq.stderr b/src/test/ui/issues/issue-67039-unsound-pin-partialeq.stderr
index 1c7c311b5d2..733456a1a8b 100644
--- a/src/test/ui/issues/issue-67039-unsound-pin-partialeq.stderr
+++ b/src/test/ui/issues/issue-67039-unsound-pin-partialeq.stderr
@@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<Rc<Apple> as Deref>::Target == Rc<Apple>
 LL |     let _ = Pin::new(Apple) == Rc::pin(Apple);
    |                             ^^ expected struct `Apple`, found struct `Rc`
    |
-   = note: expected type `Apple`
-              found type `Rc<Apple>`
+   = note: expected struct `Apple`
+              found struct `Rc<Apple>`
    = note: required because of the requirements on the impl of `PartialEq<Pin<Rc<Apple>>>` for `Pin<Apple>`
 
 error: aborting due to previous error
diff --git a/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr b/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr
index 24d45a30623..78d1a3caf4a 100644
--- a/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr
+++ b/src/test/ui/never_type/fallback-closure-wrap.fallback.stderr
@@ -8,8 +8,8 @@ LL | |         panic!("Can't connect to server.");
 LL | |     }) as Box<dyn FnMut()>);
    | |______^ expected `()`, found `!`
    |
-   = note: expected type `()`
-              found type `!`
+   = note: expected unit type `()`
+                   found type `!`
    = note: required for the cast to the object type `dyn FnMut()`
 
 error: aborting due to previous error
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.stderr
index bf7691e7f1b..4251c1a1ed6 100644
--- a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.stderr
+++ b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<i32 as Is>::T == i64`
 LL |     is_obj(x)
    |     ^^^^^^ type mismatch resolving `<i32 as Is>::T == i64`
    |
-note: expected `i64`, found `i32`
+note: expected this to be `i64`
   --> $DIR/check-trait-object-bounds-5.rs:9:14
    |
 LL |     type T = U;
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.stderr
index 016de72847d..5b23a513eea 100644
--- a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.stderr
+++ b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.stderr
@@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<i32 as Is>::T == i64`
 LL |     is_obj(x)
    |     ^^^^^^ type mismatch resolving `<i32 as Is>::T == i64`
    |
-note: expected `i64`, found `i32`
+note: expected this to be `i64`
   --> $DIR/check-trait-object-bounds-6.rs:9:14
    |
 LL |     type T = U;
diff --git a/src/test/ui/type-alias-impl-trait/issue-63355.stderr b/src/test/ui/type-alias-impl-trait/issue-63355.stderr
index 860a371b086..6fc6b4bfe1f 100644
--- a/src/test/ui/type-alias-impl-trait/issue-63355.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-63355.stderr
@@ -1,16 +1,18 @@
 error[E0271]: type mismatch resolving `<() as Bar>::Foo == ()`
   --> $DIR/issue-63355.rs:34:20
    |
+LL | pub type FooImpl = impl Foo;
+   |                    -------- the found opaque type
 LL | pub type BarImpl = impl Bar<Foo = FooImpl>;
    |                    ^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Bar>::Foo == ()`
    |
-note: expected `()`, found opaque type
+note: expected this to be `()`
   --> $DIR/issue-63355.rs:24:16
    |
 LL |     type Foo = FooImpl;
    |                ^^^^^^^
-   = note: expected type `()`
-              found type `impl Foo`
+   = note: expected unit type `()`
+            found opaque type `impl Foo`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/issue-89686.stderr b/src/test/ui/type-alias-impl-trait/issue-89686.stderr
index 56e6a5420dd..19ed9a7476c 100644
--- a/src/test/ui/type-alias-impl-trait/issue-89686.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-89686.stderr
@@ -3,9 +3,17 @@ error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as
    |
 LL | type G<'a, T> = impl Future<Output = ()>;
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
+...
+LL |         async move { self.f().await }
+   |                    ------------------ the found `async` block
    |
-   = note: expected type `()`
-              found type `<impl Future<Output = [async output]> as Future>::Output`
+  ::: $SRC_DIR/core/src/future/mod.rs:LL:COL
+   |
+LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
+   |                                           ------------------------------- the found opaque type
+   |
+   = note:    expected unit type `()`
+           found associated type `<impl Future<Output = [async output]> as Future>::Output`
    = help: consider constraining the associated type `<impl Future<Output = [async output]> as Future>::Output` to `()`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html