From e4c9a8cf9b2e2a17c589dadcaffae0b9e6b62cbc Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 19 Jun 2024 08:25:58 +0000 Subject: [PATCH] Const generic parameters aren't bounds, even if we end up erroring because of the bound that binds the parameter's type --- .../src/traits/error_reporting/suggestions.rs | 188 ++++++++++-------- .../defaults/doesnt_infer.stderr | 8 +- .../defaults/rp_impl_trait_fail.stderr | 4 +- .../generic_arg_infer/issue-91614.stderr | 4 +- .../issue-62504.full.stderr | 8 +- .../issue-62504.min.stderr | 8 +- .../object-safety-ok-infer-err.stderr | 4 +- .../infer/cannot-infer-const-args.stderr | 4 +- .../const-generics/infer/issue-77092.stderr | 4 +- .../const-generics/infer/method-chain.stderr | 4 +- .../infer/one-param-uninferred.stderr | 4 +- .../infer/uninferred-consts.stderr | 8 +- ...ent_generics_of_encoding_impl_trait.stderr | 4 +- tests/ui/const-generics/type_mismatch.stderr | 4 +- .../unify_with_nested_expr.stderr | 4 +- tests/ui/inference/issue-83606.stderr | 4 +- tests/ui/issues/issue-98299.stderr | 4 +- ...oj-ty-as-type-of-const-issue-125757.stderr | 4 +- .../ui/transmutability/issue-101739-1.stderr | 2 +- 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 f632f1ad4f260..8f8ef4b7acbd8 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::>(); + 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::>(); + 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::>(); - 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::>(); - 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 e099289827e93..c17f57f36bc5f 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::::foo` +note: required by a const generic parameter in `Foo::::foo` --> $DIR/doesnt_infer.rs:5:6 | LL | impl Foo { - | ^^^^^^^^^^^^ required by this bound in `Foo::::foo` + | ^^^^^^^^^^^^ required by this const generic parameter in `Foo::::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; - | ^^^^^^^^^^^^^^^^ 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 = 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 d91e717b3ebe5..45be3126e3b3f 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() -> impl Traitor { - | ^^^^^^^^^^^ required by this bound in `uwu` + | ^^^^^^^^^^^ required by this const generic parameter in `uwu` help: consider specifying the generic argument | LL | uwu::(); 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 b6982e05b8895..217f609459eed 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::::splat` +note: required by a const generic parameter in `Mask::::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 27411646cb72e..3739637c27951 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::::new` +note: required by a const generic parameter in `ArrayHolder::::new` --> $DIR/issue-62504.rs:16:6 | LL | impl ArrayHolder { - | ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder::::new` + | ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder::::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([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 = 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 036b9001c03db..14c67e2528a73 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::::new` +note: required by a const generic parameter in `ArrayHolder::::new` --> $DIR/issue-62504.rs:16:6 | LL | impl ArrayHolder { - | ^^^^^^^^^^^^^^ required by this bound in `ArrayHolder::::new` + | ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder::::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([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 = 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 0c290448fc5a8..d1e1c976da664 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(v: &dyn Foo) 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::(&()); 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 2180ba2f80954..c349a50a83ffb 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() -> usize { - | ^^^^^^^^^^^^^^ required by this bound in `foo` + | ^^^^^^^^^^^^^^ required by this const generic parameter in `foo` help: consider specifying the generic argument | LL | foo::(); diff --git a/tests/ui/const-generics/infer/issue-77092.stderr b/tests/ui/const-generics/infer/issue-77092.stderr index 1579d217c2d47..9a6374a2adcbe 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(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::(&mut arr, i)); diff --git a/tests/ui/const-generics/infer/method-chain.stderr b/tests/ui/const-generics/infer/method-chain.stderr index 08c664e82f7e9..95044bb5203b3 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(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::(); diff --git a/tests/ui/const-generics/infer/one-param-uninferred.stderr b/tests/ui/const-generics/infer/one-param-uninferred.stderr index 68bec93e82626..f3aa7973e67d1 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() -> [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 e8ad336af70cb..839fb25c4e1e6 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(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::(); @@ -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(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::(); 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 cb8f56c6bb089..4809f7d37dd31 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(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 07476ae76c65e..026999827c0e0 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::() | ^ 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() -> [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 87610db67ae4c..b1aecdb3cb5a7 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() - | ^^^^^^^^^^^^^^ required by this bound in `bar` + | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar` help: consider specifying the generic argument | LL | bar::(); diff --git a/tests/ui/inference/issue-83606.stderr b/tests/ui/inference/issue-83606.stderr index 2d74024bb2873..69d1d71ef3cc0 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(_: 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 f4b40cbbd1955..b645267e3b91c 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 {} - | ^^^^^^^^^^^^^^ 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| 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 b4c14c2294e5e..71d4277275fee 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 Wrapper {} | = help: consider constraining the associated type `::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::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 1df7c3e2f9744..6f79bf7b42468 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, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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