about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-10-26 20:54:38 +0000
committerMichael Goulet <michael@errs.io>2024-10-26 20:54:38 +0000
commitbd95695b947291b2aac349a6f4587a6cee213e25 (patch)
treeb4b165604ffb64e1cb278ac919453c9105871eef
parent9260be36b2dbd896c6b233d60d1c429a75a0081a (diff)
downloadrust-bd95695b947291b2aac349a6f4587a6cee213e25.tar.gz
rust-bd95695b947291b2aac349a6f4587a6cee213e25.zip
Pass constness with span into lower_poly_trait_ref
-rw-r--r--compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs7
-rw-r--r--compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs2
-rw-r--r--compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs16
-rw-r--r--tests/ui/consts/const-block-const-bound.stderr8
-rw-r--r--tests/ui/consts/fn_trait_refs.stderr92
-rw-r--r--tests/ui/consts/unstable-const-fn-in-libcore.stderr8
-rw-r--r--tests/ui/impl-trait/normalize-tait-in-const.stderr16
-rw-r--r--tests/ui/specialization/const_trait_impl.stderr24
-rw-r--r--tests/ui/traits/const-traits/assoc-type.stderr2
-rw-r--r--tests/ui/traits/const-traits/call-generic-in-impl.stderr8
-rw-r--r--tests/ui/traits/const-traits/call-generic-method-chain.stderr16
-rw-r--r--tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr16
-rw-r--r--tests/ui/traits/const-traits/call-generic-method-pass.stderr8
-rw-r--r--tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr12
-rw-r--r--tests/ui/traits/const-traits/const-closure-parse-not-item.stderr8
-rw-r--r--tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr8
-rw-r--r--tests/ui/traits/const-traits/const-closure-trait-method.stderr8
-rw-r--r--tests/ui/traits/const-traits/const-closures.stderr32
-rw-r--r--tests/ui/traits/const-traits/const-drop-bound.stderr24
-rw-r--r--tests/ui/traits/const-traits/const-drop-fail-2.stderr8
-rw-r--r--tests/ui/traits/const-traits/const-drop-fail.precise.stderr8
-rw-r--r--tests/ui/traits/const-traits/const-drop-fail.stock.stderr8
-rw-r--r--tests/ui/traits/const-traits/const-drop.precise.stderr8
-rw-r--r--tests/ui/traits/const-traits/const-drop.stock.stderr8
-rw-r--r--tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr6
-rw-r--r--tests/ui/traits/const-traits/effects/ice-112822-expected-type-for-param.stderr8
-rw-r--r--tests/ui/traits/const-traits/effects/spec-effectvar-ice.stderr4
-rw-r--r--tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr8
-rw-r--r--tests/ui/traits/const-traits/issue-92111.stderr8
-rw-r--r--tests/ui/traits/const-traits/item-bound-entailment-fails.stderr4
-rw-r--r--tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr8
-rw-r--r--tests/ui/traits/const-traits/predicate-entailment-fails.stderr12
-rw-r--r--tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr12
-rw-r--r--tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr20
-rw-r--r--tests/ui/traits/const-traits/super-traits-fail-3.nn.stderr20
-rw-r--r--tests/ui/traits/const-traits/super-traits-fail-3.ny.stderr20
-rw-r--r--tests/ui/traits/const-traits/super-traits-fail-3.yn.stderr8
-rw-r--r--tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr2
38 files changed, 241 insertions, 254 deletions
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
index c902e85c267..a5709089db6 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
@@ -168,13 +168,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
             match hir_bound {
                 hir::GenericBound::Trait(poly_trait_ref) => {
                     let hir::TraitBoundModifiers { constness, polarity } = poly_trait_ref.modifiers;
-                    // FIXME: We could pass these directly into `lower_poly_trait_ref`
-                    // so that we could use these spans in diagnostics within that function...
-                    let constness = match constness {
-                        hir::BoundConstness::Never => None,
-                        hir::BoundConstness::Always(_) => Some(ty::BoundConstness::Const),
-                        hir::BoundConstness::Maybe(_) => Some(ty::BoundConstness::ConstIfConst),
-                    };
                     let polarity = match polarity {
                         rustc_ast::BoundPolarity::Positive => ty::PredicatePolarity::Positive,
                         rustc_ast::BoundPolarity::Negative(_) => ty::PredicatePolarity::Negative,
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs
index 890e8fa99e6..f2ee4b0ccd4 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs
@@ -50,7 +50,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
             } = self.lower_poly_trait_ref(
                 &trait_bound.trait_ref,
                 trait_bound.span,
-                None,
+                hir::BoundConstness::Never,
                 ty::PredicatePolarity::Positive,
                 dummy_self,
                 &mut bounds,
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
index 863c077a9e0..4b7eb0b00bb 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@@ -658,7 +658,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
         &self,
         trait_ref: &hir::TraitRef<'tcx>,
         span: Span,
-        constness: Option<ty::BoundConstness>,
+        constness: hir::BoundConstness,
         polarity: ty::PredicatePolarity,
         self_ty: Ty<'tcx>,
         bounds: &mut Bounds<'tcx>,
@@ -681,11 +681,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
             Some(self_ty),
         );
 
-        if let Some(constness) = constness
+        if let hir::BoundConstness::Always(span) | hir::BoundConstness::Maybe(span) = constness
             && !self.tcx().is_const_trait(trait_def_id)
         {
             self.dcx().emit_err(crate::errors::ConstBoundForNonConstTrait {
-                span: trait_ref.path.span,
+                span,
                 modifier: constness.as_str(),
             });
         }
@@ -708,7 +708,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
                 bounds.push_trait_bound(tcx, poly_trait_ref, span, polarity);
 
                 match constness {
-                    Some(ty::BoundConstness::Const) => {
+                    hir::BoundConstness::Always(span) => {
                         if polarity == ty::PredicatePolarity::Positive {
                             bounds.push_const_bound(
                                 tcx,
@@ -718,13 +718,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
                             );
                         }
                     }
-                    Some(ty::BoundConstness::ConstIfConst) => {
+                    hir::BoundConstness::Maybe(_) => {
                         // We don't emit a const bound here, since that would mean that we
                         // unconditionally need to prove a `HostEffect` predicate, even when
                         // the predicates are being instantiated in a non-const context. This
                         // is instead handled in the `const_conditions` query.
                     }
-                    None => {}
+                    hir::BoundConstness::Never => {}
                 }
             }
             // On the flip side, when filtering `ConstIfConst` bounds, we only need to convert
@@ -734,12 +734,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
             // here because we only call this on self bounds, and deal with the recursive case
             // in `lower_assoc_item_constraint`.
             PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => match constness {
-                Some(ty::BoundConstness::ConstIfConst) => {
+                hir::BoundConstness::Maybe(span) => {
                     if polarity == ty::PredicatePolarity::Positive {
                         bounds.push_const_bound(tcx, poly_trait_ref, ty::HostPolarity::Maybe, span);
                     }
                 }
-                None | Some(ty::BoundConstness::Const) => {}
+                hir::BoundConstness::Always(_) | hir::BoundConstness::Never => {}
             },
         }
 
diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr
index 8cb91d78f6c..5e24959146b 100644
--- a/tests/ui/consts/const-block-const-bound.stderr
+++ b/tests/ui/consts/const-block-const-bound.stderr
@@ -1,14 +1,14 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-block-const-bound.rs:8:22
+  --> $DIR/const-block-const-bound.rs:8:15
    |
 LL | const fn f<T: ~const Destruct>(x: T) {}
-   |                      ^^^^^^^^
+   |               ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-block-const-bound.rs:8:22
+  --> $DIR/const-block-const-bound.rs:8:15
    |
 LL | const fn f<T: ~const Destruct>(x: T) {}
-   |                      ^^^^^^^^
+   |               ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr
index 82b2b87c4a5..a686bc23c0f 100644
--- a/tests/ui/consts/fn_trait_refs.stderr
+++ b/tests/ui/consts/fn_trait_refs.stderr
@@ -11,168 +11,168 @@ LL | #![feature(const_cmp)]
    |            ^^^^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:13:15
+  --> $DIR/fn_trait_refs.rs:13:8
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |               ^^^^^^
+   |        ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:13:31
+  --> $DIR/fn_trait_refs.rs:13:24
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |                               ^^^^^^^^
+   |                        ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:13:15
+  --> $DIR/fn_trait_refs.rs:13:8
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |               ^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:13:15
+  --> $DIR/fn_trait_refs.rs:13:8
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |               ^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:13:31
+  --> $DIR/fn_trait_refs.rs:13:24
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |                               ^^^^^^^^
+   |                        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:20:15
+  --> $DIR/fn_trait_refs.rs:20:8
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |               ^^^^^^^^^
+   |        ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:20:34
+  --> $DIR/fn_trait_refs.rs:20:27
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |                                  ^^^^^^^^
+   |                           ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:20:15
+  --> $DIR/fn_trait_refs.rs:20:8
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |               ^^^^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:20:15
+  --> $DIR/fn_trait_refs.rs:20:8
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |               ^^^^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:20:34
+  --> $DIR/fn_trait_refs.rs:20:27
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |                                  ^^^^^^^^
+   |                           ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:27:15
+  --> $DIR/fn_trait_refs.rs:27:8
    |
 LL |     T: ~const FnOnce<()>,
-   |               ^^^^^^^^^^
+   |        ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:27:15
+  --> $DIR/fn_trait_refs.rs:27:8
    |
 LL |     T: ~const FnOnce<()>,
-   |               ^^^^^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:27:15
+  --> $DIR/fn_trait_refs.rs:27:8
    |
 LL |     T: ~const FnOnce<()>,
-   |               ^^^^^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:34:15
+  --> $DIR/fn_trait_refs.rs:34:8
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |               ^^^^^^
+   |        ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:34:31
+  --> $DIR/fn_trait_refs.rs:34:24
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |                               ^^^^^^^^
+   |                        ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:34:15
+  --> $DIR/fn_trait_refs.rs:34:8
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |               ^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:34:15
+  --> $DIR/fn_trait_refs.rs:34:8
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |               ^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:34:31
+  --> $DIR/fn_trait_refs.rs:34:24
    |
 LL |     T: ~const Fn<()> + ~const Destruct,
-   |                               ^^^^^^^^
+   |                        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:48:15
+  --> $DIR/fn_trait_refs.rs:48:8
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |               ^^^^^^^^^
+   |        ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:48:34
+  --> $DIR/fn_trait_refs.rs:48:27
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |                                  ^^^^^^^^
+   |                           ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:48:15
+  --> $DIR/fn_trait_refs.rs:48:8
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |               ^^^^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:48:15
+  --> $DIR/fn_trait_refs.rs:48:8
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |               ^^^^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/fn_trait_refs.rs:48:34
+  --> $DIR/fn_trait_refs.rs:48:27
    |
 LL |     T: ~const FnMut<()> + ~const Destruct,
-   |                                  ^^^^^^^^
+   |                           ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.stderr b/tests/ui/consts/unstable-const-fn-in-libcore.stderr
index e546694070d..2bdec1bf41b 100644
--- a/tests/ui/consts/unstable-const-fn-in-libcore.stderr
+++ b/tests/ui/consts/unstable-const-fn-in-libcore.stderr
@@ -1,14 +1,14 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/unstable-const-fn-in-libcore.rs:19:39
+  --> $DIR/unstable-const-fn-in-libcore.rs:19:32
    |
 LL |     const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
-   |                                       ^^^^^^^^^^^^^
+   |                                ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/unstable-const-fn-in-libcore.rs:19:39
+  --> $DIR/unstable-const-fn-in-libcore.rs:19:32
    |
 LL |     const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
-   |                                       ^^^^^^^^^^^^^
+   |                                ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr
index b370a5d7eb1..f9142664f1b 100644
--- a/tests/ui/impl-trait/normalize-tait-in-const.stderr
+++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr
@@ -1,28 +1,28 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/normalize-tait-in-const.rs:26:42
+  --> $DIR/normalize-tait-in-const.rs:26:35
    |
 LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
-   |                                          ^^^^^^^^^^^^^^^^^
+   |                                   ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/normalize-tait-in-const.rs:26:69
+  --> $DIR/normalize-tait-in-const.rs:26:62
    |
 LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
-   |                                                                     ^^^^^^^^
+   |                                                              ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/normalize-tait-in-const.rs:26:42
+  --> $DIR/normalize-tait-in-const.rs:26:35
    |
 LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
-   |                                          ^^^^^^^^^^^^^^^^^
+   |                                   ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/normalize-tait-in-const.rs:26:69
+  --> $DIR/normalize-tait-in-const.rs:26:62
    |
 LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
-   |                                                                     ^^^^^^^^
+   |                                                              ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/specialization/const_trait_impl.stderr b/tests/ui/specialization/const_trait_impl.stderr
index 746b08fa710..40ac350980e 100644
--- a/tests/ui/specialization/const_trait_impl.stderr
+++ b/tests/ui/specialization/const_trait_impl.stderr
@@ -1,42 +1,42 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const_trait_impl.rs:34:16
+  --> $DIR/const_trait_impl.rs:34:9
    |
 LL | impl<T: ~const Default> const A for T {
-   |                ^^^^^^^
+   |         ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const_trait_impl.rs:40:16
+  --> $DIR/const_trait_impl.rs:40:9
    |
 LL | impl<T: ~const Default + ~const Sup> const A for T {
-   |                ^^^^^^^
+   |         ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const_trait_impl.rs:46:16
+  --> $DIR/const_trait_impl.rs:46:9
    |
 LL | impl<T: ~const Default + ~const Sub> const A for T {
-   |                ^^^^^^^
+   |         ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const_trait_impl.rs:40:16
+  --> $DIR/const_trait_impl.rs:40:9
    |
 LL | impl<T: ~const Default + ~const Sup> const A for T {
-   |                ^^^^^^^
+   |         ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const_trait_impl.rs:34:16
+  --> $DIR/const_trait_impl.rs:34:9
    |
 LL | impl<T: ~const Default> const A for T {
-   |                ^^^^^^^
+   |         ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const_trait_impl.rs:46:16
+  --> $DIR/const_trait_impl.rs:46:9
    |
 LL | impl<T: ~const Default + ~const Sub> const A for T {
-   |                ^^^^^^^
+   |         ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/assoc-type.stderr b/tests/ui/traits/const-traits/assoc-type.stderr
index 5c77754200a..672eaf26f72 100644
--- a/tests/ui/traits/const-traits/assoc-type.stderr
+++ b/tests/ui/traits/const-traits/assoc-type.stderr
@@ -17,7 +17,7 @@ note: required by a bound in `Foo::Bar`
   --> $DIR/assoc-type.rs:32:15
    |
 LL |     type Bar: ~const Add;
-   |               ^^^^^^^^^^ required by this bound in `Foo::Bar`
+   |               ^^^^^^ required by this bound in `Foo::Bar`
 
 error: aborting due to 1 previous error; 1 warning emitted
 
diff --git a/tests/ui/traits/const-traits/call-generic-in-impl.stderr b/tests/ui/traits/const-traits/call-generic-in-impl.stderr
index 971e77e372b..52ee04425b2 100644
--- a/tests/ui/traits/const-traits/call-generic-in-impl.stderr
+++ b/tests/ui/traits/const-traits/call-generic-in-impl.stderr
@@ -1,14 +1,14 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-in-impl.rs:10:16
+  --> $DIR/call-generic-in-impl.rs:10:9
    |
 LL | impl<T: ~const PartialEq> const MyPartialEq for T {
-   |                ^^^^^^^^^
+   |         ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-in-impl.rs:10:16
+  --> $DIR/call-generic-in-impl.rs:10:9
    |
 LL | impl<T: ~const PartialEq> const MyPartialEq for T {
-   |                ^^^^^^^^^
+   |         ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/call-generic-method-chain.stderr b/tests/ui/traits/const-traits/call-generic-method-chain.stderr
index aa90305c648..6dbf3ad2526 100644
--- a/tests/ui/traits/const-traits/call-generic-method-chain.stderr
+++ b/tests/ui/traits/const-traits/call-generic-method-chain.stderr
@@ -17,30 +17,30 @@ LL | impl const PartialEq for S {
    = note: adding a non-const method body in the future would be a breaking change
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-chain.rs:20:32
+  --> $DIR/call-generic-method-chain.rs:20:25
    |
 LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
-   |                                ^^^^^^^^^
+   |                         ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-chain.rs:20:32
+  --> $DIR/call-generic-method-chain.rs:20:25
    |
 LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
-   |                                ^^^^^^^^^
+   |                         ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-chain.rs:24:40
+  --> $DIR/call-generic-method-chain.rs:24:33
    |
 LL | const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
-   |                                        ^^^^^^^^^
+   |                                 ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-chain.rs:24:40
+  --> $DIR/call-generic-method-chain.rs:24:33
    |
 LL | const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
-   |                                        ^^^^^^^^^
+   |                                 ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr b/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr
index 029915b7646..08877daad79 100644
--- a/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr
+++ b/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr
@@ -17,30 +17,30 @@ LL | impl const PartialEq for S {
    = note: adding a non-const method body in the future would be a breaking change
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-dup-bound.rs:20:44
+  --> $DIR/call-generic-method-dup-bound.rs:20:37
    |
 LL | const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
-   |                                            ^^^^^^^^^
+   |                                     ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-dup-bound.rs:20:44
+  --> $DIR/call-generic-method-dup-bound.rs:20:37
    |
 LL | const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
-   |                                            ^^^^^^^^^
+   |                                     ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-dup-bound.rs:27:37
+  --> $DIR/call-generic-method-dup-bound.rs:27:30
    |
 LL | const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool {
-   |                                     ^^^^^^^^^
+   |                              ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-dup-bound.rs:27:37
+  --> $DIR/call-generic-method-dup-bound.rs:27:30
    |
 LL | const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool {
-   |                                     ^^^^^^^^^
+   |                              ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/call-generic-method-pass.stderr b/tests/ui/traits/const-traits/call-generic-method-pass.stderr
index 97ce7fe1c2a..ac08c057435 100644
--- a/tests/ui/traits/const-traits/call-generic-method-pass.stderr
+++ b/tests/ui/traits/const-traits/call-generic-method-pass.stderr
@@ -17,16 +17,16 @@ LL | impl const PartialEq for S {
    = note: adding a non-const method body in the future would be a breaking change
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-pass.rs:20:32
+  --> $DIR/call-generic-method-pass.rs:20:25
    |
 LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
-   |                                ^^^^^^^^^
+   |                         ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/call-generic-method-pass.rs:20:32
+  --> $DIR/call-generic-method-pass.rs:20:25
    |
 LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
-   |                                ^^^^^^^^^
+   |                         ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr
index 6c3c11c6a47..d27be2a324b 100644
--- a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr
+++ b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr
@@ -13,24 +13,24 @@ error: using `#![feature(effects)]` without enabling next trait solver globally
    = help: use `-Znext-solver` to enable
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-bounds-non-const-trait.rs:6:28
+  --> $DIR/const-bounds-non-const-trait.rs:6:21
    |
 LL | const fn perform<T: ~const NonConst>() {}
-   |                            ^^^^^^^^
+   |                     ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-bounds-non-const-trait.rs:6:28
+  --> $DIR/const-bounds-non-const-trait.rs:6:21
    |
 LL | const fn perform<T: ~const NonConst>() {}
-   |                            ^^^^^^^^
+   |                     ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-bounds-non-const-trait.rs:10:21
+  --> $DIR/const-bounds-non-const-trait.rs:10:15
    |
 LL | fn operate<T: const NonConst>() {}
-   |                     ^^^^^^^^
+   |               ^^^^^
 
 error: aborting due to 4 previous errors; 1 warning emitted
 
diff --git a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr
index 12cc79f5961..25c81ff900f 100644
--- a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr
+++ b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr
@@ -1,14 +1,14 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closure-parse-not-item.rs:7:32
+  --> $DIR/const-closure-parse-not-item.rs:7:25
    |
 LL | const fn test() -> impl ~const Fn() {
-   |                                ^^^^
+   |                         ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closure-parse-not-item.rs:7:32
+  --> $DIR/const-closure-parse-not-item.rs:7:25
    |
 LL | const fn test() -> impl ~const Fn() {
-   |                                ^^^^
+   |                         ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr
index f0f033bceef..cb4c994bc2f 100644
--- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr
+++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr
@@ -1,14 +1,14 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closure-trait-method-fail.rs:14:39
+  --> $DIR/const-closure-trait-method-fail.rs:14:32
    |
 LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 {
-   |                                       ^^^^^^^^^^^^^^^^^
+   |                                ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closure-trait-method-fail.rs:14:39
+  --> $DIR/const-closure-trait-method-fail.rs:14:32
    |
 LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 {
-   |                                       ^^^^^^^^^^^^^^^^^
+   |                                ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-closure-trait-method.stderr b/tests/ui/traits/const-traits/const-closure-trait-method.stderr
index 4c5a4d0cdf4..43af435ae64 100644
--- a/tests/ui/traits/const-traits/const-closure-trait-method.stderr
+++ b/tests/ui/traits/const-traits/const-closure-trait-method.stderr
@@ -1,14 +1,14 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closure-trait-method.rs:14:39
+  --> $DIR/const-closure-trait-method.rs:14:32
    |
 LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 {
-   |                                       ^^^^^^^^^^^^^^^^^
+   |                                ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closure-trait-method.rs:14:39
+  --> $DIR/const-closure-trait-method.rs:14:32
    |
 LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 {
-   |                                       ^^^^^^^^^^^^^^^^^
+   |                                ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-closures.stderr b/tests/ui/traits/const-traits/const-closures.stderr
index a81804a50dc..2e9e37ba321 100644
--- a/tests/ui/traits/const-traits/const-closures.stderr
+++ b/tests/ui/traits/const-traits/const-closures.stderr
@@ -1,56 +1,56 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closures.rs:8:19
+  --> $DIR/const-closures.rs:8:12
    |
 LL |         F: ~const FnOnce() -> u8,
-   |                   ^^^^^^^^^^^^^^
+   |            ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closures.rs:9:19
+  --> $DIR/const-closures.rs:9:12
    |
 LL |         F: ~const FnMut() -> u8,
-   |                   ^^^^^^^^^^^^^
+   |            ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closures.rs:10:19
+  --> $DIR/const-closures.rs:10:12
    |
 LL |         F: ~const Fn() -> u8,
-   |                   ^^^^^^^^^^
+   |            ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closures.rs:8:19
+  --> $DIR/const-closures.rs:8:12
    |
 LL |         F: ~const FnOnce() -> u8,
-   |                   ^^^^^^^^^^^^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closures.rs:9:19
+  --> $DIR/const-closures.rs:9:12
    |
 LL |         F: ~const FnMut() -> u8,
-   |                   ^^^^^^^^^^^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closures.rs:10:19
+  --> $DIR/const-closures.rs:10:12
    |
 LL |         F: ~const Fn() -> u8,
-   |                   ^^^^^^^^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closures.rs:23:27
+  --> $DIR/const-closures.rs:23:20
    |
 LL | const fn answer<F: ~const Fn() -> u8>(f: &F) -> u8 {
-   |                           ^^^^^^^^^^
+   |                    ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-closures.rs:23:27
+  --> $DIR/const-closures.rs:23:20
    |
 LL | const fn answer<F: ~const Fn() -> u8>(f: &F) -> u8 {
-   |                           ^^^^^^^^^^
+   |                    ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-drop-bound.stderr b/tests/ui/traits/const-traits/const-drop-bound.stderr
index d94b0542324..3f718645433 100644
--- a/tests/ui/traits/const-traits/const-drop-bound.stderr
+++ b/tests/ui/traits/const-traits/const-drop-bound.stderr
@@ -1,42 +1,42 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-bound.rs:9:68
+  --> $DIR/const-drop-bound.rs:9:61
    |
 LL | const fn foo<T, E>(res: Result<T, E>) -> Option<T> where E: ~const Destruct {
-   |                                                                    ^^^^^^^^
+   |                                                             ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-bound.rs:9:68
+  --> $DIR/const-drop-bound.rs:9:61
    |
 LL | const fn foo<T, E>(res: Result<T, E>) -> Option<T> where E: ~const Destruct {
-   |                                                                    ^^^^^^^^
+   |                                                             ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-bound.rs:20:15
+  --> $DIR/const-drop-bound.rs:20:8
    |
 LL |     T: ~const Destruct,
-   |               ^^^^^^^^
+   |        ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-bound.rs:21:15
+  --> $DIR/const-drop-bound.rs:21:8
    |
 LL |     E: ~const Destruct,
-   |               ^^^^^^^^
+   |        ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-bound.rs:20:15
+  --> $DIR/const-drop-bound.rs:20:8
    |
 LL |     T: ~const Destruct,
-   |               ^^^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-bound.rs:21:15
+  --> $DIR/const-drop-bound.rs:21:8
    |
 LL |     E: ~const Destruct,
-   |               ^^^^^^^^
+   |        ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.stderr
index 27e8053c969..82d6412ded0 100644
--- a/tests/ui/traits/const-traits/const-drop-fail-2.stderr
+++ b/tests/ui/traits/const-traits/const-drop-fail-2.stderr
@@ -8,16 +8,16 @@ LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> {
    = note: adding a non-const method body in the future would be a breaking change
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-fail-2.rs:20:26
+  --> $DIR/const-drop-fail-2.rs:20:19
    |
 LL | const fn check<T: ~const Destruct>(_: T) {}
-   |                          ^^^^^^^^
+   |                   ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-fail-2.rs:20:26
+  --> $DIR/const-drop-fail-2.rs:20:19
    |
 LL | const fn check<T: ~const Destruct>(_: T) {}
-   |                          ^^^^^^^^
+   |                   ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-drop-fail.precise.stderr b/tests/ui/traits/const-traits/const-drop-fail.precise.stderr
index bde13b4d6cf..859fdfae81a 100644
--- a/tests/ui/traits/const-traits/const-drop-fail.precise.stderr
+++ b/tests/ui/traits/const-traits/const-drop-fail.precise.stderr
@@ -8,16 +8,16 @@ LL | impl const Drop for ConstImplWithDropGlue {
    = note: adding a non-const method body in the future would be a breaking change
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-fail.rs:23:26
+  --> $DIR/const-drop-fail.rs:23:19
    |
 LL | const fn check<T: ~const Destruct>(_: T) {}
-   |                          ^^^^^^^^
+   |                   ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-fail.rs:23:26
+  --> $DIR/const-drop-fail.rs:23:19
    |
 LL | const fn check<T: ~const Destruct>(_: T) {}
-   |                          ^^^^^^^^
+   |                   ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-drop-fail.stock.stderr b/tests/ui/traits/const-traits/const-drop-fail.stock.stderr
index 064ffacca42..20dea28922b 100644
--- a/tests/ui/traits/const-traits/const-drop-fail.stock.stderr
+++ b/tests/ui/traits/const-traits/const-drop-fail.stock.stderr
@@ -8,16 +8,16 @@ LL | impl const Drop for ConstImplWithDropGlue {
    = note: adding a non-const method body in the future would be a breaking change
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-fail.rs:23:26
+  --> $DIR/const-drop-fail.rs:23:19
    |
 LL | const fn check<T: ~const Destruct>(_: T) {}
-   |                          ^^^^^^^^
+   |                   ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop-fail.rs:23:26
+  --> $DIR/const-drop-fail.rs:23:19
    |
 LL | const fn check<T: ~const Destruct>(_: T) {}
-   |                          ^^^^^^^^
+   |                   ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-drop.precise.stderr b/tests/ui/traits/const-traits/const-drop.precise.stderr
index 7b6d185c7cc..2b8066e5ee7 100644
--- a/tests/ui/traits/const-traits/const-drop.precise.stderr
+++ b/tests/ui/traits/const-traits/const-drop.precise.stderr
@@ -35,16 +35,16 @@ LL |     impl<T: SomeTrait> const Drop for ConstDropWithNonconstBound<T> {
    = note: adding a non-const method body in the future would be a breaking change
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop.rs:18:22
+  --> $DIR/const-drop.rs:18:15
    |
 LL | const fn a<T: ~const Destruct>(_: T) {}
-   |                      ^^^^^^^^
+   |               ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop.rs:18:22
+  --> $DIR/const-drop.rs:18:15
    |
 LL | const fn a<T: ~const Destruct>(_: T) {}
-   |                      ^^^^^^^^
+   |               ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const-drop.stock.stderr b/tests/ui/traits/const-traits/const-drop.stock.stderr
index b497c39b08a..54ed2930b90 100644
--- a/tests/ui/traits/const-traits/const-drop.stock.stderr
+++ b/tests/ui/traits/const-traits/const-drop.stock.stderr
@@ -35,16 +35,16 @@ LL |     impl<T: SomeTrait> const Drop for ConstDropWithNonconstBound<T> {
    = note: adding a non-const method body in the future would be a breaking change
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop.rs:18:22
+  --> $DIR/const-drop.rs:18:15
    |
 LL | const fn a<T: ~const Destruct>(_: T) {}
-   |                      ^^^^^^^^
+   |               ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/const-drop.rs:18:22
+  --> $DIR/const-drop.rs:18:15
    |
 LL | const fn a<T: ~const Destruct>(_: T) {}
-   |                      ^^^^^^^^
+   |               ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr b/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr
index 33e7e08bb23..64285cff0a6 100644
--- a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr
+++ b/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr
@@ -23,12 +23,6 @@ LL | #[derive_const(PartialEq)]
    = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/derive-const-with-params.rs:7:16
-   |
-LL | #[derive_const(PartialEq)]
-   |                ^^^^^^^^^
-   |
-   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0015]: cannot call non-const operator in constant functions
   --> $DIR/derive-const-with-params.rs:8:23
diff --git a/tests/ui/traits/const-traits/effects/ice-112822-expected-type-for-param.stderr b/tests/ui/traits/const-traits/effects/ice-112822-expected-type-for-param.stderr
index edfdf8b5f78..5b0d5a8bb1d 100644
--- a/tests/ui/traits/const-traits/effects/ice-112822-expected-type-for-param.stderr
+++ b/tests/ui/traits/const-traits/effects/ice-112822-expected-type-for-param.stderr
@@ -23,16 +23,16 @@ error: using `#![feature(effects)]` without enabling next trait solver globally
    = help: use `-Znext-solver` to enable
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/ice-112822-expected-type-for-param.rs:3:32
+  --> $DIR/ice-112822-expected-type-for-param.rs:3:25
    |
 LL | const fn test() -> impl ~const Fn() {
-   |                                ^^^^
+   |                         ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/ice-112822-expected-type-for-param.rs:3:32
+  --> $DIR/ice-112822-expected-type-for-param.rs:3:25
    |
 LL | const fn test() -> impl ~const Fn() {
-   |                                ^^^^
+   |                         ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/effects/spec-effectvar-ice.stderr b/tests/ui/traits/const-traits/effects/spec-effectvar-ice.stderr
index d9655c4995f..0cb172a2d14 100644
--- a/tests/ui/traits/const-traits/effects/spec-effectvar-ice.stderr
+++ b/tests/ui/traits/const-traits/effects/spec-effectvar-ice.stderr
@@ -37,10 +37,10 @@ LL | impl<T> const Foo for T where T: const Specialize {}
    = note: adding a non-const method body in the future would be a breaking change
 
 error: `const` can only be applied to `#[const_trait]` traits
-  --> $DIR/spec-effectvar-ice.rs:14:40
+  --> $DIR/spec-effectvar-ice.rs:14:34
    |
 LL | impl<T> const Foo for T where T: const Specialize {}
-   |                                        ^^^^^^^^^^
+   |                                  ^^^^^
 
 error: specialization impl does not specialize any associated items
   --> $DIR/spec-effectvar-ice.rs:14:1
diff --git a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr
index 03f88be0093..dcb7dd7a142 100644
--- a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr
+++ b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr
@@ -4,16 +4,16 @@ error: using `#![feature(effects)]` without enabling next trait solver globally
    = help: use `-Znext-solver` to enable
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/ice-123664-unexpected-bound-var.rs:4:34
+  --> $DIR/ice-123664-unexpected-bound-var.rs:4:27
    |
 LL | const fn with_positive<F: ~const Fn()>() {}
-   |                                  ^^^^
+   |                           ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/ice-123664-unexpected-bound-var.rs:4:34
+  --> $DIR/ice-123664-unexpected-bound-var.rs:4:27
    |
 LL | const fn with_positive<F: ~const Fn()>() {}
-   |                                  ^^^^
+   |                           ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/issue-92111.stderr b/tests/ui/traits/const-traits/issue-92111.stderr
index 805cc537014..51c6a22b43b 100644
--- a/tests/ui/traits/const-traits/issue-92111.stderr
+++ b/tests/ui/traits/const-traits/issue-92111.stderr
@@ -1,14 +1,14 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/issue-92111.rs:20:22
+  --> $DIR/issue-92111.rs:20:15
    |
 LL | const fn a<T: ~const Destruct>(t: T) {}
-   |                      ^^^^^^^^
+   |               ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/issue-92111.rs:20:22
+  --> $DIR/issue-92111.rs:20:15
    |
 LL | const fn a<T: ~const Destruct>(t: T) {}
-   |                      ^^^^^^^^
+   |               ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr
index 3b3868c4bc8..054a8ac7577 100644
--- a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr
+++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr
@@ -17,7 +17,7 @@ note: required by a bound in `Foo::Assoc`
   --> $DIR/item-bound-entailment-fails.rs:6:20
    |
 LL |     type Assoc<T>: ~const Bar
-   |                    ^^^^^^^^^^ required by this bound in `Foo::Assoc`
+   |                    ^^^^^^ required by this bound in `Foo::Assoc`
 
 error[E0277]: the trait bound `T: ~const Bar` is not satisfied
   --> $DIR/item-bound-entailment-fails.rs:25:21
@@ -29,7 +29,7 @@ note: required by a bound in `Foo::Assoc`
   --> $DIR/item-bound-entailment-fails.rs:6:20
    |
 LL |     type Assoc<T>: ~const Bar
-   |                    ^^^^^^^^^^ required by this bound in `Foo::Assoc`
+   |                    ^^^^^^ required by this bound in `Foo::Assoc`
 
 error: aborting due to 2 previous errors; 1 warning emitted
 
diff --git a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr
index 08a40fe65bf..837effb7ca4 100644
--- a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr
+++ b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr
@@ -1,14 +1,14 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/non-const-op-in-closure-in-const.rs:10:51
+  --> $DIR/non-const-op-in-closure-in-const.rs:10:44
    |
 LL | impl<A, B> const Convert<B> for A where B: ~const From<A> {
-   |                                                   ^^^^^^^
+   |                                            ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/non-const-op-in-closure-in-const.rs:10:51
+  --> $DIR/non-const-op-in-closure-in-const.rs:10:44
    |
 LL | impl<A, B> const Convert<B> for A where B: ~const From<A> {
-   |                                                   ^^^^^^^
+   |                                            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/predicate-entailment-fails.stderr b/tests/ui/traits/const-traits/predicate-entailment-fails.stderr
index 7cd48ef1d48..c50009e9b8c 100644
--- a/tests/ui/traits/const-traits/predicate-entailment-fails.stderr
+++ b/tests/ui/traits/const-traits/predicate-entailment-fails.stderr
@@ -14,7 +14,7 @@ LL |     type Bar<T> where T: ~const Bar;
    |     ----------- definition of `Bar` from trait
 ...
 LL |     type Bar<T> = () where T: const Bar;
-   |                               ^^^^^^^^^ impl has extra requirement `T: const Bar`
+   |                               ^^^^^ impl has extra requirement `T: const Bar`
 
 error[E0276]: impl has stricter requirements than trait
   --> $DIR/predicate-entailment-fails.rs:18:26
@@ -23,7 +23,7 @@ LL |     fn foo<T>() where T: ~const Bar;
    |     -------------------------------- definition of `foo` from trait
 ...
 LL |     fn foo<T>() where T: const Bar {}
-   |                          ^^^^^^^^^ impl has extra requirement `T: const Bar`
+   |                          ^^^^^ impl has extra requirement `T: const Bar`
 
 error[E0276]: impl has stricter requirements than trait
   --> $DIR/predicate-entailment-fails.rs:29:31
@@ -32,7 +32,7 @@ LL |     type Bar<T> where T: Bar;
    |     ----------- definition of `Bar` from trait
 ...
 LL |     type Bar<T> = () where T: const Bar;
-   |                               ^^^^^^^^^ impl has extra requirement `T: const Bar`
+   |                               ^^^^^ impl has extra requirement `T: const Bar`
 
 error[E0276]: impl has stricter requirements than trait
   --> $DIR/predicate-entailment-fails.rs:32:26
@@ -41,7 +41,7 @@ LL |     fn foo<T>() where T: Bar;
    |     ------------------------- definition of `foo` from trait
 ...
 LL |     fn foo<T>() where T: const Bar {}
-   |                          ^^^^^^^^^ impl has extra requirement `T: const Bar`
+   |                          ^^^^^ impl has extra requirement `T: const Bar`
 
 error[E0276]: impl has stricter requirements than trait
   --> $DIR/predicate-entailment-fails.rs:36:31
@@ -50,7 +50,7 @@ LL |     type Bar<T> where T: Bar;
    |     ----------- definition of `Bar` from trait
 ...
 LL |     type Bar<T> = () where T: ~const Bar;
-   |                               ^^^^^^^^^^ impl has extra requirement `T: ~const Bar`
+   |                               ^^^^^^ impl has extra requirement `T: ~const Bar`
 
 error[E0276]: impl has stricter requirements than trait
   --> $DIR/predicate-entailment-fails.rs:39:26
@@ -59,7 +59,7 @@ LL |     fn foo<T>() where T: Bar;
    |     ------------------------- definition of `foo` from trait
 ...
 LL |     fn foo<T>() where T: ~const Bar {}
-   |                          ^^^^^^^^^^ impl has extra requirement `T: ~const Bar`
+   |                          ^^^^^^ impl has extra requirement `T: ~const Bar`
 
 error: aborting due to 6 previous errors; 1 warning emitted
 
diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr
index 6277966b08e..8de1bb07e90 100644
--- a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr
+++ b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr
@@ -11,24 +11,24 @@ LL | trait Bar: ~const Foo {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-2.rs:12:19
+  --> $DIR/super-traits-fail-2.rs:12:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-2.rs:12:19
+  --> $DIR/super-traits-fail-2.rs:12:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-2.rs:12:19
+  --> $DIR/super-traits-fail-2.rs:12:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr
index 60660ecc279..82b306aeff6 100644
--- a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr
+++ b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr
@@ -1,38 +1,38 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-2.rs:12:19
+  --> $DIR/super-traits-fail-2.rs:12:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-2.rs:12:19
+  --> $DIR/super-traits-fail-2.rs:12:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-2.rs:12:19
+  --> $DIR/super-traits-fail-2.rs:12:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-2.rs:12:19
+  --> $DIR/super-traits-fail-2.rs:12:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-2.rs:12:19
+  --> $DIR/super-traits-fail-2.rs:12:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nn.stderr
index b39bf8d8e15..1dd4a2ed5a5 100644
--- a/tests/ui/traits/const-traits/super-traits-fail-3.nn.stderr
+++ b/tests/ui/traits/const-traits/super-traits-fail-3.nn.stderr
@@ -11,38 +11,38 @@ LL | trait Bar: ~const Foo {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:14:19
+  --> $DIR/super-traits-fail-3.rs:14:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:14:19
+  --> $DIR/super-traits-fail-3.rs:14:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:14:19
+  --> $DIR/super-traits-fail-3.rs:14:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:22:24
+  --> $DIR/super-traits-fail-3.rs:22:17
    |
 LL | const fn foo<T: ~const Bar>(x: &T) {
-   |                        ^^^
+   |                 ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:22:24
+  --> $DIR/super-traits-fail-3.rs:22:17
    |
 LL | const fn foo<T: ~const Bar>(x: &T) {
-   |                        ^^^
+   |                 ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.ny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.ny.stderr
index 187cd998d95..e619b8bd6ba 100644
--- a/tests/ui/traits/const-traits/super-traits-fail-3.ny.stderr
+++ b/tests/ui/traits/const-traits/super-traits-fail-3.ny.stderr
@@ -1,38 +1,38 @@
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:14:19
+  --> $DIR/super-traits-fail-3.rs:14:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:14:19
+  --> $DIR/super-traits-fail-3.rs:14:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:14:19
+  --> $DIR/super-traits-fail-3.rs:14:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:14:19
+  --> $DIR/super-traits-fail-3.rs:14:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:14:19
+  --> $DIR/super-traits-fail-3.rs:14:12
    |
 LL | trait Bar: ~const Foo {}
-   |                   ^^^
+   |            ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yn.stderr
index b6747d10e83..0a36d40d931 100644
--- a/tests/ui/traits/const-traits/super-traits-fail-3.yn.stderr
+++ b/tests/ui/traits/const-traits/super-traits-fail-3.yn.stderr
@@ -11,16 +11,16 @@ LL | trait Bar: ~const Foo {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:22:24
+  --> $DIR/super-traits-fail-3.rs:22:17
    |
 LL | const fn foo<T: ~const Bar>(x: &T) {
-   |                        ^^^
+   |                 ^^^^^^
 
 error: `~const` can only be applied to `#[const_trait]` traits
-  --> $DIR/super-traits-fail-3.rs:22:24
+  --> $DIR/super-traits-fail-3.rs:22:17
    |
 LL | const fn foo<T: ~const Bar>(x: &T) {
-   |                        ^^^
+   |                 ^^^^^^
    |
    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr
index e0cf062ad95..35f3019b6ee 100644
--- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr
+++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr
@@ -28,7 +28,7 @@ note: required by a bound in `require`
   --> $DIR/unsatisfied-const-trait-bound.rs:8:15
    |
 LL | fn require<T: const Trait>() {}
-   |               ^^^^^^^^^^^ required by this bound in `require`
+   |               ^^^^^ required by this bound in `require`
 
 error: aborting due to 4 previous errors