about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-06-04 11:32:29 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-06-30 08:45:43 +0000
commit28f023c75194fdd61b12b64a33e7e0ba877eb3c9 (patch)
treed6cfc5c2f1a16000edde2a97a35c81bf5b1dd10a
parentee8fa4eb169949600da993a0bfcb2d5fe85e6043 (diff)
downloadrust-28f023c75194fdd61b12b64a33e7e0ba877eb3c9.tar.gz
rust-28f023c75194fdd61b12b64a33e7e0ba877eb3c9.zip
Use predicate spans instead of whole item spans
-rw-r--r--compiler/rustc_hir_analysis/src/check/wfcheck.rs41
-rw-r--r--tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs2
-rw-r--r--tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr10
-rw-r--r--tests/ui/associated-types/issue-38821.rs10
-rw-r--r--tests/ui/associated-types/issue-38821.stderr48
-rw-r--r--tests/ui/associated-types/issue-59324.rs2
-rw-r--r--tests/ui/associated-types/issue-59324.stderr13
-rw-r--r--tests/ui/lifetimes/issue-76168-hr-outlives-3.rs4
-rw-r--r--tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr26
-rw-r--r--tests/ui/methods/filter-relevant-fn-bounds.rs5
-rw-r--r--tests/ui/methods/filter-relevant-fn-bounds.stderr40
-rw-r--r--tests/ui/regions/regions-normalize-in-where-clause-list.rs2
-rw-r--r--tests/ui/regions/regions-normalize-in-where-clause-list.stderr12
-rw-r--r--tests/ui/traits/deep-norm-pending.rs4
-rw-r--r--tests/ui/traits/deep-norm-pending.stderr29
15 files changed, 113 insertions, 135 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index 90368f7b26c..c096eb465e7 100644
--- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs
+++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
@@ -25,7 +25,7 @@ use rustc_middle::ty::{
 };
 use rustc_middle::{bug, span_bug};
 use rustc_session::parse::feature_err;
-use rustc_span::{DUMMY_SP, Ident, Span, sym};
+use rustc_span::{DUMMY_SP, Span, sym};
 use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
 use rustc_trait_selection::regions::{InferCtxtRegionExt, OutlivesEnvironmentBuildExt};
 use rustc_trait_selection::traits::misc::{
@@ -290,8 +290,8 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
             }
             res
         }
-        hir::ItemKind::Fn { ident, sig, .. } => check_item_fn(tcx, def_id, ident, sig.decl),
-        hir::ItemKind::Const(_, _, ty, _) => check_const_item(tcx, def_id, ty.span, item.span),
+        hir::ItemKind::Fn { sig, .. } => check_item_fn(tcx, def_id, sig.decl),
+        hir::ItemKind::Const(_, _, ty, _) => check_const_item(tcx, def_id, ty.span),
         hir::ItemKind::Struct(..) => check_type_defn(tcx, item, false),
         hir::ItemKind::Union(..) => check_type_defn(tcx, item, true),
         hir::ItemKind::Enum(..) => check_type_defn(tcx, item, true),
@@ -307,7 +307,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
                     Some(WellFormedLoc::Ty(def_id)),
                     item_ty.into(),
                 );
-                check_where_clauses(wfcx, item.span, def_id);
+                check_where_clauses(wfcx, def_id);
                 Ok(())
             })
         }
@@ -327,7 +327,7 @@ fn check_foreign_item<'tcx>(
     );
 
     match item.kind {
-        hir::ForeignItemKind::Fn(sig, ..) => check_item_fn(tcx, def_id, item.ident, sig.decl),
+        hir::ForeignItemKind::Fn(sig, ..) => check_item_fn(tcx, def_id, sig.decl),
         hir::ForeignItemKind::Static(..) | hir::ForeignItemKind::Type => Ok(()),
     }
 }
@@ -1017,13 +1017,7 @@ fn check_associated_item(
             ty::AssocKind::Fn { .. } => {
                 let sig = tcx.fn_sig(item.def_id).instantiate_identity();
                 let hir_sig = sig_if_method.expect("bad signature for method");
-                check_fn_or_method(
-                    wfcx,
-                    item.ident(tcx).span,
-                    sig,
-                    hir_sig.decl,
-                    item.def_id.expect_local(),
-                );
+                check_fn_or_method(wfcx, sig, hir_sig.decl, item.def_id.expect_local());
                 check_method_receiver(wfcx, hir_sig, item, self_ty)
             }
             ty::AssocKind::Type { .. } => {
@@ -1152,7 +1146,7 @@ fn check_type_defn<'tcx>(
             }
         }
 
-        check_where_clauses(wfcx, item.span, item.owner_id.def_id);
+        check_where_clauses(wfcx, item.owner_id.def_id);
         Ok(())
     })
 }
@@ -1183,7 +1177,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
     }
 
     let res = enter_wf_checking_ctxt(tcx, def_id, |wfcx| {
-        check_where_clauses(wfcx, item.span, def_id);
+        check_where_clauses(wfcx, def_id);
         Ok(())
     });
 
@@ -1219,12 +1213,11 @@ fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocIt
 fn check_item_fn(
     tcx: TyCtxt<'_>,
     def_id: LocalDefId,
-    ident: Ident,
     decl: &hir::FnDecl<'_>,
 ) -> Result<(), ErrorGuaranteed> {
     enter_wf_checking_ctxt(tcx, def_id, |wfcx| {
         let sig = tcx.fn_sig(def_id).instantiate_identity();
-        check_fn_or_method(wfcx, ident.span, sig, decl, def_id);
+        check_fn_or_method(wfcx, sig, decl, def_id);
         Ok(())
     })
 }
@@ -1287,7 +1280,6 @@ fn check_const_item(
     tcx: TyCtxt<'_>,
     def_id: LocalDefId,
     ty_span: Span,
-    item_span: Span,
 ) -> Result<(), ErrorGuaranteed> {
     enter_wf_checking_ctxt(tcx, def_id, |wfcx| {
         let ty = tcx.type_of(def_id).instantiate_identity();
@@ -1305,7 +1297,7 @@ fn check_const_item(
             tcx.require_lang_item(LangItem::Sized, ty_span),
         );
 
-        check_where_clauses(wfcx, item_span, def_id);
+        check_where_clauses(wfcx, def_id);
 
         Ok(())
     })
@@ -1402,14 +1394,14 @@ fn check_impl<'tcx>(
             }
         }
 
-        check_where_clauses(wfcx, item.span, item.owner_id.def_id);
+        check_where_clauses(wfcx, item.owner_id.def_id);
         Ok(())
     })
 }
 
 /// Checks where-clauses and inline bounds that are declared on `def_id`.
 #[instrument(level = "debug", skip(wfcx))]
-fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id: LocalDefId) {
+pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: LocalDefId) {
     let infcx = wfcx.infcx;
     let tcx = wfcx.tcx();
 
@@ -1564,21 +1556,18 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
 
     let predicates = predicates.instantiate_identity(tcx);
 
-    let predicates = wfcx.normalize(span, None, predicates);
-
-    debug!(?predicates.predicates);
     assert_eq!(predicates.predicates.len(), predicates.spans.len());
     let wf_obligations = predicates.into_iter().flat_map(|(p, sp)| {
+        let p = wfcx.normalize(sp, None, p);
         traits::wf::clause_obligations(infcx, wfcx.param_env, wfcx.body_def_id, p, sp)
     });
     let obligations: Vec<_> = wf_obligations.chain(default_obligations).collect();
     wfcx.register_obligations(obligations);
 }
 
-#[instrument(level = "debug", skip(wfcx, span, hir_decl))]
+#[instrument(level = "debug", skip(wfcx, hir_decl))]
 fn check_fn_or_method<'tcx>(
     wfcx: &WfCheckingCtxt<'_, 'tcx>,
-    span: Span,
     sig: ty::PolyFnSig<'tcx>,
     hir_decl: &hir::FnDecl<'_>,
     def_id: LocalDefId,
@@ -1616,7 +1605,7 @@ fn check_fn_or_method<'tcx>(
         );
     }
 
-    check_where_clauses(wfcx, span, def_id);
+    check_where_clauses(wfcx, def_id);
 
     if sig.abi == ExternAbi::RustCall {
         let span = tcx.def_span(def_id);
diff --git a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs
index a718eb23bed..e583b12b1d7 100644
--- a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs
+++ b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs
@@ -12,7 +12,7 @@ fn take(
         K = { () }
     >,
 ) {}
-//~^^^^^^ ERROR implementation of `Project` is not general enough
+//~^^^^^ ERROR implementation of `Project` is not general enough
 //~^^^^ ERROR higher-ranked subtype error
 //~| ERROR higher-ranked subtype error
 
diff --git a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr
index 967814c9c3d..42e084f39c0 100644
--- a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr
+++ b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr
@@ -13,10 +13,14 @@ LL |         K = { () }
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: implementation of `Project` is not general enough
-  --> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:9:4
+  --> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:10:13
    |
-LL | fn take(
-   |    ^^^^ implementation of `Project` is not general enough
+LL |       _: impl Trait<
+   |  _____________^
+LL | |         <<for<'a> fn(&'a str) -> &'a str as Project>::Out as Discard>::Out,
+LL | |         K = { () }
+LL | |     >,
+   | |_____^ implementation of `Project` is not general enough
    |
    = note: `Project` would have to be implemented for the type `for<'a> fn(&'a str) -> &'a str`
    = note: ...but `Project` is actually implemented for the type `fn(&'0 str) -> &'0 str`, for some specific lifetime `'0`
diff --git a/tests/ui/associated-types/issue-38821.rs b/tests/ui/associated-types/issue-38821.rs
index c9be1369f16..60d3b224a5b 100644
--- a/tests/ui/associated-types/issue-38821.rs
+++ b/tests/ui/associated-types/issue-38821.rs
@@ -32,16 +32,16 @@ pub trait Column: Expression {}
 //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
 //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
 //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
+pub enum ColumnInsertValue<Col, Expr> where
+//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
+    Col: Column,
+    Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
+//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
 //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
 //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
 //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
 //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
 //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-pub enum ColumnInsertValue<Col, Expr> where
-//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-    Col: Column,
-    Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
 {
     Expression(Col, Expr),
     Default(Col),
diff --git a/tests/ui/associated-types/issue-38821.stderr b/tests/ui/associated-types/issue-38821.stderr
index 8aeefb84f85..b03a3cf7f47 100644
--- a/tests/ui/associated-types/issue-38821.stderr
+++ b/tests/ui/associated-types/issue-38821.stderr
@@ -1,5 +1,5 @@
 error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-  --> $DIR/issue-38821.rs:40:1
+  --> $DIR/issue-38821.rs:35:1
    |
 LL | pub enum ColumnInsertValue<Col, Expr> where
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
@@ -17,16 +17,10 @@ LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co
    |                                                                         +++++++++++++++++++++++++++++++++++++
 
 error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-  --> $DIR/issue-38821.rs:40:1
+  --> $DIR/issue-38821.rs:38:22
    |
-LL | / pub enum ColumnInsertValue<Col, Expr> where
-LL | |
-LL | |
-LL | |     Col: Column,
-...  |
-LL | |     Default(Col),
-LL | | }
-   | |_^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
+LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
    |
 note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
   --> $DIR/issue-38821.rs:9:18
@@ -88,10 +82,10 @@ LL | impl<T: NotNull> IntoNullable for T {
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-  --> $DIR/issue-38821.rs:23:10
+  --> $DIR/issue-38821.rs:38:22
    |
-LL | #[derive(Debug, Copy, Clone)]
-   |          ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
+LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
    |
 note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
   --> $DIR/issue-38821.rs:9:18
@@ -100,7 +94,6 @@ LL | impl<T: NotNull> IntoNullable for T {
    |         -------  ^^^^^^^^^^^^     ^
    |         |
    |         unsatisfied trait bound introduced here
-   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 help: consider further restricting the associated type
    |
 LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
@@ -125,10 +118,10 @@ LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co
    |                                                                       +++++++++++++++++++++++++++++++++++++++
 
 error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-  --> $DIR/issue-38821.rs:23:17
+  --> $DIR/issue-38821.rs:38:22
    |
-LL | #[derive(Debug, Copy, Clone)]
-   |                 ^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
+LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
    |
 note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
   --> $DIR/issue-38821.rs:9:18
@@ -137,7 +130,6 @@ LL | impl<T: NotNull> IntoNullable for T {
    |         -------  ^^^^^^^^^^^^     ^
    |         |
    |         unsatisfied trait bound introduced here
-   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 help: consider further restricting the associated type
    |
 LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
@@ -191,10 +183,10 @@ LL | impl<T: NotNull> IntoNullable for T {
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-  --> $DIR/issue-38821.rs:23:23
+  --> $DIR/issue-38821.rs:38:22
    |
-LL | #[derive(Debug, Copy, Clone)]
-   |                       ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
+LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
    |
 note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
   --> $DIR/issue-38821.rs:9:18
@@ -203,7 +195,6 @@ LL | impl<T: NotNull> IntoNullable for T {
    |         -------  ^^^^^^^^^^^^     ^
    |         |
    |         unsatisfied trait bound introduced here
-   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 help: consider further restricting the associated type
    |
 LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
@@ -225,10 +216,10 @@ LL | impl<T: NotNull> IntoNullable for T {
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-  --> $DIR/issue-38821.rs:23:10
+  --> $DIR/issue-38821.rs:38:22
    |
-LL | #[derive(Debug, Copy, Clone)]
-   |          ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
+LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
    |
 note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
   --> $DIR/issue-38821.rs:9:18
@@ -237,7 +228,6 @@ LL | impl<T: NotNull> IntoNullable for T {
    |         -------  ^^^^^^^^^^^^     ^
    |         |
    |         unsatisfied trait bound introduced here
-   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
   --> $DIR/issue-38821.rs:23:23
@@ -255,10 +245,10 @@ LL | impl<T: NotNull> IntoNullable for T {
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
-  --> $DIR/issue-38821.rs:23:23
+  --> $DIR/issue-38821.rs:38:22
    |
-LL | #[derive(Debug, Copy, Clone)]
-   |                       ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
+LL |     Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
    |
 note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
   --> $DIR/issue-38821.rs:9:18
diff --git a/tests/ui/associated-types/issue-59324.rs b/tests/ui/associated-types/issue-59324.rs
index 3abe8473052..9d4c7cb39ae 100644
--- a/tests/ui/associated-types/issue-59324.rs
+++ b/tests/ui/associated-types/issue-59324.rs
@@ -10,8 +10,8 @@ pub trait Service {
 
 pub trait ThriftService<Bug: NotFoo>:
 //~^ ERROR the trait bound `Bug: Foo` is not satisfied
-//~| ERROR the trait bound `Bug: Foo` is not satisfied
     Service<AssocType = <Bug as Foo>::OnlyFoo>
+//~^ ERROR the trait bound `Bug: Foo` is not satisfied
 {
     fn get_service(
     //~^ ERROR the trait bound `Bug: Foo` is not satisfied
diff --git a/tests/ui/associated-types/issue-59324.stderr b/tests/ui/associated-types/issue-59324.stderr
index f79afc89d10..3e2b0f41889 100644
--- a/tests/ui/associated-types/issue-59324.stderr
+++ b/tests/ui/associated-types/issue-59324.stderr
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `Bug: Foo` is not satisfied
   --> $DIR/issue-59324.rs:11:1
    |
 LL | / pub trait ThriftService<Bug: NotFoo>:
-...  |
+LL | |
 LL | |     Service<AssocType = <Bug as Foo>::OnlyFoo>
    | |______________________________________________^ the trait `Foo` is not implemented for `Bug`
    |
@@ -12,15 +12,10 @@ LL | pub trait ThriftService<Bug: NotFoo + Foo>:
    |                                     +++++
 
 error[E0277]: the trait bound `Bug: Foo` is not satisfied
-  --> $DIR/issue-59324.rs:11:1
+  --> $DIR/issue-59324.rs:13:13
    |
-LL | / pub trait ThriftService<Bug: NotFoo>:
-LL | |
-LL | |
-LL | |     Service<AssocType = <Bug as Foo>::OnlyFoo>
-...  |
-LL | | }
-   | |_^ the trait `Foo` is not implemented for `Bug`
+LL |     Service<AssocType = <Bug as Foo>::OnlyFoo>
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bug`
    |
 help: consider further restricting type parameter `Bug` with trait `Foo`
    |
diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
index eab436fa341..d6fda129e36 100644
--- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
+++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
@@ -7,10 +7,12 @@ async fn wrapper<F>(f: F)
 //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
 //~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
 //~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
-//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
 where
 F:,
 for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
+//~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
 {
     //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
     let mut i = 41;
diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
index 90572fed0ed..945d38d17f6 100644
--- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
+++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
@@ -10,10 +10,26 @@ LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a
    = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`
 
 error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
-  --> $DIR/issue-76168-hr-outlives-3.rs:6:10
+  --> $DIR/issue-76168-hr-outlives-3.rs:12:50
    |
-LL | async fn wrapper<F>(f: F)
-   |          ^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
+LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
+   |                                                  ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
+   |
+   = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`
+
+error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+  --> $DIR/issue-76168-hr-outlives-3.rs:12:57
+   |
+LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
+   |                                                         ^^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
+   |
+   = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`
+
+error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
+  --> $DIR/issue-76168-hr-outlives-3.rs:12:72
+   |
+LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
+   |                                                                        ^^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
    |
    = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`
 
@@ -41,7 +57,7 @@ LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
-  --> $DIR/issue-76168-hr-outlives-3.rs:14:1
+  --> $DIR/issue-76168-hr-outlives-3.rs:16:1
    |
 LL | / {
 LL | |
@@ -52,6 +68,6 @@ LL | | }
    |
    = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`
 
-error: aborting due to 5 previous errors
+error: aborting due to 7 previous errors
 
 For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/methods/filter-relevant-fn-bounds.rs b/tests/ui/methods/filter-relevant-fn-bounds.rs
index 76ececf7baa..6233c9db53a 100644
--- a/tests/ui/methods/filter-relevant-fn-bounds.rs
+++ b/tests/ui/methods/filter-relevant-fn-bounds.rs
@@ -7,11 +7,10 @@ struct Wrapper;
 impl Wrapper {
     fn do_something_wrapper<O, F>(self, _: F)
     //~^ ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied
-    //~| ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied
     where
         F: for<'a> FnOnce(<F as Output<'a>>::Type),
-        //~^ ERROR the trait bound `F: Output<'_>` is not satisfied
-        //~| ERROR the trait bound `F: Output<'_>` is not satisfied
+        //~^ ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied
+        //~| ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied
     {
     }
 }
diff --git a/tests/ui/methods/filter-relevant-fn-bounds.stderr b/tests/ui/methods/filter-relevant-fn-bounds.stderr
index 0e00adf6ea6..82103e62ddf 100644
--- a/tests/ui/methods/filter-relevant-fn-bounds.stderr
+++ b/tests/ui/methods/filter-relevant-fn-bounds.stderr
@@ -3,7 +3,6 @@ error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied
    |
 LL | /     fn do_something_wrapper<O, F>(self, _: F)
 LL | |
-LL | |
 LL | |     where
 LL | |         F: for<'a> FnOnce(<F as Output<'a>>::Type),
    | |___________________________________________________^ the trait `for<'a> Output<'a>` is not implemented for `F`
@@ -14,54 +13,43 @@ LL |         F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>,
    |                                                    ++++++++++++++++++++
 
 error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied
-  --> $DIR/filter-relevant-fn-bounds.rs:8:8
+  --> $DIR/filter-relevant-fn-bounds.rs:11:12
    |
-LL |     fn do_something_wrapper<O, F>(self, _: F)
-   |        ^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F`
+LL |         F: for<'a> FnOnce(<F as Output<'a>>::Type),
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F`
    |
 help: consider further restricting type parameter `F` with trait `Output`
    |
 LL |         F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>,
    |                                                    ++++++++++++++++++++
 
-error[E0277]: the trait bound `F: Output<'_>` is not satisfied
-  --> $DIR/filter-relevant-fn-bounds.rs:12:12
-   |
-LL |         F: for<'a> FnOnce(<F as Output<'a>>::Type),
-   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Output<'_>` is not implemented for `F`
-   |
-help: consider further restricting type parameter `F` with trait `Output`
-   |
-LL |         F: for<'a> FnOnce(<F as Output<'a>>::Type) + Output<'_>,
-   |                                                    ++++++++++++
-
-error[E0277]: the trait bound `F: Output<'_>` is not satisfied
-  --> $DIR/filter-relevant-fn-bounds.rs:12:20
+error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied
+  --> $DIR/filter-relevant-fn-bounds.rs:11:20
    |
 LL |         F: for<'a> FnOnce(<F as Output<'a>>::Type),
-   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Output<'_>` is not implemented for `F`
+   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F`
    |
 help: consider further restricting type parameter `F` with trait `Output`
    |
-LL |         F: for<'a> FnOnce(<F as Output<'a>>::Type) + Output<'_>,
-   |                                                    ++++++++++++
+LL |         F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>,
+   |                                                    ++++++++++++++++++++
 
-error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}`
-  --> $DIR/filter-relevant-fn-bounds.rs:21:34
+error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}`
+  --> $DIR/filter-relevant-fn-bounds.rs:20:34
    |
 LL |     wrapper.do_something_wrapper(|value| ());
-   |             -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}`
+   |             -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}`
    |             |
    |             required by a bound introduced by this call
    |
-   = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}`
+   = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}`
 help: this trait has no implementations, consider adding one
   --> $DIR/filter-relevant-fn-bounds.rs:1:1
    |
 LL | trait Output<'a> {
    | ^^^^^^^^^^^^^^^^
 note: required by a bound in `Wrapper::do_something_wrapper`
-  --> $DIR/filter-relevant-fn-bounds.rs:12:12
+  --> $DIR/filter-relevant-fn-bounds.rs:11:12
    |
 LL |     fn do_something_wrapper<O, F>(self, _: F)
    |        -------------------- required by a bound in this associated function
@@ -69,6 +57,6 @@ LL |     fn do_something_wrapper<O, F>(self, _: F)
 LL |         F: for<'a> FnOnce(<F as Output<'a>>::Type),
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper::do_something_wrapper`
 
-error: aborting due to 5 previous errors
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/regions/regions-normalize-in-where-clause-list.rs b/tests/ui/regions/regions-normalize-in-where-clause-list.rs
index 389f82e794b..9b046e6baed 100644
--- a/tests/ui/regions/regions-normalize-in-where-clause-list.rs
+++ b/tests/ui/regions/regions-normalize-in-where-clause-list.rs
@@ -22,9 +22,9 @@ where
 
 // Here we get an error: we need `'a: 'b`.
 fn bar<'a, 'b>()
-//~^ ERROR cannot infer
 where
     <() as Project<'a, 'b>>::Item: Eq,
+    //~^ ERROR cannot infer
 {
 }
 
diff --git a/tests/ui/regions/regions-normalize-in-where-clause-list.stderr b/tests/ui/regions/regions-normalize-in-where-clause-list.stderr
index ca9ceeeeff3..9a5c9ae53de 100644
--- a/tests/ui/regions/regions-normalize-in-where-clause-list.stderr
+++ b/tests/ui/regions/regions-normalize-in-where-clause-list.stderr
@@ -1,8 +1,8 @@
 error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
-  --> $DIR/regions-normalize-in-where-clause-list.rs:24:4
+  --> $DIR/regions-normalize-in-where-clause-list.rs:26:36
    |
-LL | fn bar<'a, 'b>()
-   |    ^^^
+LL |     <() as Project<'a, 'b>>::Item: Eq,
+   |                                    ^^
    |
 note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
   --> $DIR/regions-normalize-in-where-clause-list.rs:24:8
@@ -15,10 +15,10 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined he
 LL | fn bar<'a, 'b>()
    |            ^^
 note: ...so that the types are compatible
-  --> $DIR/regions-normalize-in-where-clause-list.rs:24:4
+  --> $DIR/regions-normalize-in-where-clause-list.rs:26:36
    |
-LL | fn bar<'a, 'b>()
-   |    ^^^
+LL |     <() as Project<'a, 'b>>::Item: Eq,
+   |                                    ^^
    = note: expected `Project<'a, 'b>`
               found `Project<'_, '_>`
 
diff --git a/tests/ui/traits/deep-norm-pending.rs b/tests/ui/traits/deep-norm-pending.rs
index f56c3cfa3ea..d6c498dcf2b 100644
--- a/tests/ui/traits/deep-norm-pending.rs
+++ b/tests/ui/traits/deep-norm-pending.rs
@@ -8,9 +8,10 @@ trait Bar {
 }
 impl<T> Bar for T
 //~^ ERROR the trait bound `T: Foo` is not satisfied
-//~| ERROR the trait bound `T: Foo` is not satisfied
 where
     <T as Foo>::Assoc: Sized,
+    //~^ ERROR the trait bound `T: Foo` is not satisfied
+    //~| ERROR the trait bound `T: Foo` is not satisfied
 {
     fn method() {}
     //~^ ERROR the trait bound `T: Foo` is not satisfied
@@ -18,7 +19,6 @@ where
     //~| ERROR the trait bound `T: Foo` is not satisfied
     //~| ERROR the trait bound `T: Foo` is not satisfied
     //~| ERROR the trait bound `T: Foo` is not satisfied
-    //~| ERROR the trait bound `T: Foo` is not satisfied
 }
 
 fn main() {}
diff --git a/tests/ui/traits/deep-norm-pending.stderr b/tests/ui/traits/deep-norm-pending.stderr
index d9ef62f80ea..c1d6120c390 100644
--- a/tests/ui/traits/deep-norm-pending.stderr
+++ b/tests/ui/traits/deep-norm-pending.stderr
@@ -3,7 +3,6 @@ error[E0277]: the trait bound `T: Foo` is not satisfied
    |
 LL | / impl<T> Bar for T
 LL | |
-LL | |
 LL | | where
 LL | |     <T as Foo>::Assoc: Sized,
    | |_____________________________^ the trait `Foo` is not implemented for `T`
@@ -14,7 +13,7 @@ LL |     <T as Foo>::Assoc: Sized, T: Foo
    |                               ++++++
 
 error[E0277]: the trait bound `T: Foo` is not satisfied
-  --> $DIR/deep-norm-pending.rs:15:5
+  --> $DIR/deep-norm-pending.rs:16:5
    |
 LL |     fn method() {}
    |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
@@ -25,7 +24,7 @@ LL |     <T as Foo>::Assoc: Sized, T: Foo
    |                               ++++++
 
 error[E0277]: the trait bound `T: Foo` is not satisfied
-  --> $DIR/deep-norm-pending.rs:15:5
+  --> $DIR/deep-norm-pending.rs:16:5
    |
 LL |     fn method() {}
    |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
@@ -37,7 +36,7 @@ LL |     <T as Foo>::Assoc: Sized, T: Foo
    |                               ++++++
 
 error[E0277]: the trait bound `T: Foo` is not satisfied
-  --> $DIR/deep-norm-pending.rs:15:5
+  --> $DIR/deep-norm-pending.rs:16:5
    |
 LL |     fn method() {}
    |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
@@ -56,7 +55,7 @@ LL |     <T as Foo>::Assoc: Sized, T: Foo
    |                               ++++++
 
 error[E0277]: the trait bound `T: Foo` is not satisfied
-  --> $DIR/deep-norm-pending.rs:15:5
+  --> $DIR/deep-norm-pending.rs:16:5
    |
 LL |     fn method() {}
    |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
@@ -87,15 +86,10 @@ LL |     <T as Foo>::Assoc: Sized, T: Foo
    |                               ++++++
 
 error[E0277]: the trait bound `T: Foo` is not satisfied
-  --> $DIR/deep-norm-pending.rs:9:1
+  --> $DIR/deep-norm-pending.rs:12:24
    |
-LL | / impl<T> Bar for T
-LL | |
-LL | |
-LL | | where
-...  |
-LL | | }
-   | |_^ the trait `Foo` is not implemented for `T`
+LL |     <T as Foo>::Assoc: Sized,
+   |                        ^^^^^ the trait `Foo` is not implemented for `T`
    |
 help: consider further restricting type parameter `T` with trait `Foo`
    |
@@ -103,7 +97,7 @@ LL |     <T as Foo>::Assoc: Sized, T: Foo
    |                               ++++++
 
 error[E0277]: the trait bound `T: Foo` is not satisfied
-  --> $DIR/deep-norm-pending.rs:15:5
+  --> $DIR/deep-norm-pending.rs:16:5
    |
 LL |     fn method() {}
    |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
@@ -115,11 +109,12 @@ LL |     <T as Foo>::Assoc: Sized, T: Foo
    |                               ++++++
 
 error[E0277]: the trait bound `T: Foo` is not satisfied
-  --> $DIR/deep-norm-pending.rs:15:8
+  --> $DIR/deep-norm-pending.rs:12:24
    |
-LL |     fn method() {}
-   |        ^^^^^^ the trait `Foo` is not implemented for `T`
+LL |     <T as Foo>::Assoc: Sized,
+   |                        ^^^^^ the trait `Foo` is not implemented for `T`
    |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 help: consider further restricting type parameter `T` with trait `Foo`
    |
 LL |     <T as Foo>::Assoc: Sized, T: Foo