-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Compiler error could suggest using an associated type for e.g. Iterator<T> #20977
Comments
cc @Manishearth this could be a good place for a custom error attribute like the one you recently implemented |
Ooh, this looks doable. Unfortunately I don't see any opportunity for sharing much code here, but I can try to move some of the code out. |
Visiting for triage: nothing has changed here |
Current situation: the original error hasn't changed, but we get a second one that complains about the missing
... which should clear it up. (But probably not if the associated type has a default?) |
Care should be taken when some type arguments and associated items are expected. In those case, it's probably better to keep the current output to avoid confusion with the tradeoff of verbosity. |
Suggest correct syntax when writing type arg instead of assoc type - When confusing an associated type with a type argument, suggest the appropriate syntax. Given `Iterator<isize>`, suggest `Iterator<Item = isize>`. - When encountering multiple missing associated types, emit only one diagnostic. - Point at associated type def span for context. - Point at each extra type argument. Follow up to #48288, fix #20977.
If you accidentally write a bound like:
The error message is:
The compiler could be more helpful in these cases where a trait takes 0 arguments but has an associated type and suggest something like:
Iterator has an associated type. Did you mean: I: Iterator<Item=T>?
.The text was updated successfully, but these errors were encountered: