diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs index 21f0f9648ea30..3a26b8331f8b3 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs @@ -73,7 +73,7 @@ fn generic_arg_mismatch_err( let param_name = tcx.hir_ty_param_name(param_local_id); let param_type = tcx.type_of(param.def_id).instantiate_identity(); if param_type.is_suggestable(tcx, false) { - err.span_suggestion( + err.span_suggestion_verbose( tcx.def_span(src_def_id), "consider changing this type parameter to a const parameter", format!("const {param_name}: {param_type}"), diff --git a/tests/ui/const-generics/early/invalid-const-arguments.stderr b/tests/ui/const-generics/early/invalid-const-arguments.stderr index 86b4d006454f7..3a9868836ec88 100644 --- a/tests/ui/const-generics/early/invalid-const-arguments.stderr +++ b/tests/ui/const-generics/early/invalid-const-arguments.stderr @@ -51,9 +51,13 @@ error[E0747]: type provided when a constant was expected --> $DIR/invalid-const-arguments.rs:10:19 | LL | impl Foo for B {} - | - ^ - | | - | help: consider changing this type parameter to a const parameter: `const N: u8` + | ^ + | +help: consider changing this type parameter to a const parameter + | +LL - impl Foo for B {} +LL + impl Foo for B {} + | error[E0747]: unresolved item provided when a constant was expected --> $DIR/invalid-const-arguments.rs:14:32 diff --git a/tests/ui/const-generics/kind_mismatch.stderr b/tests/ui/const-generics/kind_mismatch.stderr index 1487b18961986..12a2ab141a636 100644 --- a/tests/ui/const-generics/kind_mismatch.stderr +++ b/tests/ui/const-generics/kind_mismatch.stderr @@ -2,17 +2,25 @@ error[E0747]: type provided when a constant was expected --> $DIR/kind_mismatch.rs:11:38 | LL | impl ContainsKey for KeyHolder {} - | - ^ - | | - | help: consider changing this type parameter to a const parameter: `const K: u8` + | ^ + | +help: consider changing this type parameter to a const parameter + | +LL - impl ContainsKey for KeyHolder {} +LL + impl ContainsKey for KeyHolder {} + | error[E0747]: type provided when a constant was expected --> $DIR/kind_mismatch.rs:11:21 | LL | impl ContainsKey for KeyHolder {} - | - ^ - | | - | help: consider changing this type parameter to a const parameter: `const K: u8` + | ^ + | +help: consider changing this type parameter to a const parameter + | +LL - impl ContainsKey for KeyHolder {} +LL + impl ContainsKey for KeyHolder {} + | error: aborting due to 2 previous errors