-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error 282: If we have no info about the actual type param, say something about the formal type param #36554
Comments
Yeah, this stinks. Should be fairly easy to fix though. I am happy to mentor someone. I think the basic way to fix it as follows. Step 1. Adjust the type inference variables to (optionally) carry information about what type parameter they correspond to (not all type inference variables come from a parameter) and the span where they are created.
OK, now that we have the info we need, we need to incorporate it into the print-out. I have to run and do something else, so i'll leave a follow-up comment with step 2. |
Step 2. Augment the "unable to infer enough type information about
Note that we only have the name of the variable available, not the name of the method or fn where the variable was declared. As I said, we can refactor to support that later -- it's a relatively small delta on this other plumbing. |
I am new to Rust but wanting to learn more and help make it better. I'd like to give a second shot at helping out. |
@Coder206 sorry, but I didn't mention that I've already been working on this. |
@KiChjang That's fine. Sorry for intruding on your issue. So you are doing this too: #36554 (comment) ? |
@nikomatsakis I'm planning to go the enum route and give pub enum TypeVariableOrigin {
TypeParameterDefinition(Span, ast::Name),
TransformedUpvar(Span, ast::Name),
AdjustNeverToAny(Span, ast::Name),
DivergingStatement(Span, ast::Name),
DivergingBlockExpression(Span, ast::Name),
} |
@KiChjang yes, in general |
Pinging @KiChjang - get any further with this? |
@jonathandturner I'm still trying to supply a TypeVariableOrigin to all callers of |
…akis Display better error messages for E0282 Fixes #36554.
e.g.,
and inline:
This is when calling a function with a generic type parameter. The actual type parameter is inferred, so we can't name it, but there is a corresponding formal parameter we could name.
E.g., if calling
foo<T>(...)
we havefoo(...)
and so get a type error for_
, but we could mentionT
here, something likeThe text was updated successfully, but these errors were encountered: