about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs37
-rw-r--r--tests/ui/const-generics/const-argument-if-length.full.stderr5
-rw-r--r--tests/ui/const-generics/defaults/generic-expr-default.stderr10
-rw-r--r--tests/ui/const-generics/ensure_is_evaluatable.stderr5
-rw-r--r--tests/ui/const-generics/fn_with_two_const_inputs.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.fixed21
-rw-r--r--tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs15
-rw-r--r--tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr21
-rw-r--r--tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr20
-rw-r--r--tests/ui/const-generics/generic_const_exprs/abstract-consts-as-cast-5.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr18
-rw-r--r--tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_binop_arg_tys.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_cast_arg_ty.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr20
-rw-r--r--tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr10
-rw-r--r--tests/ui/const-generics/generic_const_exprs/different-fn.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-83765.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-85848.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/needs_where_clause.stderr5
-rw-r--r--tests/ui/const-generics/generic_const_exprs/no_where_clause.stderr10
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr5
-rw-r--r--tests/ui/const-generics/issues/issue-67739.full.stderr5
-rw-r--r--tests/ui/const-generics/issues/issue-71202.stderr78
-rw-r--r--tests/ui/const-generics/issues/issue-84659.fixed13
-rw-r--r--tests/ui/const-generics/issues/issue-84659.rs3
-rw-r--r--tests/ui/const-generics/issues/issue-84659.stderr7
-rw-r--r--tests/ui/const-generics/issues/issue-90455.fixed13
-rw-r--r--tests/ui/const-generics/issues/issue-90455.rs3
-rw-r--r--tests/ui/const-generics/issues/issue-90455.stderr7
-rw-r--r--tests/ui/consts/const-needs_drop-monomorphic.stderr5
-rw-r--r--tests/ui/generic-const-items/evaluatable-bounds.fixed25
-rw-r--r--tests/ui/generic-const-items/evaluatable-bounds.rs12
-rw-r--r--tests/ui/generic-const-items/evaluatable-bounds.stderr13
-rw-r--r--tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr5
-rw-r--r--tests/ui/simd/array-trait.stderr6
-rw-r--r--tests/ui/specialization/issue-51892.stderr5
-rw-r--r--tests/ui/variance/variance-associated-consts.stderr5
41 files changed, 351 insertions, 111 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
index 9444cf8248e..3cc46b5c638 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
@@ -3536,12 +3536,39 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                     let mut err =
                         self.dcx().struct_span_err(span, "unconstrained generic constant");
                     let const_span = self.tcx.def_span(uv.def);
+
+                    let const_ty = self.tcx.type_of(uv.def).instantiate(self.tcx, uv.args);
+                    let cast = if const_ty != self.tcx.types.usize { " as usize" } else { "" };
+                    let msg = "try adding a `where` bound";
                     match self.tcx.sess.source_map().span_to_snippet(const_span) {
-                            Ok(snippet) => err.help(format!(
-                                "try adding a `where` bound using this expression: `where [(); {snippet}]:`"
-                            )),
-                            _ => err.help("consider adding a `where` bound using this expression"),
-                        };
+                        Ok(snippet) => {
+                            let code = format!("[(); {snippet}{cast}]:");
+                            let def_id = if let ObligationCauseCode::CompareImplItemObligation {
+                                trait_item_def_id,
+                                ..
+                            } = obligation.cause.code()
+                            {
+                                trait_item_def_id.as_local()
+                            } else {
+                                Some(obligation.cause.body_id)
+                            };
+                            if let Some(def_id) = def_id
+                                && let Some(generics) = self.tcx.hir().get_generics(def_id)
+                            {
+                                err.span_suggestion_verbose(
+                                    generics.tail_span_for_predicate_suggestion(),
+                                    msg,
+                                    format!("{} {code}", generics.add_where_or_trailing_comma()),
+                                    Applicability::MaybeIncorrect,
+                                );
+                            } else {
+                                err.help(format!("{msg}: where {code}"));
+                            };
+                        }
+                        _ => {
+                            err.help(msg);
+                        }
+                    };
                     Ok(err)
                 }
                 ty::ConstKind::Expr(_) => {
diff --git a/tests/ui/const-generics/const-argument-if-length.full.stderr b/tests/ui/const-generics/const-argument-if-length.full.stderr
index db3d88392bd..4de98c11d2b 100644
--- a/tests/ui/const-generics/const-argument-if-length.full.stderr
+++ b/tests/ui/const-generics/const-argument-if-length.full.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL |     pad: [u8; is_zst::<T>()],
    |          ^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); is_zst::<T>()]:`
+help: try adding a `where` bound
+   |
+LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: {
+   |                                   ++++++++++++++++++++++++++
 
 error[E0277]: the size for values of type `T` cannot be known at compilation time
   --> $DIR/const-argument-if-length.rs:16:12
diff --git a/tests/ui/const-generics/defaults/generic-expr-default.stderr b/tests/ui/const-generics/defaults/generic-expr-default.stderr
index ada1498d1c8..909edada4cb 100644
--- a/tests/ui/const-generics/defaults/generic-expr-default.stderr
+++ b/tests/ui/const-generics/defaults/generic-expr-default.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL | pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> {
    |                                                      ^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:`
+help: try adding a `where` bound
+   |
+LL | pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> where [(); { N + 1 }]: {
+   |                                                              ++++++++++++++++++++++
 
 error: unconstrained generic constant
   --> $DIR/generic-expr-default.rs:14:58
@@ -12,7 +15,10 @@ error: unconstrained generic constant
 LL | fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N>
    |                                                          ^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:`
+help: try adding a `where` bound
+   |
+LL | fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N> where [(); { N + 1 }]:
+   |                                                                      ++++++++++++++++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/const-generics/ensure_is_evaluatable.stderr b/tests/ui/const-generics/ensure_is_evaluatable.stderr
index b9bd9160b13..62f8bc34f2e 100644
--- a/tests/ui/const-generics/ensure_is_evaluatable.stderr
+++ b/tests/ui/const-generics/ensure_is_evaluatable.stderr
@@ -4,7 +4,6 @@ error: unconstrained generic constant
 LL |     bar()
    |     ^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); N + 1]:`
 note: required by a bound in `bar`
   --> $DIR/ensure_is_evaluatable.rs:15:10
    |
@@ -13,6 +12,10 @@ LL | fn bar<const N: usize>() -> [(); N]
 LL | where
 LL |     [(); N + 1]:,
    |          ^^^^^ required by this bound in `bar`
+help: try adding a `where` bound
+   |
+LL |     [(); M + 1]:, [(); N + 1]:
+   |                 ~~~~~~~~~~~~~~
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/const-generics/fn_with_two_const_inputs.stderr b/tests/ui/const-generics/fn_with_two_const_inputs.stderr
index ec31e02f144..c0a913a21fd 100644
--- a/tests/ui/const-generics/fn_with_two_const_inputs.stderr
+++ b/tests/ui/const-generics/fn_with_two_const_inputs.stderr
@@ -4,7 +4,6 @@ error: unconstrained generic constant
 LL |     bar()
    |     ^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); N + 1]:`
 note: required by a bound in `bar`
   --> $DIR/fn_with_two_const_inputs.rs:18:10
    |
@@ -13,6 +12,10 @@ LL | fn bar<const N: usize>() -> [(); N]
 LL | where
 LL |     [(); N + 1]:,
    |          ^^^^^ required by this bound in `bar`
+help: try adding a `where` bound
+   |
+LL |     [(); both(N + 1, M + 1)]:, [(); N + 1]:
+   |                              ~~~~~~~~~~~~~~
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.fixed b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.fixed
new file mode 100644
index 00000000000..929282f40e6
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.fixed
@@ -0,0 +1,21 @@
+//@ run-rustfix
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features, dead_code)]
+
+struct Evaluatable<const N: u128> {}
+
+struct Foo<const N: u8>([u8; N as usize])
+//~^ ERROR unconstrained generic constant
+where
+    Evaluatable<{N as u128}>:, [(); N as usize]:;
+//~^ HELP try adding a `where` bound
+
+struct Foo2<const N: u8>(Evaluatable::<{N as u128}>) where Evaluatable<{N as usize as u128 }>:, [(); {N as u128} as usize]:;
+//~^ ERROR unconstrained generic constant
+//~| HELP try adding a `where` bound
+
+struct Bar<const N: u8>([u8; (N + 2) as usize]) where [(); (N + 1) as usize]:, [(); (N + 2) as usize]:;
+//~^ ERROR unconstrained generic constant
+//~| HELP try adding a `where` bound
+
+fn main() {}
diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs
index 3b5b87b2b3d..3a6c4d35451 100644
--- a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs
+++ b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs
@@ -1,20 +1,21 @@
+//@ run-rustfix
 #![feature(generic_const_exprs)]
-#![allow(incomplete_features)]
+#![allow(incomplete_features, dead_code)]
 
 struct Evaluatable<const N: u128> {}
 
 struct Foo<const N: u8>([u8; N as usize])
-//~^ Error: unconstrained generic constant
-//~| help: try adding a `where` bound using this expression: `where [(); N as usize]:`
+//~^ ERROR unconstrained generic constant
 where
     Evaluatable<{N as u128}>:;
+//~^ HELP try adding a `where` bound
 
 struct Foo2<const N: u8>(Evaluatable::<{N as u128}>) where Evaluatable<{N as usize as u128 }>:;
-//~^ Error: unconstrained generic constant
-//~| help: try adding a `where` bound using this expression: `where [(); {N as u128}]:`
+//~^ ERROR unconstrained generic constant
+//~| HELP try adding a `where` bound
 
 struct Bar<const N: u8>([u8; (N + 2) as usize]) where [(); (N + 1) as usize]:;
-//~^ Error: unconstrained generic constant
-//~| help: try adding a `where` bound using this expression: `where [(); (N + 2) as usize]:`
+//~^ ERROR unconstrained generic constant
+//~| HELP try adding a `where` bound
 
 fn main() {}
diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr
index 5ca04d25e55..ce8eca8d25e 100644
--- a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr
@@ -1,26 +1,35 @@
 error: unconstrained generic constant
-  --> $DIR/abstract-const-as-cast-2.rs:6:25
+  --> $DIR/abstract-const-as-cast-2.rs:7:25
    |
 LL | struct Foo<const N: u8>([u8; N as usize])
    |                         ^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); N as usize]:`
+help: try adding a `where` bound
+   |
+LL |     Evaluatable<{N as u128}>:, [(); N as usize]:;
+   |                              +++++++++++++++++++
 
 error: unconstrained generic constant
-  --> $DIR/abstract-const-as-cast-2.rs:12:26
+  --> $DIR/abstract-const-as-cast-2.rs:13:26
    |
 LL | struct Foo2<const N: u8>(Evaluatable::<{N as u128}>) where Evaluatable<{N as usize as u128 }>:;
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); {N as u128}]:`
+help: try adding a `where` bound
+   |
+LL | struct Foo2<const N: u8>(Evaluatable::<{N as u128}>) where Evaluatable<{N as usize as u128 }>:, [(); {N as u128} as usize]:;
+   |                                                                                               +++++++++++++++++++++++++++++
 
 error: unconstrained generic constant
-  --> $DIR/abstract-const-as-cast-2.rs:16:25
+  --> $DIR/abstract-const-as-cast-2.rs:17:25
    |
 LL | struct Bar<const N: u8>([u8; (N + 2) as usize]) where [(); (N + 1) as usize]:;
    |                         ^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); (N + 2) as usize]:`
+help: try adding a `where` bound
+   |
+LL | struct Bar<const N: u8>([u8; (N + 2) as usize]) where [(); (N + 1) as usize]:, [(); (N + 2) as usize]:;
+   |                                                                              +++++++++++++++++++++++++
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr
index bd6fd67b89d..3622ef16a96 100644
--- a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr
@@ -4,7 +4,6 @@ error: unconstrained generic constant
 LL |     assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as u128 }>>();
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { O as u128 }]:`
 note: required for `HasCastInTraitImpl<{ N + 1 }, { N as u128 }>` to implement `Trait`
   --> $DIR/abstract-const-as-cast-3.rs:8:22
    |
@@ -15,6 +14,10 @@ note: required by a bound in `use_trait_impl::assert_impl`
    |
 LL |     fn assert_impl<T: Trait>() {}
    |                       ^^^^^ required by this bound in `assert_impl`
+help: try adding a `where` bound
+   |
+LL |     EvaluatableU128<{N as u128}>:, [(); { O as u128 } as usize]: {
+   |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error[E0308]: mismatched types
   --> $DIR/abstract-const-as-cast-3.rs:17:5
@@ -36,7 +39,6 @@ error: unconstrained generic constant
 LL |     assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as _ }>>();
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { O as u128 }]:`
 note: required for `HasCastInTraitImpl<{ N + 1 }, { N as _ }>` to implement `Trait`
   --> $DIR/abstract-const-as-cast-3.rs:8:22
    |
@@ -47,6 +49,10 @@ note: required by a bound in `use_trait_impl::assert_impl`
    |
 LL |     fn assert_impl<T: Trait>() {}
    |                       ^^^^^ required by this bound in `assert_impl`
+help: try adding a `where` bound
+   |
+LL |     EvaluatableU128<{N as u128}>:, [(); { O as u128 } as usize]: {
+   |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error[E0308]: mismatched types
   --> $DIR/abstract-const-as-cast-3.rs:20:5
@@ -96,7 +102,6 @@ error: unconstrained generic constant
 LL |     assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as u128 }>>();
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { O as u128 }]:`
 note: required for `HasCastInTraitImpl<{ N + 1 }, { N as u128 }>` to implement `Trait`
   --> $DIR/abstract-const-as-cast-3.rs:8:22
    |
@@ -107,6 +112,10 @@ note: required by a bound in `use_trait_impl_2::assert_impl`
    |
 LL |     fn assert_impl<T: Trait>() {}
    |                       ^^^^^ required by this bound in `assert_impl`
+help: try adding a `where` bound
+   |
+LL |     EvaluatableU128<{N as _}>:, [(); { O as u128 } as usize]: {
+   |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error[E0308]: mismatched types
   --> $DIR/abstract-const-as-cast-3.rs:35:5
@@ -128,7 +137,6 @@ error: unconstrained generic constant
 LL |     assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as _ }>>();
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { O as u128 }]:`
 note: required for `HasCastInTraitImpl<{ N + 1 }, { N as _ }>` to implement `Trait`
   --> $DIR/abstract-const-as-cast-3.rs:8:22
    |
@@ -139,6 +147,10 @@ note: required by a bound in `use_trait_impl_2::assert_impl`
    |
 LL |     fn assert_impl<T: Trait>() {}
    |                       ^^^^^ required by this bound in `assert_impl`
+help: try adding a `where` bound
+   |
+LL |     EvaluatableU128<{N as _}>:, [(); { O as u128 } as usize]: {
+   |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 error[E0308]: mismatched types
   --> $DIR/abstract-const-as-cast-3.rs:38:5
diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-consts-as-cast-5.stderr b/tests/ui/const-generics/generic_const_exprs/abstract-consts-as-cast-5.stderr
index 4b76ae6cfd5..5fc36ebc929 100644
--- a/tests/ui/const-generics/generic_const_exprs/abstract-consts-as-cast-5.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/abstract-consts-as-cast-5.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL |     bar::<{ N as usize as usize }>();
    |           ^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { N as usize as usize }]:`
+help: try adding a `where` bound
+   |
+LL | fn foo<const N: u8>(a: [(); N as usize]) where [(); { N as usize as usize }]: {
+   |                                          ++++++++++++++++++++++++++++++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr
index c478718b4cc..471b850d8d5 100644
--- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
    |                                      ^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); 0 + N]:`
+help: try adding a `where` bound
+   |
+LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]) where [(); 0 + N]:;
+   |                                                    ++++++++++++++++++
 
 error: overly complex generic constant
   --> $DIR/array-size-in-generic-struct-param.rs:23:15
diff --git a/tests/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr b/tests/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr
index a8657bf5263..f3a38fcc005 100644
--- a/tests/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL |     bar::<{ T::ASSOC }>();
    |           ^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { T::ASSOC }]:`
+help: try adding a `where` bound
+   |
+LL | fn foo<T: Trait, U: Trait>() where [(); U::ASSOC]:, [(); { T::ASSOC }]: {
+   |                                                   ~~~~~~~~~~~~~~~~~~~~~
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr
index 9a8aa222dc1..0c29d94ed5b 100644
--- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr
@@ -24,7 +24,10 @@ error: unconstrained generic constant
 LL |     foo::<_, L>([(); L + 1 + L]);
    |                      ^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); L + 1 + L]:`
+help: try adding a `where` bound
+   |
+LL |     [(); (L - 1) + 1 + L]:, [(); L + 1 + L]:
+   |                           ~~~~~~~~~~~~~~~~~~
 
 error: unconstrained generic constant
   --> $DIR/issue_114151.rs:17:17
@@ -34,11 +37,6 @@ LL |     foo::<_, L>([(); L + 1 + L]);
    |     |
    |     required by a bound introduced by this call
    |
-   = help: try adding a `where` bound using this expression: `where [(); {
-                   {
-                       N
-                   }
-               }]:`
 note: required by a bound in `foo`
   --> $DIR/issue_114151.rs:5:13
    |
@@ -51,6 +49,14 @@ LL | |             N
 LL | |         }
 LL | |     }],
    | |_____^ required by this bound in `foo`
+help: try adding a `where` bound
+   |
+LL ~     [(); (L - 1) + 1 + L]:, [(); {
+LL +         {
+LL +             N
+LL +         }
+LL +     }]:
+   |
 
 error: unconstrained generic constant `L + 1 + L`
   --> $DIR/issue_114151.rs:17:5
diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_binop_arg_tys.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_binop_arg_tys.stderr
index ba824e84a5a..6a62c0b4778 100644
--- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_binop_arg_tys.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_binop_arg_tys.stderr
@@ -13,7 +13,10 @@ error: unconstrained generic constant
 LL |     Bar::<{ make_generic(N, 1_u8 == 0_u8) }>
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { make_generic(N, 1_u8 == 0_u8) }]:`
+help: try adding a `where` bound
+   |
+LL | fn foo<const N: usize>() -> Bar<{ make_generic(N, true == false) }> where [(); { make_generic(N, 1_u8 == 0_u8) } as usize]: {
+   |                                                                     +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_cast_arg_ty.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_cast_arg_ty.stderr
index d3ba870a2d7..fba8b9e7784 100644
--- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_cast_arg_ty.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_cast_arg_ty.stderr
@@ -13,7 +13,10 @@ error: unconstrained generic constant
 LL |     [(); (1_u8 as usize) + N]
    |          ^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); (1_u8 as usize) + N]:`
+help: try adding a `where` bound
+   |
+LL | fn foo<const N: usize>() -> [(); (true as usize) + N] where [(); (1_u8 as usize) + N]: {
+   |                                                       ++++++++++++++++++++++++++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr
index da5194696e6..99eab935a09 100644
--- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr
@@ -13,7 +13,10 @@ error: unconstrained generic constant
 LL |     foo::<_, L>([(); L + 1 + L]);
    |                      ^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); L + 1 + L]:`
+help: try adding a `where` bound
+   |
+LL |     [(); (L - 1) + 1 + L]:, [(); L + 1 + L]:
+   |                           ~~~~~~~~~~~~~~~~~~
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr
index 921314f0c50..a05aaf2af64 100644
--- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr
@@ -4,7 +4,6 @@ error: unconstrained generic constant
 LL |     let _ = const_evaluatable_lib::test1::<T>();
    |                                            ^
    |
-   = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:`
 note: required by a bound in `test1`
   --> $DIR/auxiliary/const_evaluatable_lib.rs:5:10
    |
@@ -13,6 +12,10 @@ LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
 LL | where
 LL |     [u8; std::mem::size_of::<T>() - 1]: Sized,
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1`
+help: try adding a `where` bound
+   |
+LL | fn user<T>() where [(); std::mem::size_of::<T>() - 1]: {
+   |              +++++++++++++++++++++++++++++++++++++++++
 
 error: unconstrained generic constant
   --> $DIR/cross_crate_predicate.rs:7:44
@@ -20,12 +23,15 @@ error: unconstrained generic constant
 LL |     let _ = const_evaluatable_lib::test1::<T>();
    |                                            ^
    |
-   = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:`
 note: required by a bound in `test1`
   --> $DIR/auxiliary/const_evaluatable_lib.rs:3:27
    |
 LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1`
+help: try adding a `where` bound
+   |
+LL | fn user<T>() where [(); std::mem::size_of::<T>() - 1]: {
+   |              +++++++++++++++++++++++++++++++++++++++++
 
 error: unconstrained generic constant
   --> $DIR/cross_crate_predicate.rs:7:13
@@ -33,7 +39,6 @@ error: unconstrained generic constant
 LL |     let _ = const_evaluatable_lib::test1::<T>();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:`
 note: required by a bound in `test1`
   --> $DIR/auxiliary/const_evaluatable_lib.rs:5:10
    |
@@ -42,6 +47,10 @@ LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
 LL | where
 LL |     [u8; std::mem::size_of::<T>() - 1]: Sized,
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1`
+help: try adding a `where` bound
+   |
+LL | fn user<T>() where [(); std::mem::size_of::<T>() - 1]: {
+   |              +++++++++++++++++++++++++++++++++++++++++
 
 error: unconstrained generic constant
   --> $DIR/cross_crate_predicate.rs:7:13
@@ -49,12 +58,15 @@ error: unconstrained generic constant
 LL |     let _ = const_evaluatable_lib::test1::<T>();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:`
 note: required by a bound in `test1`
   --> $DIR/auxiliary/const_evaluatable_lib.rs:3:27
    |
 LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1`
+help: try adding a `where` bound
+   |
+LL | fn user<T>() where [(); std::mem::size_of::<T>() - 1]: {
+   |              +++++++++++++++++++++++++++++++++++++++++
 
 error: aborting due to 4 previous errors
 
diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr
index 74111ef1d38..632ece0ddcb 100644
--- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr
@@ -20,7 +20,10 @@ error: unconstrained generic constant
 LL |     let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); size_of::<*mut T>()]:`
+help: try adding a `where` bound
+   |
+LL | fn foo<T>() where [(); size_of::<*mut T>()]: {
+   |             ++++++++++++++++++++++++++++++++
 
 error: unconstrained generic constant
   --> $DIR/dependence_lint.rs:10:9
@@ -28,7 +31,10 @@ error: unconstrained generic constant
 LL |     [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs`
    |         ^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); size_of::<*mut T>()]:`
+help: try adding a `where` bound
+   |
+LL | fn foo<T>() where [(); size_of::<*mut T>()]: {
+   |             ++++++++++++++++++++++++++++++++
 
 error: aborting due to 4 previous errors
 
diff --git a/tests/ui/const-generics/generic_const_exprs/different-fn.stderr b/tests/ui/const-generics/generic_const_exprs/different-fn.stderr
index 83a2f3740b1..52917df0da1 100644
--- a/tests/ui/const-generics/generic_const_exprs/different-fn.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/different-fn.stderr
@@ -13,7 +13,10 @@ error: unconstrained generic constant
 LL |     [0; size_of::<Foo<T>>()]
    |         ^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); size_of::<Foo<T>>()]:`
+help: try adding a `where` bound
+   |
+LL | fn test<T>() -> [u8; size_of::<T>()] where [(); size_of::<Foo<T>>()]: {
+   |                                      ++++++++++++++++++++++++++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr b/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr
index 87e26ce85dc..f27d52a1437 100644
--- a/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr
@@ -13,7 +13,10 @@ error: unconstrained generic constant
 LL |         ArrayHolder([0; Self::SIZE])
    |                         ^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); Self::SIZE]:`
+help: try adding a `where` bound
+   |
+LL |     pub const fn new() -> Self where [(); Self::SIZE]: {
+   |                                +++++++++++++++++++++++
 
 error[E0282]: type annotations needed for `ArrayHolder<X>`
   --> $DIR/issue-62504.rs:26:9
diff --git a/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr b/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr
index b693023f125..ca6681b635a 100644
--- a/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr
@@ -13,12 +13,15 @@ error: unconstrained generic constant
 LL |         self.reference.size()
    |                        ^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
 note: required by a bound in `TensorSize::size`
   --> $DIR/issue-83765.rs:9:31
    |
 LL |     fn size(&self) -> [usize; Self::DIM];
    |                               ^^^^^^^^^ required by this bound in `TensorSize::size`
+help: try adding a `where` bound
+   |
+LL |     fn size(&self) -> [usize; DIM] where [(); Self::DIM]: {
+   |                                    ++++++++++++++++++++++
 
 error[E0308]: mismatched types
   --> $DIR/issue-83765.rs:32:9
diff --git a/tests/ui/const-generics/generic_const_exprs/issue-85848.stderr b/tests/ui/const-generics/generic_const_exprs/issue-85848.stderr
index 3acccba026f..4abe39eb598 100644
--- a/tests/ui/const-generics/generic_const_exprs/issue-85848.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/issue-85848.stderr
@@ -35,7 +35,6 @@ LL |     writes_to_specific_path(&cap);
    |     |
    |     required by a bound introduced by this call
    |
-   = help: try adding a `where` bound using this expression: `where [(); { contains::<T, U>() }]:`
 note: required for `&C` to implement `Contains<(), true>`
   --> $DIR/issue-85848.rs:21:12
    |
@@ -53,6 +52,10 @@ note: required by a bound in `writes_to_specific_path`
    |
 LL | fn writes_to_specific_path<C: Delegates<()>>(cap: &C) {}
    |                               ^^^^^^^^^^^^^ required by this bound in `writes_to_specific_path`
+help: try adding a `where` bound
+   |
+LL | fn writes_to_path<C>(cap: &C) where [(); { contains::<T, U>() } as usize]: {
+   |                               ++++++++++++++++++++++++++++++++++++++++++++
 
 error[E0308]: mismatched types
   --> $DIR/issue-85848.rs:24:5
diff --git a/tests/ui/const-generics/generic_const_exprs/needs_where_clause.stderr b/tests/ui/const-generics/generic_const_exprs/needs_where_clause.stderr
index 395088bf2f2..c83e859ac79 100644
--- a/tests/ui/const-generics/generic_const_exprs/needs_where_clause.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/needs_where_clause.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL |   b: [f32; complex_maths::<T>(N)],
    |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); complex_maths::<T>(N)]:`
+help: try adding a `where` bound
+   |
+LL | struct Example<T, const N: usize> where [(); complex_maths::<T>(N)]: {
+   |                                   ++++++++++++++++++++++++++++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/const-generics/generic_const_exprs/no_where_clause.stderr b/tests/ui/const-generics/generic_const_exprs/no_where_clause.stderr
index 4a87649f43d..a2680eac039 100644
--- a/tests/ui/const-generics/generic_const_exprs/no_where_clause.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/no_where_clause.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL |   b: [f32; complex_maths(N)],
    |      ^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); complex_maths(N)]:`
+help: try adding a `where` bound
+   |
+LL | pub struct Example<const N: usize> where [(); complex_maths(N)]: {
+   |                                    +++++++++++++++++++++++++++++
 
 error: unconstrained generic constant
   --> $DIR/no_where_clause.rs:18:15
@@ -12,7 +15,10 @@ error: unconstrained generic constant
 LL |       b: [0.; complex_maths(N)],
    |               ^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); complex_maths(N)]:`
+help: try adding a `where` bound
+   |
+LL |   pub fn new() -> Self where [(); complex_maths(N)]: {
+   |                        +++++++++++++++++++++++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
index 0bf99bb8b26..335130c958f 100644
--- a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
@@ -40,7 +40,10 @@ error: unconstrained generic constant
 LL |     bar2::<{ std::ops::Add::add(N, N) }>();
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { std::ops::Add::add(N, N) }]:`
+help: try adding a `where` bound
+   |
+LL | fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) where [(); { std::ops::Add::add(N, N) }]: {
+   |                                                     +++++++++++++++++++++++++++++++++++++++++
 
 error[E0015]: cannot call non-const operator in constants
   --> $DIR/unify-op-with-fn-call.rs:20:39
diff --git a/tests/ui/const-generics/issues/issue-67739.full.stderr b/tests/ui/const-generics/issues/issue-67739.full.stderr
index bdf05023d5f..99368a66148 100644
--- a/tests/ui/const-generics/issues/issue-67739.full.stderr
+++ b/tests/ui/const-generics/issues/issue-67739.full.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL |         [0u8; mem::size_of::<Self::Associated>()];
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); mem::size_of::<Self::Associated>()]:`
+help: try adding a `where` bound
+   |
+LL |     fn associated_size(&self) -> usize where [(); mem::size_of::<Self::Associated>()]: {
+   |                                        +++++++++++++++++++++++++++++++++++++++++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/const-generics/issues/issue-71202.stderr b/tests/ui/const-generics/issues/issue-71202.stderr
index 437b808c893..a2d38221852 100644
--- a/tests/ui/const-generics/issues/issue-71202.stderr
+++ b/tests/ui/const-generics/issues/issue-71202.stderr
@@ -10,24 +10,27 @@ LL | |         <IsCopy<T>>::VALUE
 LL | |     } as usize] = [];
    | |_____________________^
    |
-   = help: try adding a `where` bound using this expression: `where [(); 1 - {
-                   trait NotCopy {
-                       const VALUE: bool = false;
-                   }
-           
-                   impl<__Type: ?Sized> NotCopy for __Type {}
-           
-                   struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
-           
-                   impl<__Type> IsCopy<__Type>
-                   where
-                       __Type: Sized + Copy,
-                   {
-                       const VALUE: bool = true;
-                   }
-           
-                   <IsCopy<T>>::VALUE
-               } as usize]:`
+help: try adding a `where` bound
+   |
+LL ~     } as usize] where [(); 1 - {
+LL +         trait NotCopy {
+LL +             const VALUE: bool = false;
+LL +         }
+LL + 
+LL +         impl<__Type: ?Sized> NotCopy for __Type {}
+LL + 
+LL +         struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
+LL + 
+LL +         impl<__Type> IsCopy<__Type>
+LL +         where
+LL +             __Type: Sized + Copy,
+LL +         {
+LL +             const VALUE: bool = true;
+LL +         }
+LL + 
+LL +         <IsCopy<T>>::VALUE
+LL ~     } as usize]: = [];
+   |
 
 error: unconstrained generic constant
   --> $DIR/issue-71202.rs:28:19
@@ -35,24 +38,27 @@ error: unconstrained generic constant
 LL |     } as usize] = [];
    |                   ^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); 1 - {
-                   trait NotCopy {
-                       const VALUE: bool = false;
-                   }
-           
-                   impl<__Type: ?Sized> NotCopy for __Type {}
-           
-                   struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
-           
-                   impl<__Type> IsCopy<__Type>
-                   where
-                       __Type: Sized + Copy,
-                   {
-                       const VALUE: bool = true;
-                   }
-           
-                   <IsCopy<T>>::VALUE
-               } as usize]:`
+help: try adding a `where` bound
+   |
+LL ~     } as usize] where [(); 1 - {
+LL +         trait NotCopy {
+LL +             const VALUE: bool = false;
+LL +         }
+LL + 
+LL +         impl<__Type: ?Sized> NotCopy for __Type {}
+LL + 
+LL +         struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
+LL + 
+LL +         impl<__Type> IsCopy<__Type>
+LL +         where
+LL +             __Type: Sized + Copy,
+LL +         {
+LL +             const VALUE: bool = true;
+LL +         }
+LL + 
+LL +         <IsCopy<T>>::VALUE
+LL ~     } as usize]: = [];
+   |
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/const-generics/issues/issue-84659.fixed b/tests/ui/const-generics/issues/issue-84659.fixed
new file mode 100644
index 00000000000..85f1adc5c19
--- /dev/null
+++ b/tests/ui/const-generics/issues/issue-84659.fixed
@@ -0,0 +1,13 @@
+//@ run-rustfix
+#![allow(incomplete_features, dead_code, unused_braces)]
+#![feature(generic_const_exprs)]
+
+trait Bar<const N: usize> {}
+
+trait Foo<'a> {
+    const N: usize;
+    type Baz: Bar<{ Self::N }> where [(); { Self::N }]:;
+    //~^ ERROR: unconstrained generic constant
+}
+
+fn main() {}
diff --git a/tests/ui/const-generics/issues/issue-84659.rs b/tests/ui/const-generics/issues/issue-84659.rs
index 440ca740af2..b2ea6320f73 100644
--- a/tests/ui/const-generics/issues/issue-84659.rs
+++ b/tests/ui/const-generics/issues/issue-84659.rs
@@ -1,4 +1,5 @@
-#![allow(incomplete_features)]
+//@ run-rustfix
+#![allow(incomplete_features, dead_code, unused_braces)]
 #![feature(generic_const_exprs)]
 
 trait Bar<const N: usize> {}
diff --git a/tests/ui/const-generics/issues/issue-84659.stderr b/tests/ui/const-generics/issues/issue-84659.stderr
index 796c5515e04..82e80603c7f 100644
--- a/tests/ui/const-generics/issues/issue-84659.stderr
+++ b/tests/ui/const-generics/issues/issue-84659.stderr
@@ -1,10 +1,13 @@
 error: unconstrained generic constant
-  --> $DIR/issue-84659.rs:8:15
+  --> $DIR/issue-84659.rs:9:15
    |
 LL |     type Baz: Bar<{ Self::N }>;
    |               ^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { Self::N }]:`
+help: try adding a `where` bound
+   |
+LL |     type Baz: Bar<{ Self::N }> where [(); { Self::N }]:;
+   |                                ++++++++++++++++++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/const-generics/issues/issue-90455.fixed b/tests/ui/const-generics/issues/issue-90455.fixed
new file mode 100644
index 00000000000..2502d47eb46
--- /dev/null
+++ b/tests/ui/const-generics/issues/issue-90455.fixed
@@ -0,0 +1,13 @@
+//@ run-rustfix
+#![feature(generic_const_exprs, adt_const_params)]
+#![allow(incomplete_features, dead_code)]
+
+struct FieldElement<const N: &'static str> where [(); num_limbs(N)]: {
+    n: [u64; num_limbs(N)],
+    //~^ ERROR unconstrained generic constant
+}
+const fn num_limbs(_: &str) -> usize {
+    0
+}
+
+fn main() {}
diff --git a/tests/ui/const-generics/issues/issue-90455.rs b/tests/ui/const-generics/issues/issue-90455.rs
index a580410cf37..794c7d76cb1 100644
--- a/tests/ui/const-generics/issues/issue-90455.rs
+++ b/tests/ui/const-generics/issues/issue-90455.rs
@@ -1,5 +1,6 @@
+//@ run-rustfix
 #![feature(generic_const_exprs, adt_const_params)]
-#![allow(incomplete_features)]
+#![allow(incomplete_features, dead_code)]
 
 struct FieldElement<const N: &'static str> {
     n: [u64; num_limbs(N)],
diff --git a/tests/ui/const-generics/issues/issue-90455.stderr b/tests/ui/const-generics/issues/issue-90455.stderr
index 1db90609572..1fcc08db579 100644
--- a/tests/ui/const-generics/issues/issue-90455.stderr
+++ b/tests/ui/const-generics/issues/issue-90455.stderr
@@ -1,10 +1,13 @@
 error: unconstrained generic constant
-  --> $DIR/issue-90455.rs:5:8
+  --> $DIR/issue-90455.rs:6:8
    |
 LL |     n: [u64; num_limbs(N)],
    |        ^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); num_limbs(N)]:`
+help: try adding a `where` bound
+   |
+LL | struct FieldElement<const N: &'static str> where [(); num_limbs(N)]: {
+   |                                            +++++++++++++++++++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/consts/const-needs_drop-monomorphic.stderr b/tests/ui/consts/const-needs_drop-monomorphic.stderr
index 0874a70ce39..446d34810c5 100644
--- a/tests/ui/consts/const-needs_drop-monomorphic.stderr
+++ b/tests/ui/consts/const-needs_drop-monomorphic.stderr
@@ -13,7 +13,10 @@ error: unconstrained generic constant
 LL |     Bool::<{ std::mem::needs_drop::<T>() }>::assert();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); { std::mem::needs_drop::<T>() }]:`
+help: try adding a `where` bound
+   |
+LL | fn f<T>() where [(); { std::mem::needs_drop::<T>() } as usize]: {
+   |           +++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/generic-const-items/evaluatable-bounds.fixed b/tests/ui/generic-const-items/evaluatable-bounds.fixed
new file mode 100644
index 00000000000..de1baffbcdb
--- /dev/null
+++ b/tests/ui/generic-const-items/evaluatable-bounds.fixed
@@ -0,0 +1,25 @@
+// This is a regression test for issue #104400.
+
+//@ run-rustfix
+
+// Test that we can constrain generic const items that appear inside associated consts by
+// adding a (makeshift) "evaluatable"-bound to the item, after applying the suggestion.
+
+#![feature(generic_const_items, generic_const_exprs)]
+#![allow(incomplete_features)]
+
+trait Trait {
+    const LEN: usize;
+
+    const ARRAY: [i32; Self::LEN] where [(); Self::LEN]:; //~ ERROR unconstrained generic constant
+
+}
+
+impl Trait for () {
+    const LEN: usize = 2;
+    const ARRAY: [i32; Self::LEN] = [360, 720];
+}
+
+fn main() {
+    let [_, _] = <() as Trait>::ARRAY;
+}
diff --git a/tests/ui/generic-const-items/evaluatable-bounds.rs b/tests/ui/generic-const-items/evaluatable-bounds.rs
index 1a858f41999..b47801360f9 100644
--- a/tests/ui/generic-const-items/evaluatable-bounds.rs
+++ b/tests/ui/generic-const-items/evaluatable-bounds.rs
@@ -1,10 +1,9 @@
 // This is a regression test for issue #104400.
 
-//@ revisions: unconstrained constrained
-//@[constrained] check-pass
+//@ run-rustfix
 
 // Test that we can constrain generic const items that appear inside associated consts by
-// adding a (makeshift) "evaluatable"-bound to the item.
+// adding a (makeshift) "evaluatable"-bound to the item, after applying the suggestion.
 
 #![feature(generic_const_items, generic_const_exprs)]
 #![allow(incomplete_features)]
@@ -12,13 +11,8 @@
 trait Trait {
     const LEN: usize;
 
-    #[cfg(unconstrained)]
-    const ARRAY: [i32; Self::LEN]; //[unconstrained]~ ERROR unconstrained generic constant
+    const ARRAY: [i32; Self::LEN]; //~ ERROR unconstrained generic constant
 
-    #[cfg(constrained)]
-    const ARRAY: [i32; Self::LEN]
-    where
-        [(); Self::LEN]:;
 }
 
 impl Trait for () {
diff --git a/tests/ui/generic-const-items/evaluatable-bounds.stderr b/tests/ui/generic-const-items/evaluatable-bounds.stderr
new file mode 100644
index 00000000000..ca26d633658
--- /dev/null
+++ b/tests/ui/generic-const-items/evaluatable-bounds.stderr
@@ -0,0 +1,13 @@
+error: unconstrained generic constant
+  --> $DIR/evaluatable-bounds.rs:14:5
+   |
+LL |     const ARRAY: [i32; Self::LEN];
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: try adding a `where` bound
+   |
+LL |     const ARRAY: [i32; Self::LEN] where [(); Self::LEN]:;
+   |                                   ++++++++++++++++++++++
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr b/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr
index 1475d988ea4..b6f9bdce1cb 100644
--- a/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr
+++ b/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL |     const ARRAY: [i32; Self::LEN];
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); Self::LEN]:`
+help: try adding a `where` bound
+   |
+LL |     const ARRAY: [i32; Self::LEN] where [(); Self::LEN]:;
+   |                                   ++++++++++++++++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/simd/array-trait.stderr b/tests/ui/simd/array-trait.stderr
index 16ff732396d..a63dbf37959 100644
--- a/tests/ui/simd/array-trait.stderr
+++ b/tests/ui/simd/array-trait.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL | pub struct T<S: Simd>([S::Lane; S::SIZE]);
    |                       ^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); S::SIZE]:`
+help: try adding a `where` bound
+   |
+LL | pub struct T<S: Simd>([S::Lane; S::SIZE]) where [(); S::SIZE]:;
+   |                                           ++++++++++++++++++++
 
 error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type
   --> $DIR/array-trait.rs:23:1
@@ -20,7 +23,6 @@ LL | #[derive(Copy, Clone)]
 LL | pub struct T<S: Simd>([S::Lane; S::SIZE]);
    |                       ^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); S::SIZE]:`
    = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
diff --git a/tests/ui/specialization/issue-51892.stderr b/tests/ui/specialization/issue-51892.stderr
index 9553a04c8f6..b1cabc0ac0e 100644
--- a/tests/ui/specialization/issue-51892.stderr
+++ b/tests/ui/specialization/issue-51892.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL |     type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()];
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<<T as Trait>::Type>()]:`
+help: try adding a `where` bound
+   |
+LL |     type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()] where [(); std::mem::size_of::<<T as Trait>::Type>()]:;
+   |                                                                 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/variance/variance-associated-consts.stderr b/tests/ui/variance/variance-associated-consts.stderr
index f41574ca3a3..b955a7686c2 100644
--- a/tests/ui/variance/variance-associated-consts.stderr
+++ b/tests/ui/variance/variance-associated-consts.stderr
@@ -4,7 +4,10 @@ error: unconstrained generic constant
 LL |     field: [u8; <T as Trait>::Const]
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: try adding a `where` bound using this expression: `where [(); <T as Trait>::Const]:`
+help: try adding a `where` bound
+   |
+LL | struct Foo<T: Trait> where [(); <T as Trait>::Const]: {
+   |                      ++++++++++++++++++++++++++++++++
 
 error: [o]
   --> $DIR/variance-associated-consts.rs:13:1