Diagnostics hint for const generics #80506
Labels
A-const-generics
Area: const generics (parameters and arguments)
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Current Behavior
Given the following code:
where
Iterator::combinations
is defined as:The following diagnostic is provided:
Attempting a fix, and failing:
Naively I thought I could fix this by adding a turbofish, but that doesn't seem to help:
Expected behavior
Providing a hint on how to correctly define const generics would be immensely helpful. I'm sure I'll be able to figure out the syntax for this eventually (currently going through #78460 among others), but given we're set for a 1.51 stabilization of
min_const_generics
I suspect more people will be running into this soon.Further Considerations
I was looking at how hints work for e.g. missing type params in
collect
, and noticed no hints are provided there either. It only explains what to do, not showing how to do it. For something that's notoriously tricky to learn that seems like it could benefit from hints as well.The text was updated successfully, but these errors were encountered: