about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-19 08:25:58 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-19 14:58:29 +0000
commite4c9a8cf9b2e2a17c589dadcaffae0b9e6b62cbc (patch)
treef8ca00ac21fad58ca146ade0801f2e42596b6baa
parent1cb75dc4a92ef131b2b88bd9faeaa1d39c3d5f4e (diff)
downloadrust-e4c9a8cf9b2e2a17c589dadcaffae0b9e6b62cbc.tar.gz
rust-e4c9a8cf9b2e2a17c589dadcaffae0b9e6b62cbc.zip
Const generic parameters aren't bounds, even if we end up erroring because of the bound that binds the parameter's type
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs188
-rw-r--r--tests/ui/const-generics/defaults/doesnt_infer.stderr8
-rw-r--r--tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr4
-rw-r--r--tests/ui/const-generics/generic_arg_infer/issue-91614.stderr4
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr8
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr8
-rw-r--r--tests/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr4
-rw-r--r--tests/ui/const-generics/infer/cannot-infer-const-args.stderr4
-rw-r--r--tests/ui/const-generics/infer/issue-77092.stderr4
-rw-r--r--tests/ui/const-generics/infer/method-chain.stderr4
-rw-r--r--tests/ui/const-generics/infer/one-param-uninferred.stderr4
-rw-r--r--tests/ui/const-generics/infer/uninferred-consts.stderr8
-rw-r--r--tests/ui/const-generics/parent_generics_of_encoding_impl_trait.stderr4
-rw-r--r--tests/ui/const-generics/type_mismatch.stderr4
-rw-r--r--tests/ui/const-generics/unify_with_nested_expr.stderr4
-rw-r--r--tests/ui/inference/issue-83606.stderr4
-rw-r--r--tests/ui/issues/issue-98299.stderr4
-rw-r--r--tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr4
-rw-r--r--tests/ui/transmutability/issue-101739-1.stderr2
19 files changed, 146 insertions, 128 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index f632f1ad4f2..8f8ef4b7acb 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -2776,97 +2776,115 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
                 let mut this = "this bound";
                 let mut note = None;
                 let mut help = None;
-                if let ty::PredicateKind::Clause(clause) = predicate.kind().skip_binder()
-                    && let ty::ClauseKind::Trait(trait_pred) = clause
-                {
-                    let def_id = trait_pred.def_id();
-                    let visible_item = if let Some(local) = def_id.as_local() {
-                        // Check for local traits being reachable.
-                        let vis = &tcx.resolutions(()).effective_visibilities;
-                        // Account for non-`pub` traits in the root of the local crate.
-                        let is_locally_reachable = tcx.parent(def_id).is_crate_root();
-                        vis.is_reachable(local) || is_locally_reachable
-                    } else {
-                        // Check for foreign traits being reachable.
-                        tcx.visible_parent_map(()).get(&def_id).is_some()
-                    };
-                    if tcx.is_lang_item(def_id, LangItem::Sized) {
-                        // Check if this is an implicit bound, even in foreign crates.
-                        if tcx
-                            .generics_of(item_def_id)
-                            .own_params
-                            .iter()
-                            .any(|param| tcx.def_span(param.def_id) == span)
-                        {
-                            a = "an implicit `Sized`";
-                            this = "the implicit `Sized` requirement on this type parameter";
-                        }
-                        if let Some(hir::Node::TraitItem(hir::TraitItem {
-                            generics,
-                            kind: hir::TraitItemKind::Type(bounds, None),
-                            ..
-                        })) = tcx.hir().get_if_local(item_def_id)
-                        // Do not suggest relaxing if there is an explicit `Sized` obligation.
-                        && !bounds.iter()
-                            .filter_map(|bound| bound.trait_ref())
-                            .any(|tr| tr.trait_def_id() == tcx.lang_items().sized_trait())
-                        {
-                            let (span, separator) = if let [.., last] = bounds {
-                                (last.span().shrink_to_hi(), " +")
+                if let ty::PredicateKind::Clause(clause) = predicate.kind().skip_binder() {
+                    match clause {
+                        ty::ClauseKind::Trait(trait_pred) => {
+                            let def_id = trait_pred.def_id();
+                            let visible_item = if let Some(local) = def_id.as_local() {
+                                // Check for local traits being reachable.
+                                let vis = &tcx.resolutions(()).effective_visibilities;
+                                // Account for non-`pub` traits in the root of the local crate.
+                                let is_locally_reachable = tcx.parent(def_id).is_crate_root();
+                                vis.is_reachable(local) || is_locally_reachable
                             } else {
-                                (generics.span.shrink_to_hi(), ":")
+                                // Check for foreign traits being reachable.
+                                tcx.visible_parent_map(()).get(&def_id).is_some()
                             };
-                            err.span_suggestion_verbose(
-                                span,
-                                "consider relaxing the implicit `Sized` restriction",
-                                format!("{separator} ?Sized"),
-                                Applicability::MachineApplicable,
-                            );
+                            if tcx.is_lang_item(def_id, LangItem::Sized) {
+                                // Check if this is an implicit bound, even in foreign crates.
+                                if tcx
+                                    .generics_of(item_def_id)
+                                    .own_params
+                                    .iter()
+                                    .any(|param| tcx.def_span(param.def_id) == span)
+                                {
+                                    a = "an implicit `Sized`";
+                                    this =
+                                        "the implicit `Sized` requirement on this type parameter";
+                                }
+                                if let Some(hir::Node::TraitItem(hir::TraitItem {
+                                    generics,
+                                    kind: hir::TraitItemKind::Type(bounds, None),
+                                    ..
+                                })) = tcx.hir().get_if_local(item_def_id)
+                                    // Do not suggest relaxing if there is an explicit `Sized` obligation.
+                                    && !bounds.iter()
+                                        .filter_map(|bound| bound.trait_ref())
+                                        .any(|tr| tr.trait_def_id() == tcx.lang_items().sized_trait())
+                                {
+                                    let (span, separator) = if let [.., last] = bounds {
+                                        (last.span().shrink_to_hi(), " +")
+                                    } else {
+                                        (generics.span.shrink_to_hi(), ":")
+                                    };
+                                    err.span_suggestion_verbose(
+                                        span,
+                                        "consider relaxing the implicit `Sized` restriction",
+                                        format!("{separator} ?Sized"),
+                                        Applicability::MachineApplicable,
+                                    );
+                                }
+                            }
+                            if let DefKind::Trait = tcx.def_kind(item_def_id)
+                                && !visible_item
+                            {
+                                note = Some(format!(
+                                    "`{short_item_name}` is a \"sealed trait\", because to implement it \
+                                    you also need to implement `{}`, which is not accessible; this is \
+                                    usually done to force you to use one of the provided types that \
+                                    already implement it",
+                                    with_no_trimmed_paths!(tcx.def_path_str(def_id)),
+                                ));
+                                let impls_of = tcx.trait_impls_of(def_id);
+                                let impls = impls_of
+                                    .non_blanket_impls()
+                                    .values()
+                                    .flatten()
+                                    .chain(impls_of.blanket_impls().iter())
+                                    .collect::<Vec<_>>();
+                                if !impls.is_empty() {
+                                    let len = impls.len();
+                                    let mut types = impls
+                                        .iter()
+                                        .map(|t| {
+                                            with_no_trimmed_paths!(format!(
+                                                "  {}",
+                                                tcx.type_of(*t).instantiate_identity(),
+                                            ))
+                                        })
+                                        .collect::<Vec<_>>();
+                                    let post = if types.len() > 9 {
+                                        types.truncate(8);
+                                        format!("\nand {} others", len - 8)
+                                    } else {
+                                        String::new()
+                                    };
+                                    help = Some(format!(
+                                        "the following type{} implement{} the trait:\n{}{post}",
+                                        pluralize!(len),
+                                        if len == 1 { "s" } else { "" },
+                                        types.join("\n"),
+                                    ));
+                                }
+                            }
                         }
-                    }
-                    if let DefKind::Trait = tcx.def_kind(item_def_id)
-                        && !visible_item
-                    {
-                        note = Some(format!(
-                            "`{short_item_name}` is a \"sealed trait\", because to implement it \
-                             you also need to implement `{}`, which is not accessible; this is \
-                             usually done to force you to use one of the provided types that \
-                             already implement it",
-                            with_no_trimmed_paths!(tcx.def_path_str(def_id)),
-                        ));
-                        let impls_of = tcx.trait_impls_of(def_id);
-                        let impls = impls_of
-                            .non_blanket_impls()
-                            .values()
-                            .flatten()
-                            .chain(impls_of.blanket_impls().iter())
-                            .collect::<Vec<_>>();
-                        if !impls.is_empty() {
-                            let len = impls.len();
-                            let mut types = impls
-                                .iter()
-                                .map(|t| {
-                                    with_no_trimmed_paths!(format!(
-                                        "  {}",
-                                        tcx.type_of(*t).instantiate_identity(),
-                                    ))
-                                })
-                                .collect::<Vec<_>>();
-                            let post = if types.len() > 9 {
-                                types.truncate(8);
-                                format!("\nand {} others", len - 8)
+                        ty::ClauseKind::ConstArgHasType(..) => {
+                            let descr =
+                                format!("required by a const generic parameter in `{item_name}`");
+                            if span.is_visible(sm) {
+                                let msg = format!(
+                                    "required by this const generic parameter in `{short_item_name}`"
+                                );
+                                multispan.push_span_label(span, msg);
+                                err.span_note(multispan, descr);
                             } else {
-                                String::new()
-                            };
-                            help = Some(format!(
-                                "the following type{} implement{} the trait:\n{}{post}",
-                                pluralize!(len),
-                                if len == 1 { "s" } else { "" },
-                                types.join("\n"),
-                            ));
+                                err.span_note(tcx.def_span(item_def_id), descr);
+                            }
+                            return;
                         }
+                        _ => (),
                     }
-                };
+                }
                 let descr = format!("required by {a} bound in `{item_name}`");
                 if span.is_visible(sm) {
                     let msg = format!("required by {this} in `{short_item_name}`");
diff --git a/tests/ui/const-generics/defaults/doesnt_infer.stderr b/tests/ui/const-generics/defaults/doesnt_infer.stderr
index e099289827e..c17f57f36bc 100644
--- a/tests/ui/const-generics/defaults/doesnt_infer.stderr
+++ b/tests/ui/const-generics/defaults/doesnt_infer.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed for `Foo<_>`
 LL |     let foo = Foo::foo();
    |         ^^^   ---------- type must be known at this point
    |
-note: required by a bound in `Foo::<N>::foo`
+note: required by a const generic parameter in `Foo::<N>::foo`
   --> $DIR/doesnt_infer.rs:5:6
    |
 LL | impl<const N: u32> Foo<N> {
-   |      ^^^^^^^^^^^^ required by this bound in `Foo::<N>::foo`
+   |      ^^^^^^^^^^^^ required by this const generic parameter in `Foo::<N>::foo`
 LL |     fn foo() -> Self {
    |        --- required by a bound in this associated function
 help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified
@@ -22,11 +22,11 @@ error[E0284]: type annotations needed for `Foo<_>`
 LL |     let foo = Foo::foo();
    |         ^^^   --- type must be known at this point
    |
-note: required by a bound in `Foo`
+note: required by a const generic parameter in `Foo`
   --> $DIR/doesnt_infer.rs:3:12
    |
 LL | struct Foo<const N: u32 = 2>;
-   |            ^^^^^^^^^^^^^^^^ required by this bound in `Foo`
+   |            ^^^^^^^^^^^^^^^^ required by this const generic parameter in `Foo`
 help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified
    |
 LL |     let foo: Foo<N> = Foo::foo();
diff --git a/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr
index d91e717b3eb..45be3126e3b 100644
--- a/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr
+++ b/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr
@@ -37,11 +37,11 @@ error[E0284]: type annotations needed
 LL |     uwu();
    |     ^^^ cannot infer the value of the const parameter `N` declared on the function `uwu`
    |
-note: required by a bound in `uwu`
+note: required by a const generic parameter in `uwu`
   --> $DIR/rp_impl_trait_fail.rs:16:8
    |
 LL | fn uwu<const N: u8>() -> impl Traitor<N> {
-   |        ^^^^^^^^^^^ required by this bound in `uwu`
+   |        ^^^^^^^^^^^ required by this const generic parameter in `uwu`
 help: consider specifying the generic argument
    |
 LL |     uwu::<N>();
diff --git a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr
index b6982e05b88..217f609459e 100644
--- a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr
+++ b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr
@@ -4,7 +4,7 @@ error[E0284]: type annotations needed for `Mask<_, _>`
 LL |     let y = Mask::<_, _>::splat(false);
    |         ^   -------------------------- type must be known at this point
    |
-note: required by a bound in `Mask::<T, N>::splat`
+note: required by a const generic parameter in `Mask::<T, N>::splat`
   --> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
 help: consider giving `y` an explicit type, where the value of const parameter `N` is specified
    |
@@ -17,7 +17,7 @@ error[E0284]: type annotations needed for `Mask<_, _>`
 LL |     let y = Mask::<_, _>::splat(false);
    |         ^   ------------ type must be known at this point
    |
-note: required by a bound in `Mask`
+note: required by a const generic parameter in `Mask`
   --> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
 help: consider giving `y` an explicit type, where the value of const parameter `N` is specified
    |
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 27411646cb7..3739637c279 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
@@ -24,11 +24,11 @@ error[E0284]: type annotations needed for `ArrayHolder<_>`
 LL |     let mut array = ArrayHolder::new();
    |         ^^^^^^^^^   ------------------ type must be known at this point
    |
-note: required by a bound in `ArrayHolder::<X>::new`
+note: required by a const generic parameter in `ArrayHolder::<X>::new`
   --> $DIR/issue-62504.rs:16:6
    |
 LL | impl<const X: usize> ArrayHolder<X> {
-   |      ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder::<X>::new`
+   |      ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder::<X>::new`
 LL |     pub const fn new() -> Self {
    |                  --- required by a bound in this associated function
 help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
@@ -42,11 +42,11 @@ error[E0284]: type annotations needed for `ArrayHolder<_>`
 LL |     let mut array = ArrayHolder::new();
    |         ^^^^^^^^^   ----------- type must be known at this point
    |
-note: required by a bound in `ArrayHolder`
+note: required by a const generic parameter in `ArrayHolder`
   --> $DIR/issue-62504.rs:14:20
    |
 LL | struct ArrayHolder<const X: usize>([u32; X]);
-   |                    ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder`
+   |                    ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder`
 help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
    |
 LL |     let mut array: ArrayHolder<X> = ArrayHolder::new();
diff --git a/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr b/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr
index 036b9001c03..14c67e2528a 100644
--- a/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr
@@ -28,11 +28,11 @@ error[E0284]: type annotations needed for `ArrayHolder<_>`
 LL |     let mut array = ArrayHolder::new();
    |         ^^^^^^^^^   ------------------ type must be known at this point
    |
-note: required by a bound in `ArrayHolder::<X>::new`
+note: required by a const generic parameter in `ArrayHolder::<X>::new`
   --> $DIR/issue-62504.rs:16:6
    |
 LL | impl<const X: usize> ArrayHolder<X> {
-   |      ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder::<X>::new`
+   |      ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder::<X>::new`
 LL |     pub const fn new() -> Self {
    |                  --- required by a bound in this associated function
 help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
@@ -46,11 +46,11 @@ error[E0284]: type annotations needed for `ArrayHolder<_>`
 LL |     let mut array = ArrayHolder::new();
    |         ^^^^^^^^^   ----------- type must be known at this point
    |
-note: required by a bound in `ArrayHolder`
+note: required by a const generic parameter in `ArrayHolder`
   --> $DIR/issue-62504.rs:14:20
    |
 LL | struct ArrayHolder<const X: usize>([u32; X]);
-   |                    ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder`
+   |                    ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder`
 help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
    |
 LL |     let mut array: ArrayHolder<X> = ArrayHolder::new();
diff --git a/tests/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr b/tests/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr
index 0c290448fc5..d1e1c976da6 100644
--- a/tests/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed
 LL |     use_dyn(&());
    |     ^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `use_dyn`
    |
-note: required by a bound in `use_dyn`
+note: required by a const generic parameter in `use_dyn`
   --> $DIR/object-safety-ok-infer-err.rs:14:12
    |
 LL | fn use_dyn<const N: usize>(v: &dyn Foo<N>) where [u8; N + 1]: Sized {
-   |            ^^^^^^^^^^^^^^ required by this bound in `use_dyn`
+   |            ^^^^^^^^^^^^^^ required by this const generic parameter in `use_dyn`
 help: consider specifying the generic argument
    |
 LL |     use_dyn::<N>(&());
diff --git a/tests/ui/const-generics/infer/cannot-infer-const-args.stderr b/tests/ui/const-generics/infer/cannot-infer-const-args.stderr
index 2180ba2f809..c349a50a83f 100644
--- a/tests/ui/const-generics/infer/cannot-infer-const-args.stderr
+++ b/tests/ui/const-generics/infer/cannot-infer-const-args.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed
 LL |     foo();
    |     ^^^ cannot infer the value of the const parameter `X` declared on the function `foo`
    |
-note: required by a bound in `foo`
+note: required by a const generic parameter in `foo`
   --> $DIR/cannot-infer-const-args.rs:1:8
    |
 LL | fn foo<const X: usize>() -> usize {
-   |        ^^^^^^^^^^^^^^ required by this bound in `foo`
+   |        ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
 help: consider specifying the generic argument
    |
 LL |     foo::<X>();
diff --git a/tests/ui/const-generics/infer/issue-77092.stderr b/tests/ui/const-generics/infer/issue-77092.stderr
index 1579d217c2d..9a6374a2adc 100644
--- a/tests/ui/const-generics/infer/issue-77092.stderr
+++ b/tests/ui/const-generics/infer/issue-77092.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed
 LL |         println!("{:?}", take_array_from_mut(&mut arr, i));
    |                          ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `take_array_from_mut`
    |
-note: required by a bound in `take_array_from_mut`
+note: required by a const generic parameter in `take_array_from_mut`
   --> $DIR/issue-77092.rs:3:27
    |
 LL | fn take_array_from_mut<T, const N: usize>(data: &mut [T], start: usize) -> &mut [T; N] {
-   |                           ^^^^^^^^^^^^^^ required by this bound in `take_array_from_mut`
+   |                           ^^^^^^^^^^^^^^ required by this const generic parameter in `take_array_from_mut`
 help: consider specifying the generic arguments
    |
 LL |         println!("{:?}", take_array_from_mut::<i32, N>(&mut arr, i));
diff --git a/tests/ui/const-generics/infer/method-chain.stderr b/tests/ui/const-generics/infer/method-chain.stderr
index 08c664e82f7..95044bb5203 100644
--- a/tests/ui/const-generics/infer/method-chain.stderr
+++ b/tests/ui/const-generics/infer/method-chain.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed
 LL |     Foo.bar().bar().bar().bar().baz();
    |                                 ^^^ cannot infer the value of the const parameter `N` declared on the method `baz`
    |
-note: required by a bound in `Foo::baz`
+note: required by a const generic parameter in `Foo::baz`
   --> $DIR/method-chain.rs:8:12
    |
 LL |     fn baz<const N: usize>(self) -> Foo {
-   |            ^^^^^^^^^^^^^^ required by this bound in `Foo::baz`
+   |            ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo::baz`
 help: consider specifying the generic argument
    |
 LL |     Foo.bar().bar().bar().bar().baz::<N>();
diff --git a/tests/ui/const-generics/infer/one-param-uninferred.stderr b/tests/ui/const-generics/infer/one-param-uninferred.stderr
index 68bec93e826..f3aa7973e67 100644
--- a/tests/ui/const-generics/infer/one-param-uninferred.stderr
+++ b/tests/ui/const-generics/infer/one-param-uninferred.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed
 LL |     let _: [u8; 17] = foo();
    |                       ^^^ cannot infer the value of the const parameter `M` declared on the function `foo`
    |
-note: required by a bound in `foo`
+note: required by a const generic parameter in `foo`
   --> $DIR/one-param-uninferred.rs:2:24
    |
 LL | fn foo<const N: usize, const M: usize>() -> [u8; N] {
-   |                        ^^^^^^^^^^^^^^ required by this bound in `foo`
+   |                        ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
 help: consider specifying the generic arguments
    |
 LL |     let _: [u8; 17] = foo::<17, M>();
diff --git a/tests/ui/const-generics/infer/uninferred-consts.stderr b/tests/ui/const-generics/infer/uninferred-consts.stderr
index e8ad336af70..839fb25c4e1 100644
--- a/tests/ui/const-generics/infer/uninferred-consts.stderr
+++ b/tests/ui/const-generics/infer/uninferred-consts.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed
 LL |     Foo.foo();
    |         ^^^ cannot infer the value of the const parameter `A` declared on the method `foo`
    |
-note: required by a bound in `Foo::foo`
+note: required by a const generic parameter in `Foo::foo`
   --> $DIR/uninferred-consts.rs:6:12
    |
 LL |     fn foo<const A: usize, const B: usize>(self) {}
-   |            ^^^^^^^^^^^^^^ required by this bound in `Foo::foo`
+   |            ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo::foo`
 help: consider specifying the generic arguments
    |
 LL |     Foo.foo::<A, B>();
@@ -20,11 +20,11 @@ error[E0284]: type annotations needed
 LL |     Foo.foo();
    |         ^^^ cannot infer the value of the const parameter `B` declared on the method `foo`
    |
-note: required by a bound in `Foo::foo`
+note: required by a const generic parameter in `Foo::foo`
   --> $DIR/uninferred-consts.rs:6:28
    |
 LL |     fn foo<const A: usize, const B: usize>(self) {}
-   |                            ^^^^^^^^^^^^^^ required by this bound in `Foo::foo`
+   |                            ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo::foo`
 help: consider specifying the generic arguments
    |
 LL |     Foo.foo::<A, B>();
diff --git a/tests/ui/const-generics/parent_generics_of_encoding_impl_trait.stderr b/tests/ui/const-generics/parent_generics_of_encoding_impl_trait.stderr
index cb8f56c6bb0..4809f7d37dd 100644
--- a/tests/ui/const-generics/parent_generics_of_encoding_impl_trait.stderr
+++ b/tests/ui/const-generics/parent_generics_of_encoding_impl_trait.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed
 LL |     generics_of_parent_impl_trait::foo([()]);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `foo`
    |
-note: required by a bound in `foo`
+note: required by a const generic parameter in `foo`
   --> $DIR/auxiliary/generics_of_parent_impl_trait.rs:5:12
    |
 LL | pub fn foo<const N: usize>(foo: impl Into<[(); N + 1]>) {
-   |            ^^^^^^^^^^^^^^ required by this bound in `foo`
+   |            ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/const-generics/type_mismatch.stderr b/tests/ui/const-generics/type_mismatch.stderr
index 07476ae76c6..026999827c0 100644
--- a/tests/ui/const-generics/type_mismatch.stderr
+++ b/tests/ui/const-generics/type_mismatch.stderr
@@ -4,11 +4,11 @@ error: the constant `N` is not of type `u8`
 LL |     bar::<N>()
    |           ^ expected `u8`, found `usize`
    |
-note: required by a bound in `bar`
+note: required by a const generic parameter in `bar`
   --> $DIR/type_mismatch.rs:6:8
    |
 LL | fn bar<const N: u8>() -> [u8; N] {}
-   |        ^^^^^^^^^^^ required by this bound in `bar`
+   |        ^^^^^^^^^^^ required by this const generic parameter in `bar`
 
 error[E0308]: mismatched types
   --> $DIR/type_mismatch.rs:6:26
diff --git a/tests/ui/const-generics/unify_with_nested_expr.stderr b/tests/ui/const-generics/unify_with_nested_expr.stderr
index 87610db67ae..b1aecdb3cb5 100644
--- a/tests/ui/const-generics/unify_with_nested_expr.stderr
+++ b/tests/ui/const-generics/unify_with_nested_expr.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed
 LL |     bar();
    |     ^^^ cannot infer the value of the const parameter `N` declared on the function `bar`
    |
-note: required by a bound in `bar`
+note: required by a const generic parameter in `bar`
   --> $DIR/unify_with_nested_expr.rs:12:8
    |
 LL | fn bar<const N: usize>()
-   |        ^^^^^^^^^^^^^^ required by this bound in `bar`
+   |        ^^^^^^^^^^^^^^ required by this const generic parameter in `bar`
 help: consider specifying the generic argument
    |
 LL |     bar::<N>();
diff --git a/tests/ui/inference/issue-83606.stderr b/tests/ui/inference/issue-83606.stderr
index 2d74024bb28..69d1d71ef3c 100644
--- a/tests/ui/inference/issue-83606.stderr
+++ b/tests/ui/inference/issue-83606.stderr
@@ -4,11 +4,11 @@ error[E0284]: type annotations needed for `[usize; _]`
 LL |     let _ = foo("foo");
    |         ^   ---------- type must be known at this point
    |
-note: required by a bound in `foo`
+note: required by a const generic parameter in `foo`
   --> $DIR/issue-83606.rs:3:8
    |
 LL | fn foo<const N: usize>(_: impl std::fmt::Display) -> [usize; N] {
-   |        ^^^^^^^^^^^^^^ required by this bound in `foo`
+   |        ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
 help: consider giving this pattern a type, where the value of const parameter `N` is specified
    |
 LL |     let _: [usize; N] = foo("foo");
diff --git a/tests/ui/issues/issue-98299.stderr b/tests/ui/issues/issue-98299.stderr
index f4b40cbbd19..b645267e3b9 100644
--- a/tests/ui/issues/issue-98299.stderr
+++ b/tests/ui/issues/issue-98299.stderr
@@ -6,11 +6,11 @@ LL |     SmallCString::try_from(p).map(|cstr| cstr);
    |     |
    |     type must be known at this point
    |
-note: required by a bound in `SmallCString`
+note: required by a const generic parameter in `SmallCString`
   --> $DIR/issue-98299.rs:10:25
    |
 LL | pub struct SmallCString<const N: usize> {}
-   |                         ^^^^^^^^^^^^^^ required by this bound in `SmallCString`
+   |                         ^^^^^^^^^^^^^^ required by this const generic parameter in `SmallCString`
 help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified
    |
 LL |     SmallCString::try_from(p).map(|cstr: SmallCString<N>| cstr);
diff --git a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr
index b4c14c2294e..71d4277275f 100644
--- a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr
+++ b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr
@@ -14,11 +14,11 @@ LL | impl<const C: usize> Wrapper<C> {}
    |
    = help: consider constraining the associated type `<i32 as Trait>::Type` to `usize`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
-note: required by a bound in `Wrapper`
+note: required by a const generic parameter in `Wrapper`
   --> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:12:16
    |
 LL | struct Wrapper<const C: <i32 as Trait>::Type> {}
-   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper`
+   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `Wrapper`
 
 error[E0308]: mismatched types
   --> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:15:30
diff --git a/tests/ui/transmutability/issue-101739-1.stderr b/tests/ui/transmutability/issue-101739-1.stderr
index 1df7c3e2f97..6f79bf7b424 100644
--- a/tests/ui/transmutability/issue-101739-1.stderr
+++ b/tests/ui/transmutability/issue-101739-1.stderr
@@ -10,7 +10,7 @@ error: the constant `ASSUME_ALIGNMENT` is not of type `Assume`
 LL |         Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>,
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
    |
-note: required by a bound in `BikeshedIntrinsicFrom`
+note: required by a const generic parameter in `BikeshedIntrinsicFrom`
   --> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
 
 error[E0308]: mismatched types