Explain how to fix “no field on type” on a TAIT / ATPIT typed value #113581
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
F-impl_trait_in_assoc_type
`#![feature(impl_trait_in_assoc_type)]`
F-type_alias_impl_trait
`#[feature(type_alias_impl_trait)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
If users are not given this advice, it will not be obvious how to proceed; they may think that it is not even possible. For me at least, it is obvious only in hindsight that
check
argument is of a different type than the outgoing return value, andThe alternate mental model I was working with before I understood the problem was something like:
Self::Check
is an alias for a particularimpl Sized
impl
or module knows (being in the defining scope of theimpl Trait
), is an alias forFooC
so
check
should be of typeFooC
already. Now that I understand what's actually going on, it makes much more sense that the compiler would work this way (scope-dependent type equality would be a nightmare), but it wasn't obvious when I started.Other cases
No response
Anything else?
This exact same problem happens with TAIT; I just think it's just a little less clear and more important for associated types in traits.
Another detail to consider is what the output should be when the underlying type does not have such a field (or method). I think there should still be a similar hint, but phrased differently — in general, this hint should show up whenever
@rustbot label +A-impl-trait +F-type_alias_impl_trait
The text was updated successfully, but these errors were encountered: