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:
parent
df8102fe5f
commit
35cb28b7cf
3 changed files with 22 additions and 10 deletions
|
|
@ -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}"),
|
||||
|
|
|
|||
|
|
@ -51,9 +51,13 @@ 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: `const N: u8`
|
||||
| ^
|
||||
|
|
||||
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> {}
|
||||
|
|
||||
|
||||
error[E0747]: unresolved item provided when a constant was expected
|
||||
--> $DIR/invalid-const-arguments.rs:14:32
|
||||
|
|
|
|||
|
|
@ -2,17 +2,25 @@ error[E0747]: type provided when a constant was expected
|
|||
--> $DIR/kind_mismatch.rs:11:38
|
||||
|
|
||||
LL | impl<K> ContainsKey<K> for KeyHolder<K> {}
|
||||
| - ^
|
||||
| |
|
||||
| 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<K> ContainsKey<K> for KeyHolder<K> {}
|
||||
LL + impl<const K: u8> ContainsKey<K> for KeyHolder<K> {}
|
||||
|
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/kind_mismatch.rs:11:21
|
||||
|
|
||||
LL | impl<K> ContainsKey<K> for KeyHolder<K> {}
|
||||
| - ^
|
||||
| |
|
||||
| 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<K> ContainsKey<K> for KeyHolder<K> {}
|
||||
LL + impl<const K: u8> ContainsKey<K> for KeyHolder<K> {}
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue