Diagnostics for mismatched generic types for constructors accessed via Self could show where the mismatch occurs #68476
Labels
A-associated-items
Area: Associated items such as associated types and consts.
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
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.
In this code, I used
Self::VariantName
to construct a new enum. However, sinceSelf
is treated asWrapper<T>
, I get an error when I try to populateSelf::There
/Wrapper<T>::There
with a value of typeU
:(Playground)
Errors:
This threw me for a fair number of minutes, mostly spent saying "no, that function
f
takes aT
and returns aU
, not the other way around".Technically, the compiler is pointing to the entire call of
f
which should have tipped me off to realizing that it's the constructor call that was an issue.Interestingly, the same problem doesn't occur for structs:
The text was updated successfully, but these errors were encountered: