Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDiagnostics doesn't provide proper explaination as to where type annotations should be added #48089
Comments
estebank
added
A-typesystem
C-enhancement
A-diagnostics
labels
Feb 9, 2018
This comment has been minimized.
This comment has been minimized.
|
I would go further and say that we should always point to the definition span of the method that we failed to infer a type argument for, and when it is from another crate, present a reasonable signature, as we do for other diagnostics:
In cases where the type argument comes from a |
This comment has been minimized.
This comment has been minimized.
shingtaklam1324
closed this
Feb 10, 2018
shingtaklam1324
reopened this
Feb 11, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
shingtaklam1324 commentedFeb 9, 2018
•
edited
Code
Current Error message
This fails compilation (on purpose), and the error message is as below
Problem
The current error message isn't helpful by producing a message with the type
B, which can be confusing to users, (it comes from te type signature offn sort_by_key<B, F>(&mut self, _: F) where B: Ord, F: FnMut(&T) -> Basestebankpoints out).As well as that, the positions of the arrows implies that the error comes from.sort_by_key(), when in fact it comes from the need for type annotations for.sum().Proposed solution
The proposed change would be to point to the inside of the function, which would (in my opinion) be clearer to the user that the type annotations are needed inside the function, not with
.sort_by_key()Playground