Verbose suggestion to make param const

```
error[E0747]: type provided when a constant was expected
  --> $DIR/invalid-const-arguments.rs:10:19
   |
LL | impl<N> Foo for B<N> {}
   |                   ^
   |
help: consider changing this type parameter to a const parameter
   |
LL - impl<N> Foo for B<N> {}
LL + impl<const N: u8> Foo for B<N> {}
   |
```
This commit is contained in:
Esteban Küber 2025-06-04 21:23:11 +00:00
parent df8102fe5f
commit 35cb28b7cf
3 changed files with 22 additions and 10 deletions

View file

@ -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}"),