From eb53721a34d1d910b900aa753e0a00dc72ef41ac Mon Sep 17 00:00:00 2001
From: jyn <github@jyn.dev>
Date: Thu, 7 Dec 2023 22:54:41 -0500
Subject: [PATCH] recurse into refs when comparing tys for diagnostics

---
 .../src/infer/error_reporting/mod.rs          | 94 ++++++++++---------
 ...ssociated-const-impl-wrong-lifetime.stderr |  4 +-
 .../dont-suggest-cyclic-constraint.stderr     |  4 +-
 ...nc-example-desugared-boxed-in-trait.stderr |  4 +-
 ...regions-bound-missing-bound-in-impl.stderr |  8 +-
 tests/ui/box/issue-82446.stderr               |  4 +-
 .../expect-fn-supply-fn.stderr                | 12 +--
 tests/ui/closures/multiple-fn-bounds.stderr   |  4 +-
 tests/ui/fn/fn-pointer-mismatch.rs            | 12 +--
 tests/ui/fn/fn-pointer-mismatch.stderr        | 16 ++--
 .../issue-88360.stderr                        |  4 +-
 ...pe.bound_a_b_ret_a_vs_bound_a_ret_a.stderr |  4 +-
 .../hr-subtype.bound_a_vs_free_x.stderr       |  4 +-
 .../trait-bounds/hrtb-exists-forall-fn.stderr |  4 +-
 .../in-trait/specialization-broken.stderr     |  4 +-
 ...s-impl-trait-declaration-too-subtle.stderr |  8 +-
 tests/ui/implied-bounds/issue-100690.stderr   |  4 +-
 tests/ui/issues/issue-17905-2.stderr          |  8 +-
 tests/ui/issues/issue-20225.stderr            | 12 +--
 tests/ui/issues/issue-24322.stderr            |  4 +-
 tests/ui/issues/issue-37884.stderr            |  4 +-
 ...else-binding-explicit-mut-annotated.stderr |  8 +-
 tests/ui/lifetimes/issue-79187-2.stderr       |  8 +-
 .../lub-glb/old-lub-glb-hr-noteq1.leak.stderr |  4 +-
 .../old-lub-glb-hr-noteq1.noleak.stderr       |  4 +-
 .../lub-glb/old-lub-glb-hr-noteq2.leak.stderr |  4 +-
 .../field-projection-mutating-context.stderr  |  4 +-
 .../closure-arg-type-mismatch.stderr          |  4 +-
 .../ui/mismatched_types/issue-36053-2.stderr  |  4 +-
 .../mismatched_types/normalize-fn-sig.stderr  |  4 +-
 ...ne-call-on-ref-due-to-missing-bound.stderr |  4 +-
 .../ui/nll/relate_tys/hr-fn-aaa-as-aba.stderr |  8 +-
 .../nll/relate_tys/universe-violation.stderr  |  4 +-
 tests/ui/nll/trait-associated-constant.stderr |  4 +-
 .../ui/or-patterns/inconsistent-modes.stderr  |  4 +-
 ...issue-73553-misinterp-range-literal.stderr |  4 +-
 tests/ui/regions/issue-101280.stderr          |  4 +-
 ...lifetime-bounds-on-fns-where-clause.stderr |  4 +-
 ...lifetime-bounds-on-fns-where-clause.stderr |  4 +-
 .../regions-lifetime-bounds-on-fns.stderr     |  4 +-
 .../resolve-inconsistent-binding-mode.stderr  |  4 +-
 .../rfc-2005-default-binding-mode/lit.stderr  |  4 +-
 ...sue-92010-trait-bound-not-satisfied.stderr |  4 +-
 .../ui/static/static-reference-to-fn-1.stderr |  4 +-
 tests/ui/suggestions/as-ref.stderr            | 12 +--
 ...n-unconstrained-borrowed-type-param.stderr |  4 +-
 ...method-access-to-range-literal-typo.stderr |  4 +-
 .../suggestions/mut-ref-reassignment.stderr   |  4 +-
 tests/ui/traits/impl-method-mismatch.stderr   |  4 +-
 .../traits/wrong-mul-method-signature.stderr  |  4 +-
 .../type-check/point-at-inference-2.stderr    |  8 +-
 tests/ui/type/type-mismatch.stderr            | 24 ++---
 .../ui/typeck/bad-index-due-to-nested.stderr  |  8 +-
 .../typeck/mismatched-map-under-self.stderr   |  4 +-
 tests/ui/ufcs/ufcs-explicit-self-bad.rs       |  8 +-
 tests/ui/ufcs/ufcs-explicit-self-bad.stderr   | 20 ++--
 tests/ui/unsafe/unsafe-trait-impl.rs          |  4 +-
 tests/ui/unsafe/unsafe-trait-impl.stderr      |  4 +-
 58 files changed, 224 insertions(+), 214 deletions(-)

diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index ecaf9f4e16937..745c3d195ada7 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -1181,37 +1181,54 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
         debug!("cmp(t1={}, t1.kind={:?}, t2={}, t2.kind={:?})", t1, t1.kind(), t2, t2.kind());
 
         // helper functions
-        fn equals<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
-            match (a.kind(), b.kind()) {
-                (a, b) if *a == *b => true,
-                (&ty::Int(_), &ty::Infer(ty::InferTy::IntVar(_)))
-                | (
-                    &ty::Infer(ty::InferTy::IntVar(_)),
-                    &ty::Int(_) | &ty::Infer(ty::InferTy::IntVar(_)),
-                )
-                | (&ty::Float(_), &ty::Infer(ty::InferTy::FloatVar(_)))
-                | (
-                    &ty::Infer(ty::InferTy::FloatVar(_)),
-                    &ty::Float(_) | &ty::Infer(ty::InferTy::FloatVar(_)),
-                ) => true,
-                _ => false,
+        let recurse = |t1, t2, values: &mut (DiagnosticStyledString, DiagnosticStyledString)| {
+            let (x1, x2) = self.cmp(t1, t2);
+            (values.0).0.extend(x1.0);
+            (values.1).0.extend(x2.0);
+        };
+
+        fn fmt_region<'tcx>(region: ty::Region<'tcx>) -> String {
+            let mut r = region.to_string();
+            if r == "'_" {
+                r.clear();
+            } else {
+                r.push(' ');
             }
+            format!("&{r}")
         }
 
-        fn push_ty_ref<'tcx>(
+        fn push_ref<'tcx>(
             region: ty::Region<'tcx>,
-            ty: Ty<'tcx>,
             mutbl: hir::Mutability,
             s: &mut DiagnosticStyledString,
         ) {
-            let mut r = region.to_string();
-            if r == "'_" {
-                r.clear();
+            s.push_highlighted(fmt_region(region));
+            s.push_highlighted(mutbl.prefix_str());
+        }
+
+        fn cmp_ty_refs<'tcx>(
+            r1: ty::Region<'tcx>,
+            mut1: hir::Mutability,
+            r2: ty::Region<'tcx>,
+            mut2: hir::Mutability,
+            ss: &mut (DiagnosticStyledString, DiagnosticStyledString),
+        ) {
+            let (r1, r2) = (fmt_region(r1), fmt_region(r2));
+            if r1 != r2 {
+                ss.0.push_highlighted(r1);
+                ss.1.push_highlighted(r2);
             } else {
-                r.push(' ');
+                ss.0.push_normal(r1);
+                ss.1.push_normal(r2);
+            }
+
+            if mut1 != mut2 {
+                ss.0.push_highlighted(mut1.prefix_str());
+                ss.1.push_highlighted(mut2.prefix_str());
+            } else {
+                ss.0.push_normal(mut1.prefix_str());
+                ss.1.push_normal(mut2.prefix_str());
             }
-            s.push_highlighted(format!("&{}{}", r, mutbl.prefix_str()));
-            s.push_normal(ty.to_string());
         }
 
         // process starts here
@@ -1310,9 +1327,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                             values.0.push_normal("_");
                             values.1.push_normal("_");
                         } else {
-                            let (x1, x2) = self.cmp(ta1, ta2);
-                            (values.0).0.extend(x1.0);
-                            (values.1).0.extend(x2.0);
+                            recurse(ta1, ta2, &mut values);
                         }
                         self.push_comma(&mut values.0, &mut values.1, len, i);
                     }
@@ -1418,27 +1433,24 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                 }
             }
 
-            // When finding T != &T, highlight only the borrow
-            (&ty::Ref(r1, ref_ty1, mutbl1), _) if equals(ref_ty1, t2) => {
+            // When finding `&T != &T`, compare the references, then recurse into pointee type
+            (&ty::Ref(r1, ref_ty1, mutbl1), &ty::Ref(r2, ref_ty2, mutbl2)) => {
                 let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
-                push_ty_ref(r1, ref_ty1, mutbl1, &mut values.0);
-                values.1.push_normal(t2.to_string());
+                cmp_ty_refs(r1, mutbl1, r2, mutbl2, &mut values);
+                recurse(ref_ty1, ref_ty2, &mut values);
                 values
             }
-            (_, &ty::Ref(r2, ref_ty2, mutbl2)) if equals(t1, ref_ty2) => {
+            // When finding T != &T, highlight the borrow
+            (&ty::Ref(r1, ref_ty1, mutbl1), _) => {
                 let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
-                values.0.push_normal(t1.to_string());
-                push_ty_ref(r2, ref_ty2, mutbl2, &mut values.1);
+                push_ref(r1, mutbl1, &mut values.0);
+                recurse(ref_ty1, t2, &mut values);
                 values
             }
-
-            // When encountering &T != &mut T, highlight only the borrow
-            (&ty::Ref(r1, ref_ty1, mutbl1), &ty::Ref(r2, ref_ty2, mutbl2))
-                if equals(ref_ty1, ref_ty2) =>
-            {
+            (_, &ty::Ref(r2, ref_ty2, mutbl2)) => {
                 let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
-                push_ty_ref(r1, ref_ty1, mutbl1, &mut values.0);
-                push_ty_ref(r2, ref_ty2, mutbl2, &mut values.1);
+                push_ref(r2, mutbl2, &mut values.1);
+                recurse(t1, ref_ty2, &mut values);
                 values
             }
 
@@ -1448,9 +1460,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                     (DiagnosticStyledString::normal("("), DiagnosticStyledString::normal("("));
                 let len = args1.len();
                 for (i, (left, right)) in args1.iter().zip(args2).enumerate() {
-                    let (x1, x2) = self.cmp(left, right);
-                    (values.0).0.extend(x1.0);
-                    (values.1).0.extend(x2.0);
+                    recurse(left, right, &mut values);
                     self.push_comma(&mut values.0, &mut values.1, len, i);
                 }
                 if len == 1 {
diff --git a/tests/ui/associated-consts/associated-const-impl-wrong-lifetime.stderr b/tests/ui/associated-consts/associated-const-impl-wrong-lifetime.stderr
index 6037122a365d9..1304bef4211d0 100644
--- a/tests/ui/associated-consts/associated-const-impl-wrong-lifetime.stderr
+++ b/tests/ui/associated-consts/associated-const-impl-wrong-lifetime.stderr
@@ -4,8 +4,8 @@ error[E0308]: const not compatible with trait
 LL |     const NAME: &'a str = "unit";
    |     ^^^^^^^^^^^^^^^^^^^ lifetime mismatch
    |
-   = note: expected reference `&'static str`
-              found reference `&'a str`
+   = note: expected reference `&'static _`
+              found reference `&'a _`
 note: the lifetime `'a` as defined here...
   --> $DIR/associated-const-impl-wrong-lifetime.rs:6:6
    |
diff --git a/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr b/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr
index 606084aea34a6..1b4694a2125a6 100644
--- a/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr
+++ b/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
 LL |     debug_assert_eq!(iter.next(), Some(value));
    |                                   ^^^^^^^^^^^ expected `Option<<I as Iterator>::Item>`, found `Option<&<I as Iterator>::Item>`
    |
-   = note: expected enum `Option<<I as Iterator>::Item>`
-              found enum `Option<&<I as Iterator>::Item>`
+   = note: expected enum `Option<_>`
+              found enum `Option<&_>`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr
index 34aded73da55b..54df0edf5a8e4 100644
--- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr
+++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr
@@ -9,8 +9,8 @@ note: type in trait
    |
 LL |     fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>;
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: expected signature `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>`
-              found signature `fn(&i32) -> impl Future<Output = i32>`
+   = note: expected signature `fn(&_) -> Pin<Box<dyn Future<Output = i32>>>`
+              found signature `fn(&_) -> impl Future<Output = i32>`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/borrowck/regions-bound-missing-bound-in-impl.stderr b/tests/ui/borrowck/regions-bound-missing-bound-in-impl.stderr
index 7ebea3c03d36f..54d8f26f4ea8e 100644
--- a/tests/ui/borrowck/regions-bound-missing-bound-in-impl.stderr
+++ b/tests/ui/borrowck/regions-bound-missing-bound-in-impl.stderr
@@ -22,8 +22,8 @@ error[E0308]: method not compatible with trait
 LL |     fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
    |
-   = note: expected signature `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)`
-              found signature `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)`
+   = note: expected signature `fn(&'a _, Inv<'c>, Inv<'c>, Inv<'_>)`
+              found signature `fn(&'a _, Inv<'_>, Inv<'c>, Inv<'_>)`
 note: the lifetime `'c` as defined here...
   --> $DIR/regions-bound-missing-bound-in-impl.rs:27:24
    |
@@ -41,8 +41,8 @@ error[E0308]: method not compatible with trait
 LL |     fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
    |
-   = note: expected signature `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)`
-              found signature `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)`
+   = note: expected signature `fn(&'a _, Inv<'c>, Inv<'c>, Inv<'_>)`
+              found signature `fn(&'a _, Inv<'_>, Inv<'c>, Inv<'_>)`
 note: the lifetime `'c` as defined here...
   --> $DIR/regions-bound-missing-bound-in-impl.rs:27:24
    |
diff --git a/tests/ui/box/issue-82446.stderr b/tests/ui/box/issue-82446.stderr
index 568d23c2cb791..66daaceffb156 100644
--- a/tests/ui/box/issue-82446.stderr
+++ b/tests/ui/box/issue-82446.stderr
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
 LL |         val
    |         ^^^ expected `Box<dyn MyTrait>`, found `&Box<dyn MyTrait>`
    |
-   = note: expected struct `Box<(dyn MyTrait + 'static)>`
-           found reference `&Box<(dyn MyTrait + 'static)>`
+   = note: expected struct `Box<_>`
+           found reference `&Box<_>`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/closure-expected-type/expect-fn-supply-fn.stderr b/tests/ui/closure-expected-type/expect-fn-supply-fn.stderr
index e6ddc60689779..e010f0502f833 100644
--- a/tests/ui/closure-expected-type/expect-fn-supply-fn.stderr
+++ b/tests/ui/closure-expected-type/expect-fn-supply-fn.stderr
@@ -25,8 +25,8 @@ error[E0308]: mismatched types
 LL |     with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
    |                                                 ^ one type is more general than the other
    |
-   = note: expected fn pointer `fn(&u32)`
-              found fn pointer `for<'a> fn(&'a u32)`
+   = note: expected fn pointer `fn(&_)`
+              found fn pointer `for<'a> fn(&'a _)`
 
 error[E0308]: mismatched types
   --> $DIR/expect-fn-supply-fn.rs:39:50
@@ -34,8 +34,8 @@ error[E0308]: mismatched types
 LL |     with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
    |                                                  ^ one type is more general than the other
    |
-   = note: expected fn pointer `for<'a> fn(&'a u32)`
-              found fn pointer `fn(&u32)`
+   = note: expected fn pointer `for<'a> fn(&'a _)`
+              found fn pointer `fn(&_)`
 
 error[E0308]: mismatched types
   --> $DIR/expect-fn-supply-fn.rs:48:50
@@ -43,8 +43,8 @@ error[E0308]: mismatched types
 LL |     with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
    |                                                  ^ one type is more general than the other
    |
-   = note: expected fn pointer `for<'a> fn(&'a u32)`
-              found fn pointer `fn(&u32)`
+   = note: expected fn pointer `for<'a> fn(&'a _)`
+              found fn pointer `fn(&_)`
 
 error: aborting due to 5 previous errors
 
diff --git a/tests/ui/closures/multiple-fn-bounds.stderr b/tests/ui/closures/multiple-fn-bounds.stderr
index d510fc585f651..325652ef14ce5 100644
--- a/tests/ui/closures/multiple-fn-bounds.stderr
+++ b/tests/ui/closures/multiple-fn-bounds.stderr
@@ -6,8 +6,8 @@ LL |     foo(move |x| v);
    |     |
    |     expected due to this
    |
-   = note: expected closure signature `fn(char) -> _`
-              found closure signature `for<'a> fn(&'a char) -> _`
+   = note: expected closure signature `fn(_) -> _`
+              found closure signature `for<'a> fn(&'a _) -> _`
 note: closure inferred to have a different signature due to this bound
   --> $DIR/multiple-fn-bounds.rs:1:11
    |
diff --git a/tests/ui/fn/fn-pointer-mismatch.rs b/tests/ui/fn/fn-pointer-mismatch.rs
index 0597478cb4292..1c50d8b0f8b2d 100644
--- a/tests/ui/fn/fn-pointer-mismatch.rs
+++ b/tests/ui/fn/fn-pointer-mismatch.rs
@@ -35,20 +35,20 @@ fn main() {
     // suggest removing reference
     let c: fn(u32) -> u32 = &foo;
     //~^ ERROR mismatched types
-    //~| expected fn pointer `fn(u32) -> u32`
-    //~| found reference `&fn(u32) -> u32 {foo}`
+    //~| expected fn pointer `fn(_) -> _`
+    //~| found reference `&fn(_) -> _ {foo}`
 
     // suggest using reference
     let d: &fn(u32) -> u32 = foo;
     //~^ ERROR mismatched types
-    //~| expected reference `&fn(u32) -> u32`
-    //~| found fn item `fn(u32) -> u32 {foo}`
+    //~| expected reference `&fn(_) -> _`
+    //~| found fn item `fn(_) -> _ {foo}`
 
     // suggest casting with reference
     let e: &fn(u32) -> u32 = &foo;
     //~^ ERROR mismatched types
-    //~| expected reference `&fn(u32) -> u32`
-    //~| found reference `&fn(u32) -> u32 {foo}`
+    //~| expected reference `&fn(_) -> _`
+    //~| found reference `&fn(_) -> _ {foo}`
 
     // OK
     let mut z: fn(u32) -> u32 = foo as fn(u32) -> u32;
diff --git a/tests/ui/fn/fn-pointer-mismatch.stderr b/tests/ui/fn/fn-pointer-mismatch.stderr
index 87ece845b83a8..9cda11639d0f5 100644
--- a/tests/ui/fn/fn-pointer-mismatch.stderr
+++ b/tests/ui/fn/fn-pointer-mismatch.stderr
@@ -6,8 +6,8 @@ LL |     let g = if n % 2 == 0 { &foo } else { &bar };
    |                             |
    |                             expected because of this
    |
-   = note: expected reference `&fn(u32) -> u32 {foo}`
-              found reference `&fn(u32) -> u32 {bar}`
+   = note: expected reference `&fn(_) -> _ {foo}`
+              found reference `&fn(_) -> _ {bar}`
    = note: different fn items have unique types, even if their signatures are the same
    = help: consider casting both fn items to fn pointers using `as fn(u32) -> u32`
 
@@ -47,8 +47,8 @@ LL |     let c: fn(u32) -> u32 = &foo;
    |            |
    |            expected due to this
    |
-   = note: expected fn pointer `fn(u32) -> u32`
-               found reference `&fn(u32) -> u32 {foo}`
+   = note: expected fn pointer `fn(_) -> _`
+               found reference `&fn(_) -> _ {foo}`
 help: consider removing the reference
    |
 LL |     let c: fn(u32) -> u32 = foo;
@@ -62,8 +62,8 @@ LL |     let d: &fn(u32) -> u32 = foo;
    |            |
    |            expected due to this
    |
-   = note: expected reference `&fn(u32) -> u32`
-                found fn item `fn(u32) -> u32 {foo}`
+   = note: expected reference `&fn(_) -> _`
+                found fn item `fn(_) -> _ {foo}`
 help: consider using a reference
    |
 LL |     let d: &fn(u32) -> u32 = &foo;
@@ -77,8 +77,8 @@ LL |     let e: &fn(u32) -> u32 = &foo;
    |            |
    |            expected due to this
    |
-   = note: expected reference `&fn(u32) -> u32`
-              found reference `&fn(u32) -> u32 {foo}`
+   = note: expected reference `&fn(_) -> _`
+              found reference `&fn(_) -> _ {foo}`
    = note: fn items are distinct from fn pointers
 help: consider casting to a fn pointer
    |
diff --git a/tests/ui/generic-associated-types/issue-88360.stderr b/tests/ui/generic-associated-types/issue-88360.stderr
index 64cd55e684c65..49d36acadd657 100644
--- a/tests/ui/generic-associated-types/issue-88360.stderr
+++ b/tests/ui/generic-associated-types/issue-88360.stderr
@@ -9,8 +9,8 @@ LL |     fn copy(&self) -> Self::Gat<'_> where T: Copy {
 LL |         *self.test()
    |         ^^^^^^^^^^^^ expected `&T`, found type parameter `T`
    |
-   = note:   expected reference `&T`
-           found type parameter `T`
+   = note:   expected reference `&_`
+           found type parameter `_`
 help: consider removing deref here
    |
 LL -         *self.test()
diff --git a/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr b/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr
index 7cb7edfafeb66..d7f0860a026ac 100644
--- a/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr
+++ b/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr
@@ -8,8 +8,8 @@ LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u3
 LL | | for<'a>    fn(&'a u32, &'a u32) -> &'a u32) }
    | |_____________________________________________- in this macro invocation
    |
-   = note: expected enum `Option<for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32>`
-              found enum `Option<for<'a> fn(&'a u32, &'a u32) -> &'a u32>`
+   = note: expected enum `Option<for<'a, 'b> fn(&'a _, &'b _) -> &'a _>`
+              found enum `Option<for<'a> fn(&'a _, &'a _) -> &'a _>`
    = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 1 previous error
diff --git a/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_vs_free_x.stderr b/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_vs_free_x.stderr
index c6adbd91e7860..9b5ca3b2056aa 100644
--- a/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_vs_free_x.stderr
+++ b/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_vs_free_x.stderr
@@ -8,8 +8,8 @@ LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
 LL | | fn(&'x u32)) }
    | |______________- in this macro invocation
    |
-   = note: expected enum `Option<for<'a> fn(&'a u32)>`
-              found enum `Option<fn(&u32)>`
+   = note: expected enum `Option<for<'a> fn(&'a _)>`
+              found enum `Option<fn(&_)>`
    = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 1 previous error
diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr
index f269babcf71aa..2d6b8063f69ff 100644
--- a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr
+++ b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr
@@ -6,8 +6,8 @@ LL |     let _: for<'b> fn(&'b u32) = foo();
    |            |
    |            expected due to this
    |
-   = note: expected fn pointer `for<'b> fn(&'b u32)`
-              found fn pointer `fn(&u32)`
+   = note: expected fn pointer `for<'b> fn(&'b _)`
+              found fn pointer `fn(&_)`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr
index 25c0adeddbd7e..b8a8e2401b229 100644
--- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr
+++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr
@@ -15,8 +15,8 @@ note: type in trait
    |
 LL |     fn bar(&self) -> impl Sized;
    |                      ^^^^^^^^^^
-   = note: expected signature `fn(&U) -> impl Sized`
-              found signature `fn(&U) -> U`
+   = note: expected signature `fn(&_) -> impl Sized`
+              found signature `fn(&_) -> U`
 
 error: method with return-position `impl Trait` in trait cannot be specialized
   --> $DIR/specialization-broken.rs:15:5
diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr
index fe765271bd2fe..07ac1a37e75ce 100644
--- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr
+++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr
@@ -18,8 +18,8 @@ LL |         fn eq(&self, _other: &(Foo, i32)) -> bool {
    |                              expected `a::Bar`, found opaque type
    |                              help: change the parameter type to match the trait: `&(a::Bar, i32)`
    |
-   = note: expected signature `fn(&a::Bar, &(a::Bar, i32)) -> _`
-              found signature `fn(&a::Bar, &(a::Foo, i32)) -> _`
+   = note: expected signature `fn(&a::Bar, &(a::Bar, _)) -> _`
+              found signature `fn(&a::Bar, &(a::Foo, _)) -> _`
 
 error: unconstrained opaque type
   --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16
@@ -41,8 +41,8 @@ LL |         fn eq(&self, _other: &(Bar, i32)) -> bool {
    |                              expected opaque type, found `b::Bar`
    |                              help: change the parameter type to match the trait: `&(b::Foo, i32)`
    |
-   = note: expected signature `fn(&b::Bar, &(b::Foo, i32)) -> _`
-              found signature `fn(&b::Bar, &(b::Bar, i32)) -> _`
+   = note: expected signature `fn(&b::Bar, &(b::Foo, _)) -> _`
+              found signature `fn(&b::Bar, &(b::Bar, _)) -> _`
 note: this item must have the opaque type in its signature in order to be able to register hidden types
   --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:12
    |
diff --git a/tests/ui/implied-bounds/issue-100690.stderr b/tests/ui/implied-bounds/issue-100690.stderr
index 49f2fcd0a677b..df069d875cebc 100644
--- a/tests/ui/implied-bounds/issue-100690.stderr
+++ b/tests/ui/implied-bounds/issue-100690.stderr
@@ -6,8 +6,8 @@ LL |         real_dispatch(f)
    |         |
    |         required by a bound introduced by this call
    |
-   = note: expected a closure with arguments `(&mut UIView<'a, T>,)`
-              found a closure with arguments `(&mut UIView<'_, T>,)`
+   = note: expected a closure with arguments `(&mut UIView<'a, _>,)`
+              found a closure with arguments `(&mut UIView<'_, _>,)`
 note: required by a bound in `real_dispatch`
   --> $DIR/issue-100690.rs:9:8
    |
diff --git a/tests/ui/issues/issue-17905-2.stderr b/tests/ui/issues/issue-17905-2.stderr
index 88b5fbec6cf03..c66cb2224897d 100644
--- a/tests/ui/issues/issue-17905-2.stderr
+++ b/tests/ui/issues/issue-17905-2.stderr
@@ -4,8 +4,8 @@ error[E0308]: mismatched `self` parameter type
 LL |     fn say(self: &Pair<&str, isize>) {
    |                  ^^^^^^^^^^^^^^^^^^ lifetime mismatch
    |
-   = note: expected struct `Pair<&str, _>`
-              found struct `Pair<&str, _>`
+   = note: expected struct `Pair<&_, _>`
+              found struct `Pair<&_, _>`
 note: the anonymous lifetime defined here...
   --> $DIR/issue-17905-2.rs:8:24
    |
@@ -23,8 +23,8 @@ error[E0308]: mismatched `self` parameter type
 LL |     fn say(self: &Pair<&str, isize>) {
    |                  ^^^^^^^^^^^^^^^^^^ lifetime mismatch
    |
-   = note: expected struct `Pair<&str, _>`
-              found struct `Pair<&str, _>`
+   = note: expected struct `Pair<&_, _>`
+              found struct `Pair<&_, _>`
 note: the anonymous lifetime as defined here...
   --> $DIR/issue-17905-2.rs:5:5
    |
diff --git a/tests/ui/issues/issue-20225.stderr b/tests/ui/issues/issue-20225.stderr
index b34aa8e1ff5ae..2d24a5bbd50ab 100644
--- a/tests/ui/issues/issue-20225.stderr
+++ b/tests/ui/issues/issue-20225.stderr
@@ -9,8 +9,8 @@ LL |   extern "rust-call" fn call(&self, (_,): (T,)) {}
    |                                           expected `&'a T`, found type parameter `T`
    |                                           help: change the parameter type to match the trait: `(&'a T,)`
    |
-   = note: expected signature `extern "rust-call" fn(&Foo, (&'a T,))`
-              found signature `extern "rust-call" fn(&Foo, (T,))`
+   = note: expected signature `extern "rust-call" fn(&Foo, (&'a _,))`
+              found signature `extern "rust-call" fn(&Foo, (_,))`
 
 error[E0053]: method `call_mut` has an incompatible type for trait
   --> $DIR/issue-20225.rs:11:51
@@ -23,8 +23,8 @@ LL |   extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
    |                                                   expected `&'a T`, found type parameter `T`
    |                                                   help: change the parameter type to match the trait: `(&'a T,)`
    |
-   = note: expected signature `extern "rust-call" fn(&mut Foo, (&'a T,))`
-              found signature `extern "rust-call" fn(&mut Foo, (T,))`
+   = note: expected signature `extern "rust-call" fn(&mut Foo, (&'a _,))`
+              found signature `extern "rust-call" fn(&mut Foo, (_,))`
 
 error[E0053]: method `call_once` has an incompatible type for trait
   --> $DIR/issue-20225.rs:18:47
@@ -38,8 +38,8 @@ LL |   extern "rust-call" fn call_once(self, (_,): (T,)) {}
    |                                               expected `&'a T`, found type parameter `T`
    |                                               help: change the parameter type to match the trait: `(&'a T,)`
    |
-   = note: expected signature `extern "rust-call" fn(Foo, (&'a T,))`
-              found signature `extern "rust-call" fn(Foo, (T,))`
+   = note: expected signature `extern "rust-call" fn(Foo, (&'a _,))`
+              found signature `extern "rust-call" fn(Foo, (_,))`
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/ui/issues/issue-24322.stderr b/tests/ui/issues/issue-24322.stderr
index b260d02738854..d078069addcfb 100644
--- a/tests/ui/issues/issue-24322.stderr
+++ b/tests/ui/issues/issue-24322.stderr
@@ -6,8 +6,8 @@ LL |     let x: &fn(&B) -> u32 = &B::func;
    |            |
    |            expected due to this
    |
-   = note: expected reference `&for<'a> fn(&'a B) -> u32`
-              found reference `&for<'a> fn(&'a B) -> u32 {B::func}`
+   = note: expected reference `&for<'a> fn(&'a B) -> _`
+              found reference `&for<'a> fn(&'a B) -> _ {B::func}`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/issues/issue-37884.stderr b/tests/ui/issues/issue-37884.stderr
index 633abeb6f2266..b7c0095d682a2 100644
--- a/tests/ui/issues/issue-37884.stderr
+++ b/tests/ui/issues/issue-37884.stderr
@@ -4,8 +4,8 @@ error[E0308]: method not compatible with trait
 LL |     fn next(&'a mut self) -> Option<Self::Item>
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
    |
-   = note: expected signature `fn(&mut RepeatMut<'a, T>) -> Option<_>`
-              found signature `fn(&'a mut RepeatMut<'a, T>) -> Option<_>`
+   = note: expected signature `fn(&mut RepeatMut<'_, _>) -> Option<_>`
+              found signature `fn(&'a mut RepeatMut<'_, _>) -> Option<_>`
 note: the anonymous lifetime as defined here...
   --> $DIR/issue-37884.rs:6:5
    |
diff --git a/tests/ui/let-else/let-else-binding-explicit-mut-annotated.stderr b/tests/ui/let-else/let-else-binding-explicit-mut-annotated.stderr
index 065787cab08ff..1d41335036e56 100644
--- a/tests/ui/let-else/let-else-binding-explicit-mut-annotated.stderr
+++ b/tests/ui/let-else/let-else-binding-explicit-mut-annotated.stderr
@@ -6,8 +6,8 @@ LL |     let Some(n): &mut Option<i32> = &&Some(5i32) else { return };
    |                  |
    |                  expected due to this
    |
-   = note: expected mutable reference `&mut Option<i32>`
-                      found reference `&&Option<i32>`
+   = note: expected mutable reference `&mut Option<_>`
+                      found reference `&&Option<_>`
 
 error[E0308]: mismatched types
   --> $DIR/let-else-binding-explicit-mut-annotated.rs:13:37
@@ -17,8 +17,8 @@ LL |     let Some(n): &mut Option<i32> = &&mut Some(5i32) else { return };
    |                  |
    |                  expected due to this
    |
-   = note: expected mutable reference `&mut Option<i32>`
-                      found reference `&&mut Option<i32>`
+   = note: expected mutable reference `&mut Option<_>`
+                      found reference `&&mut Option<_>`
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/lifetimes/issue-79187-2.stderr b/tests/ui/lifetimes/issue-79187-2.stderr
index 86a4ac4132e44..e8115bb6b064f 100644
--- a/tests/ui/lifetimes/issue-79187-2.stderr
+++ b/tests/ui/lifetimes/issue-79187-2.stderr
@@ -54,8 +54,8 @@ error[E0308]: mismatched types
 LL |     take_foo(|a: &i32| a);
    |     ^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
    |
-   = note: expected reference `&i32`
-              found reference `&i32`
+   = note: expected reference `&_`
+              found reference `&_`
 note: the lifetime requirement is introduced here
   --> $DIR/issue-79187-2.rs:5:21
    |
@@ -68,8 +68,8 @@ error[E0308]: mismatched types
 LL |     take_foo(|a: &i32| -> &i32 { a });
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
    |
-   = note: expected reference `&i32`
-              found reference `&i32`
+   = note: expected reference `&_`
+              found reference `&_`
 note: the lifetime requirement is introduced here
   --> $DIR/issue-79187-2.rs:5:21
    |
diff --git a/tests/ui/lub-glb/old-lub-glb-hr-noteq1.leak.stderr b/tests/ui/lub-glb/old-lub-glb-hr-noteq1.leak.stderr
index c3d7960de5641..10e3fc9286895 100644
--- a/tests/ui/lub-glb/old-lub-glb-hr-noteq1.leak.stderr
+++ b/tests/ui/lub-glb/old-lub-glb-hr-noteq1.leak.stderr
@@ -12,8 +12,8 @@ LL | |
 LL | |     };
    | |_____- `match` arms have incompatible types
    |
-   = note: expected fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
-              found fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8`
+   = note: expected fn pointer `for<'a, 'b> fn(&'a _, &'b _) -> &'a _`
+              found fn pointer `for<'a> fn(&'a _, &'a _) -> &'a _`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/lub-glb/old-lub-glb-hr-noteq1.noleak.stderr b/tests/ui/lub-glb/old-lub-glb-hr-noteq1.noleak.stderr
index 8e4a514c7c6b8..bf77875fa7a2a 100644
--- a/tests/ui/lub-glb/old-lub-glb-hr-noteq1.noleak.stderr
+++ b/tests/ui/lub-glb/old-lub-glb-hr-noteq1.noleak.stderr
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
 LL |         _ => y,
    |              ^ one type is more general than the other
    |
-   = note: expected fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
-              found fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8`
+   = note: expected fn pointer `for<'a, 'b> fn(&'a _, &'b _) -> &'a _`
+              found fn pointer `for<'a> fn(&'a _, &'a _) -> &'a _`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/lub-glb/old-lub-glb-hr-noteq2.leak.stderr b/tests/ui/lub-glb/old-lub-glb-hr-noteq2.leak.stderr
index a1958cc436adc..1c8925e0bfbcf 100644
--- a/tests/ui/lub-glb/old-lub-glb-hr-noteq2.leak.stderr
+++ b/tests/ui/lub-glb/old-lub-glb-hr-noteq2.leak.stderr
@@ -11,8 +11,8 @@ LL | |
 LL | |     };
    | |_____- `match` arms have incompatible types
    |
-   = note: expected fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8`
-              found fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
+   = note: expected fn pointer `for<'a> fn(&'a _, &'a _) -> &'a _`
+              found fn pointer `for<'a, 'b> fn(&'a _, &'b _) -> &'a _`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/mir/field-projection-mutating-context.stderr b/tests/ui/mir/field-projection-mutating-context.stderr
index 62c9e55a44bb5..c7289c0f07c75 100644
--- a/tests/ui/mir/field-projection-mutating-context.stderr
+++ b/tests/ui/mir/field-projection-mutating-context.stderr
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
 LL |     let Foo(ref mut y): Foo<fn(&'static str)> = x;
    |             ^^^^^^^^^ one type is more general than the other
    |
-   = note: expected fn pointer `for<'a> fn(&'a str)`
-              found fn pointer `fn(&str)`
+   = note: expected fn pointer `for<'a> fn(&'a _)`
+              found fn pointer `fn(&_)`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr
index 760e3327b776a..e9808b8699186 100644
--- a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr
+++ b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr
@@ -6,8 +6,8 @@ LL |     a.iter().map(|_: (u32, u32)| 45);
    |              |
    |              expected due to this
    |
-   = note: expected closure signature `fn(&(u32, u32)) -> _`
-              found closure signature `fn((u32, u32)) -> _`
+   = note: expected closure signature `fn(&(_, _)) -> _`
+              found closure signature `fn((_, _)) -> _`
 note: required by a bound in `map`
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
 help: consider adjusting the signature so it borrows its argument
diff --git a/tests/ui/mismatched_types/issue-36053-2.stderr b/tests/ui/mismatched_types/issue-36053-2.stderr
index bac27788a2dc6..292525daa3d6b 100644
--- a/tests/ui/mismatched_types/issue-36053-2.stderr
+++ b/tests/ui/mismatched_types/issue-36053-2.stderr
@@ -6,8 +6,8 @@ LL |     once::<&str>("str").fuse().filter(|a: &str| true).count();
    |                                |
    |                                expected due to this
    |
-   = note: expected closure signature `for<'a> fn(&'a &str) -> _`
-              found closure signature `for<'a> fn(&'a str) -> _`
+   = note: expected closure signature `for<'a> fn(&'a &_) -> _`
+              found closure signature `for<'a> fn(&'a _) -> _`
 note: required by a bound in `filter`
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
 help: consider adjusting the signature so it borrows its argument
diff --git a/tests/ui/mismatched_types/normalize-fn-sig.stderr b/tests/ui/mismatched_types/normalize-fn-sig.stderr
index 2166de85f1fec..0fb3975c3c29d 100644
--- a/tests/ui/mismatched_types/normalize-fn-sig.stderr
+++ b/tests/ui/mismatched_types/normalize-fn-sig.stderr
@@ -6,8 +6,8 @@ LL |     needs_i32_ref_fn(foo::<()>);
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected fn pointer `fn(&'static i32, i32)`
-                 found fn item `fn(i32, &'static i32) {foo::<()>}`
+   = note: expected fn pointer `fn(&'static _, _)`
+                 found fn item `fn(_, &'static _) {foo::<()>}`
 note: function defined here
   --> $DIR/normalize-fn-sig.rs:11:4
    |
diff --git a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.stderr b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.stderr
index 821661f1a568e..6a9d76f7998c9 100644
--- a/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.stderr
+++ b/tests/ui/moves/assignment-of-clone-call-on-ref-due-to-missing-bound.stderr
@@ -6,8 +6,8 @@ LL |             let mut x: HashSet<Day> = v.clone();
    |                        |
    |                        expected due to this
    |
-   = note: expected struct `HashSet<Day>`
-           found reference `&HashSet<Day>`
+   = note: expected struct `HashSet<_>`
+           found reference `&HashSet<_>`
 note: `HashSet<Day>` does not implement `Clone`, so `&HashSet<Day>` was cloned instead
   --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:18:39
    |
diff --git a/tests/ui/nll/relate_tys/hr-fn-aaa-as-aba.stderr b/tests/ui/nll/relate_tys/hr-fn-aaa-as-aba.stderr
index 7d76c916d6ddc..58fd7776f2f00 100644
--- a/tests/ui/nll/relate_tys/hr-fn-aaa-as-aba.stderr
+++ b/tests/ui/nll/relate_tys/hr-fn-aaa-as-aba.stderr
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
 LL |     let a: for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32 = make_it();
    |                                                          ^^^^^^^^^ one type is more general than the other
    |
-   = note: expected fn pointer `for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32`
-              found fn pointer `for<'a> fn(&'a u32, &'a u32) -> &'a u32`
+   = note: expected fn pointer `for<'a, 'b> fn(&'a _, &'b _) -> &'a _`
+              found fn pointer `for<'a> fn(&'a _, &'a _) -> &'a _`
 
 error[E0308]: mismatched types
   --> $DIR/hr-fn-aaa-as-aba.rs:20:12
@@ -13,8 +13,8 @@ error[E0308]: mismatched types
 LL |     let _: for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32 = make_it();
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
    |
-   = note: expected fn pointer `for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32`
-              found fn pointer `for<'a> fn(&'a u32, &'a u32) -> &'a u32`
+   = note: expected fn pointer `for<'a, 'b> fn(&'a _, &'b _) -> &'a _`
+              found fn pointer `for<'a> fn(&'a _, &'a _) -> &'a _`
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/nll/relate_tys/universe-violation.stderr b/tests/ui/nll/relate_tys/universe-violation.stderr
index b585eee0769db..a538a59a495dc 100644
--- a/tests/ui/nll/relate_tys/universe-violation.stderr
+++ b/tests/ui/nll/relate_tys/universe-violation.stderr
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
 LL |     let b: fn(&u32) -> &u32 = a;
    |                               ^ one type is more general than the other
    |
-   = note: expected fn pointer `for<'a> fn(&'a u32) -> &'a u32`
-              found fn pointer `fn(&u32) -> &u32`
+   = note: expected fn pointer `for<'a> fn(&'a _) -> &'a _`
+              found fn pointer `fn(&_) -> &_`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/nll/trait-associated-constant.stderr b/tests/ui/nll/trait-associated-constant.stderr
index f6277508eebf5..371f7860d4da7 100644
--- a/tests/ui/nll/trait-associated-constant.stderr
+++ b/tests/ui/nll/trait-associated-constant.stderr
@@ -4,8 +4,8 @@ error[E0308]: const not compatible with trait
 LL |     const AC: Option<&'c str> = None;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
    |
-   = note: expected enum `Option<&'b str>`
-              found enum `Option<&'c str>`
+   = note: expected enum `Option<&'b _>`
+              found enum `Option<&'c _>`
 note: the lifetime `'c` as defined here...
   --> $DIR/trait-associated-constant.rs:20:18
    |
diff --git a/tests/ui/or-patterns/inconsistent-modes.stderr b/tests/ui/or-patterns/inconsistent-modes.stderr
index f6367ef823405..19618d336f883 100644
--- a/tests/ui/or-patterns/inconsistent-modes.stderr
+++ b/tests/ui/or-patterns/inconsistent-modes.stderr
@@ -57,8 +57,8 @@ LL |     let (Ok(ref a) | Err(ref mut a)): Result<&u8, &mut u8> = Ok(&0);
    |             |            types differ in mutability
    |             first introduced with type `&&u8` here
    |
-   = note:      expected reference `&&u8`
-           found mutable reference `&mut &mut u8`
+   = note:      expected reference `&&_`
+           found mutable reference `&mut &mut _`
    = note: a binding must have the same type in all alternatives
 
 error[E0308]: mismatched types
diff --git a/tests/ui/range/issue-73553-misinterp-range-literal.stderr b/tests/ui/range/issue-73553-misinterp-range-literal.stderr
index 52efa241d0b12..15e55708c3785 100644
--- a/tests/ui/range/issue-73553-misinterp-range-literal.stderr
+++ b/tests/ui/range/issue-73553-misinterp-range-literal.stderr
@@ -6,8 +6,8 @@ LL |     demo(tell(1)..tell(10));
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected reference `&std::ops::Range<usize>`
-                 found struct `std::ops::Range<usize>`
+   = note: expected reference `&std::ops::Range<_>`
+                 found struct `std::ops::Range<_>`
 note: function defined here
   --> $DIR/issue-73553-misinterp-range-literal.rs:3:4
    |
diff --git a/tests/ui/regions/issue-101280.stderr b/tests/ui/regions/issue-101280.stderr
index 70953808b8168..48deb99494bee 100644
--- a/tests/ui/regions/issue-101280.stderr
+++ b/tests/ui/regions/issue-101280.stderr
@@ -6,8 +6,8 @@ LL | fn f<'r>(f: fn(Cell<(&'r i32, &i32)>)) -> Ty {
 LL |     f
    |     ^ one type is more general than the other
    |
-   = note: expected fn pointer `for<'r> fn(Cell<(&'r i32, &'r i32)>)`
-              found fn pointer `for<'a> fn(Cell<(&'r i32, &'a i32)>)`
+   = note: expected fn pointer `for<'r> fn(Cell<(&'r _, &'r _)>)`
+              found fn pointer `for<'a> fn(Cell<(&'r _, &'a _)>)`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr b/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr
index 03d5a0be7235e..d8269514befd9 100644
--- a/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr
+++ b/tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr
@@ -6,8 +6,8 @@ LL |     let _: fn(&mut &isize, &mut &isize) = a;
    |            |
    |            expected due to this
    |
-   = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)`
-                 found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}`
+   = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b _, &'c mut &'d _)`
+                 found fn item `for<'a, 'b> fn(&'a mut &_, &'b mut &_) {a::<'_, '_>}`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr b/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr
index 250571f1556d8..e383f352b9e97 100644
--- a/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr
+++ b/tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr
@@ -6,8 +6,8 @@ LL |     let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
    |            |
    |            expected due to this
    |
-   = note: expected fn pointer `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut &'b isize, &'c mut &'d isize, &'e mut &'f isize)`
-                 found fn item `for<'a, 'b, 'c> fn(&'a mut &isize, &'b mut &isize, &'c mut &isize) {a::<'_, '_, '_>}`
+   = note: expected fn pointer `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut &'b _, &'c mut &'d _, &'e mut &'f _)`
+                 found fn item `for<'a, 'b, 'c> fn(&'a mut &_, &'b mut &_, &'c mut &_) {a::<'_, '_, '_>}`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr b/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr
index 31dd7efe067cf..989e91c702b83 100644
--- a/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr
+++ b/tests/ui/regions/regions-lifetime-bounds-on-fns.stderr
@@ -6,8 +6,8 @@ LL |     let _: fn(&mut &isize, &mut &isize) = a;
    |            |
    |            expected due to this
    |
-   = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)`
-                 found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}`
+   = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b _, &'c mut &'d _)`
+                 found fn item `for<'a, 'b> fn(&'a mut &_, &'b mut &_) {a::<'_, '_>}`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/resolve/resolve-inconsistent-binding-mode.stderr b/tests/ui/resolve/resolve-inconsistent-binding-mode.stderr
index c805c9eb125c8..6e44c280f758d 100644
--- a/tests/ui/resolve/resolve-inconsistent-binding-mode.stderr
+++ b/tests/ui/resolve/resolve-inconsistent-binding-mode.stderr
@@ -62,8 +62,8 @@ LL |         Opts::A(ref mut i) | Opts::B(ref i) => {}
    |                 |
    |                 first introduced with type `&mut isize` here
    |
-   = note: expected mutable reference `&mut isize`
-                      found reference `&isize`
+   = note: expected mutable reference `&mut _`
+                      found reference `&_`
    = note: in the same arm, a binding must have the same type in all alternatives
 
 error: aborting due to 6 previous errors
diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr
index 181f57899a910..970a9c151c18f 100644
--- a/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr
+++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr
@@ -6,8 +6,8 @@ LL |     match &s {
 LL |             "abc" => true,
    |             ^^^^^ expected `&&str`, found `&str`
    |
-   = note: expected reference `&&str`
-              found reference `&'static str`
+   = note: expected reference `&&_`
+              found reference `&'static _`
 
 error[E0308]: mismatched types
   --> $DIR/lit.rs:16:9
diff --git a/tests/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.stderr b/tests/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.stderr
index 61aae850a9438..86f2d9b6ec800 100644
--- a/tests/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.stderr
+++ b/tests/ui/rfcs/rfc-2528-type-changing-struct-update/issue-92010-trait-bound-not-satisfied.stderr
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
 LL |     fn y(&self, y: f64) -> Self { P{y, .. self.clone() } }
    |                                           ^^^^^^^^^^^^ expected `P<T>`, found `&P<T>`
    |
-   = note: expected struct `P<T>`
-           found reference `&P<T>`
+   = note: expected struct `P<_>`
+           found reference `&P<_>`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/static/static-reference-to-fn-1.stderr b/tests/ui/static/static-reference-to-fn-1.stderr
index ce9b6a739cfcc..6bf64974ef59b 100644
--- a/tests/ui/static/static-reference-to-fn-1.stderr
+++ b/tests/ui/static/static-reference-to-fn-1.stderr
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
 LL |         func: &foo,
    |               ^^^^ expected `&fn() -> Option<isize>`, found `&fn() -> Option<isize> {foo}`
    |
-   = note: expected reference `&fn() -> Option<isize>`
-              found reference `&fn() -> Option<isize> {foo}`
+   = note: expected reference `&fn() -> Option<_>`
+              found reference `&fn() -> Option<_> {foo}`
    = note: fn items are distinct from fn pointers
 help: consider casting to a fn pointer
    |
diff --git a/tests/ui/suggestions/as-ref.stderr b/tests/ui/suggestions/as-ref.stderr
index c5b2bb1260f35..a42e2af316415 100644
--- a/tests/ui/suggestions/as-ref.stderr
+++ b/tests/ui/suggestions/as-ref.stderr
@@ -78,8 +78,8 @@ LL |     let y: Option<&usize> = x;
    |            |
    |            expected due to this
    |
-   = note:   expected enum `Option<&usize>`
-           found reference `&Option<usize>`
+   = note:   expected enum `Option<&_>`
+           found reference `&Option<_>`
 help: try using `.as_ref()` to convert `&Option<usize>` to `Option<&usize>`
    |
 LL |     let y: Option<&usize> = x.as_ref();
@@ -93,8 +93,8 @@ LL |     let y: Result<&usize, &usize> = x;
    |            |
    |            expected due to this
    |
-   = note:   expected enum `Result<&usize, &usize>`
-           found reference `&Result<usize, usize>`
+   = note:   expected enum `Result<&_, &_>`
+           found reference `&Result<_, _>`
 help: try using `.as_ref()` to convert `&Result<usize, usize>` to `Result<&usize, &usize>`
    |
 LL |     let y: Result<&usize, &usize> = x.as_ref();
@@ -108,8 +108,8 @@ LL |     let y: Result<&usize, usize> = x;
    |            |
    |            expected due to this
    |
-   = note:   expected enum `Result<&usize, usize>`
-           found reference `&Result<usize, usize>`
+   = note:   expected enum `Result<&_, _>`
+           found reference `&Result<_, _>`
 
 error[E0308]: mismatched types
   --> $DIR/as-ref.rs:22:42
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 8c973995c34bd..afbb9c32d516e 100644
--- a/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
+++ b/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
@@ -8,8 +8,8 @@ LL | fn wat<T>(t: &T) -> T {
 LL |     t.clone()
    |     ^^^^^^^^^ expected type parameter `T`, found `&T`
    |
-   = note: expected type parameter `T`
-                   found reference `&T`
+   = note: expected type parameter `_`
+                   found reference `&_`
 note: `T` does not implement `Clone`, so `&T` was cloned instead
   --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:3:5
    |
diff --git a/tests/ui/suggestions/method-access-to-range-literal-typo.stderr b/tests/ui/suggestions/method-access-to-range-literal-typo.stderr
index 54a16b8efa748..b1fb0254cd9cf 100644
--- a/tests/ui/suggestions/method-access-to-range-literal-typo.stderr
+++ b/tests/ui/suggestions/method-access-to-range-literal-typo.stderr
@@ -18,8 +18,8 @@ LL |     fn method(&self) -> Option<&Vec<u8>> {
 LL |         self.option..as_ref().map(|x| x)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<&Vec<u8>>`, found `Range<Option<Vec<u8>>>`
    |
-   = note: expected enum `Option<&Vec<u8>>`
-            found struct `std::ops::Range<Option<Vec<u8>>>`
+   = note: expected enum `Option<&Vec<_>>`
+            found struct `std::ops::Range<Option<Vec<_>>>`
 help: you likely meant to write a method call instead of a range
    |
 LL -         self.option..as_ref().map(|x| x)
diff --git a/tests/ui/suggestions/mut-ref-reassignment.stderr b/tests/ui/suggestions/mut-ref-reassignment.stderr
index b86a04c7cd3d1..a225b34f8c30b 100644
--- a/tests/ui/suggestions/mut-ref-reassignment.stderr
+++ b/tests/ui/suggestions/mut-ref-reassignment.stderr
@@ -32,8 +32,8 @@ LL | fn suggestion2(opt: &mut Option<String>) {
 LL |     opt = Some(String::new())
    |           ^^^^^^^^^^^^^^^^^^^ expected `&mut Option<String>`, found `Option<String>`
    |
-   = note: expected mutable reference `&mut Option<String>`
-                           found enum `Option<String>`
+   = note: expected mutable reference `&mut Option<_>`
+                           found enum `Option<_>`
 help: consider dereferencing here to assign to the mutably borrowed value
    |
 LL |     *opt = Some(String::new())
diff --git a/tests/ui/traits/impl-method-mismatch.stderr b/tests/ui/traits/impl-method-mismatch.stderr
index 2655d465f2363..2061fc78575a0 100644
--- a/tests/ui/traits/impl-method-mismatch.stderr
+++ b/tests/ui/traits/impl-method-mismatch.stderr
@@ -9,8 +9,8 @@ note: type in trait
    |
 LL |     fn jumbo(&self, x: &usize) -> usize;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: expected signature `fn(&usize, &usize) -> usize`
-              found signature `unsafe fn(&usize, &usize)`
+   = note: expected signature `fn(&_, &_) -> usize`
+              found signature `unsafe fn(&_, &_)`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/traits/wrong-mul-method-signature.stderr b/tests/ui/traits/wrong-mul-method-signature.stderr
index 25a92f5ec12a7..91162cbc1231f 100644
--- a/tests/ui/traits/wrong-mul-method-signature.stderr
+++ b/tests/ui/traits/wrong-mul-method-signature.stderr
@@ -7,8 +7,8 @@ LL |     fn mul(self, s: &f64) -> Vec1 {
    |                     expected `f64`, found `&f64`
    |                     help: change the parameter type to match the trait: `f64`
    |
-   = note: expected signature `fn(Vec1, f64) -> Vec1`
-              found signature `fn(Vec1, &f64) -> Vec1`
+   = note: expected signature `fn(Vec1, _) -> Vec1`
+              found signature `fn(Vec1, &_) -> Vec1`
 
 error[E0053]: method `mul` has an incompatible type for trait
   --> $DIR/wrong-mul-method-signature.rs:33:21
diff --git a/tests/ui/type/type-check/point-at-inference-2.stderr b/tests/ui/type/type-check/point-at-inference-2.stderr
index 1d2777ad69a21..8b559ffff7e3b 100644
--- a/tests/ui/type/type-check/point-at-inference-2.stderr
+++ b/tests/ui/type/type-check/point-at-inference-2.stderr
@@ -25,8 +25,8 @@ LL |     bar(v);
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected struct `Vec<i32>`
-              found struct `Vec<&i32>`
+   = note: expected struct `Vec<_>`
+              found struct `Vec<&_>`
 note: function defined here
   --> $DIR/point-at-inference-2.rs:1:4
    |
@@ -43,8 +43,8 @@ LL |     bar(v);
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected struct `Vec<i32>`
-              found struct `Vec<&i32>`
+   = note: expected struct `Vec<_>`
+              found struct `Vec<&_>`
 note: function defined here
   --> $DIR/point-at-inference-2.rs:1:4
    |
diff --git a/tests/ui/type/type-mismatch.stderr b/tests/ui/type/type-mismatch.stderr
index ce6f29d354fd1..aca96978ac91a 100644
--- a/tests/ui/type/type-mismatch.stderr
+++ b/tests/ui/type/type-mismatch.stderr
@@ -382,8 +382,8 @@ LL |     want::<&Foo<foo>>(f);
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected reference `&Foo<foo>`
-                 found struct `Foo<foo>`
+   = note: expected reference `&Foo<_>`
+                 found struct `Foo<_>`
 note: function defined here
   --> $DIR/type-mismatch.rs:14:4
    |
@@ -402,8 +402,8 @@ LL |     want::<&Foo<foo, B>>(f);
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected reference `&Foo<foo, B>`
-                 found struct `Foo<foo>`
+   = note: expected reference `&Foo<_, B>`
+                 found struct `Foo<_, A>`
 note: function defined here
   --> $DIR/type-mismatch.rs:14:4
    |
@@ -546,8 +546,8 @@ LL |     want::<&Foo<foo>>(f);
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected reference `&Foo<foo>`
-                 found struct `Foo<foo, B>`
+   = note: expected reference `&Foo<_, A>`
+                 found struct `Foo<_, B>`
 note: function defined here
   --> $DIR/type-mismatch.rs:14:4
    |
@@ -562,8 +562,8 @@ LL |     want::<&Foo<foo, B>>(f);
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected reference `&Foo<foo, B>`
-                 found struct `Foo<foo, B>`
+   = note: expected reference `&Foo<_, _>`
+                 found struct `Foo<_, _>`
 note: function defined here
   --> $DIR/type-mismatch.rs:14:4
    |
@@ -726,8 +726,8 @@ LL |     want::<&Foo<foo>>(f);
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected reference `&Foo<foo>`
-                 found struct `Foo<foo, B, A>`
+   = note: expected reference `&Foo<_, A, B>`
+                 found struct `Foo<_, B, A>`
 note: function defined here
   --> $DIR/type-mismatch.rs:14:4
    |
@@ -742,8 +742,8 @@ LL |     want::<&Foo<foo, B>>(f);
    |     |
    |     arguments to this function are incorrect
    |
-   = note: expected reference `&Foo<foo, B>`
-                 found struct `Foo<foo, B, A>`
+   = note: expected reference `&Foo<_, _, B>`
+                 found struct `Foo<_, _, A>`
 note: function defined here
   --> $DIR/type-mismatch.rs:14:4
    |
diff --git a/tests/ui/typeck/bad-index-due-to-nested.stderr b/tests/ui/typeck/bad-index-due-to-nested.stderr
index 0b705d467ffb4..bd7fd0392c378 100644
--- a/tests/ui/typeck/bad-index-due-to-nested.stderr
+++ b/tests/ui/typeck/bad-index-due-to-nested.stderr
@@ -44,8 +44,8 @@ LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
 LL |     map[k]
    |         ^ expected `&K`, found type parameter `K`
    |
-   = note:   expected reference `&K`
-           found type parameter `K`
+   = note:   expected reference `&_`
+           found type parameter `_`
 help: consider borrowing here
    |
 LL |     map[&k]
@@ -59,8 +59,8 @@ LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
 LL |     map[k]
    |     ^^^^^^ expected `&V`, found type parameter `V`
    |
-   = note:   expected reference `&'a V`
-           found type parameter `V`
+   = note:   expected reference `&'a _`
+           found type parameter `_`
 help: consider borrowing here
    |
 LL |     &map[k]
diff --git a/tests/ui/typeck/mismatched-map-under-self.stderr b/tests/ui/typeck/mismatched-map-under-self.stderr
index 41391720a28c5..13678b4b82727 100644
--- a/tests/ui/typeck/mismatched-map-under-self.stderr
+++ b/tests/ui/typeck/mismatched-map-under-self.stderr
@@ -12,8 +12,8 @@ note: type in trait
    |
 LL |     fn values(&self) -> Self::Values;
    |               ^^^^^
-   = note: expected signature `fn(&Option<T>)`
-              found signature `fn(Option<T>)`
+   = note: expected signature `fn(&Option<_>)`
+              found signature `fn(Option<_>)`
 
 error[E0631]: type mismatch in function arguments
   --> $DIR/mismatched-map-under-self.rs:12:18
diff --git a/tests/ui/ufcs/ufcs-explicit-self-bad.rs b/tests/ui/ufcs/ufcs-explicit-self-bad.rs
index 9b0f99a189a76..3bb3d906d110b 100644
--- a/tests/ui/ufcs/ufcs-explicit-self-bad.rs
+++ b/tests/ui/ufcs/ufcs-explicit-self-bad.rs
@@ -39,12 +39,12 @@ impl<'a, T> SomeTrait for &'a Bar<T> {
     //~| ERROR has an incompatible type for trait
     fn dummy3(self: &&Bar<T>) {}
     //~^ ERROR mismatched `self` parameter type
-    //~| expected reference `&'a Bar<T>`
-    //~| found reference `&Bar<T>`
+    //~| expected reference `&'a Bar<_>`
+    //~| found reference `&Bar<_>`
     //~| lifetime mismatch
     //~| ERROR mismatched `self` parameter type
-    //~| expected reference `&'a Bar<T>`
-    //~| found reference `&Bar<T>`
+    //~| expected reference `&'a Bar<_>`
+    //~| found reference `&Bar<_>`
     //~| lifetime mismatch
 }
 
diff --git a/tests/ui/ufcs/ufcs-explicit-self-bad.stderr b/tests/ui/ufcs/ufcs-explicit-self-bad.stderr
index 0efaa41d48a1c..4c2cb0eb7536a 100644
--- a/tests/ui/ufcs/ufcs-explicit-self-bad.stderr
+++ b/tests/ui/ufcs/ufcs-explicit-self-bad.stderr
@@ -31,8 +31,8 @@ error[E0308]: mismatched `self` parameter type
 LL |     fn dummy2(self: &Bar<T>) {}
    |                     ^^^^^^^ lifetime mismatch
    |
-   = note: expected reference `&'a Bar<T>`
-              found reference `&Bar<T>`
+   = note: expected reference `&'a Bar<_>`
+              found reference `&Bar<_>`
 note: the anonymous lifetime defined here...
   --> $DIR/ufcs-explicit-self-bad.rs:37:21
    |
@@ -50,8 +50,8 @@ error[E0308]: mismatched `self` parameter type
 LL |     fn dummy2(self: &Bar<T>) {}
    |                     ^^^^^^^ lifetime mismatch
    |
-   = note: expected reference `&'a Bar<T>`
-              found reference `&Bar<T>`
+   = note: expected reference `&'a Bar<_>`
+              found reference `&Bar<_>`
 note: the lifetime `'a` as defined here...
   --> $DIR/ufcs-explicit-self-bad.rs:35:6
    |
@@ -69,8 +69,8 @@ error[E0308]: mismatched `self` parameter type
 LL |     fn dummy3(self: &&Bar<T>) {}
    |                     ^^^^^^^^ lifetime mismatch
    |
-   = note: expected reference `&'a Bar<T>`
-              found reference `&Bar<T>`
+   = note: expected reference `&'a Bar<_>`
+              found reference `&Bar<_>`
 note: the anonymous lifetime defined here...
   --> $DIR/ufcs-explicit-self-bad.rs:40:22
    |
@@ -88,8 +88,8 @@ error[E0308]: mismatched `self` parameter type
 LL |     fn dummy3(self: &&Bar<T>) {}
    |                     ^^^^^^^^ lifetime mismatch
    |
-   = note: expected reference `&'a Bar<T>`
-              found reference `&Bar<T>`
+   = note: expected reference `&'a Bar<_>`
+              found reference `&Bar<_>`
 note: the lifetime `'a` as defined here...
   --> $DIR/ufcs-explicit-self-bad.rs:35:6
    |
@@ -115,8 +115,8 @@ note: type in trait
    |
 LL |     fn dummy2(&self);
    |               ^^^^^
-   = note: expected signature `fn(&&'a Bar<T>)`
-              found signature `fn(&Bar<T>)`
+   = note: expected signature `fn(&&'a Bar<_>)`
+              found signature `fn(&Bar<_>)`
 
 error: aborting due to 8 previous errors
 
diff --git a/tests/ui/unsafe/unsafe-trait-impl.rs b/tests/ui/unsafe/unsafe-trait-impl.rs
index 1fc84ca02560d..9fd9ff65288d9 100644
--- a/tests/ui/unsafe/unsafe-trait-impl.rs
+++ b/tests/ui/unsafe/unsafe-trait-impl.rs
@@ -7,8 +7,8 @@ trait Foo {
 impl Foo for u32 {
     fn len(&self) -> u32 { *self }
     //~^ ERROR method `len` has an incompatible type for trait
-    //~| expected signature `unsafe fn(&u32) -> _`
-    //~| found signature `fn(&u32) -> _`
+    //~| expected signature `unsafe fn(&_) -> _`
+    //~| found signature `fn(&_) -> _`
 }
 
 fn main() { }
diff --git a/tests/ui/unsafe/unsafe-trait-impl.stderr b/tests/ui/unsafe/unsafe-trait-impl.stderr
index db5200e1c2030..5888b674d4fb4 100644
--- a/tests/ui/unsafe/unsafe-trait-impl.stderr
+++ b/tests/ui/unsafe/unsafe-trait-impl.stderr
@@ -9,8 +9,8 @@ note: type in trait
    |
 LL |     unsafe fn len(&self) -> u32;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: expected signature `unsafe fn(&u32) -> _`
-              found signature `fn(&u32) -> _`
+   = note: expected signature `unsafe fn(&_) -> _`
+              found signature `fn(&_) -> _`
 
 error: aborting due to 1 previous error