-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Erase type params when suggesting fully qualified path #96347
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
Conversation
r? @cjgillot (rust-highfive has picked a reviewer for you, use r? to override) |
When suggesting the use of a fully qualified path for a method call that is ambiguous because it has multiple candidates, erase type params in the resulting code, as they would result in an error when applied. We replace them with `_` in the output to rely on inference. There might be cases where this still produces slighlty incomplete suggestions, but it otherwise produces many more errors in relatively common cases. Fix rust-lang#96292
This comment has been minimized.
This comment has been minimized.
{ | ||
let mut eraser = TypeParamEraser(self.tcx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is overkill, but we could know exactly what generic types need to be erased if we returned the impl's DefId
from find_similar_impl_candidates
instead of just the TraitRef
, then we might just be able to use subst instead of erasing all type params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 maybe, but that'd end up being a relatively larger change, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, but it might allow us to erase fewer type variables when we're calling one generic method from another generic method with type variables.
but probably not worth the effort...
For now this is fine! @bors r+ |
📌 Commit a721383 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (7c4b476): comparison url. Summary:
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
When suggesting the use of a fully qualified path for a method call that
is ambiguous because it has multiple candidates, erase type params in
the resulting code, as they would result in an error when applied. We
replace them with
_
in the output to rely on inference. There might becases where this still produces slighlty incomplete suggestions, but it
otherwise produces many more errors in relatively common cases.
Fix #96292