Suggest using let
when a const uses outer function's generics
#79955
Labels
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-papercut
Diagnostics: An error or lint that needs small tweaks.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
If you use:
const size = std::mem::size_of::<T>()
instead oflet size = ...
You get the misleading compiler error E401:
error[E0401]: can't use generic parameters from outer function
Which is total nonsense. You just need let instead of const here. This fooled me for a while, so I'm opening this issue so it will get addressed and not fool other developers.
For more info see: https://stackoverflow.com/questions/59808575/cant-create-a-constant-using-memsize-of-inside-a-function-on-a-sized-generic
The text was updated successfully, but these errors were encountered: