Skip to content
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

#17497 - Invalid RA diagnostic error: expected 2 arguments, found 1 #17504

Closed

Conversation

mckenfra
Copy link

@mckenfra mckenfra commented Jun 27, 2024

Fix for #17497

The issue occurs because in some configurations of traits where one of them has Deref as a supertrait, RA's type inference algorithm fails to fully resolve a trait's self type, and instead uses a TyKind::BoundVar. This then erroneously matches with types that do not implement the trait. In other words, unconnected types appear to inherit the trait's methods.

The fix is to insert an optional heuristic that tells the method-lookup algorithm to continue looking for other possibly better matches, in the case where the initial match is affected by the above situation. It may find a better match, or else will fall back to returning the initial match.

Includes a unit test that only passes after applying the fixes in this commit.

…xpected 2 arguments, found 1

The issue occurs because in some configurations of traits where one of them has Deref
as a supertrait, RA's type inference algorithm fails to fully resolve a trait's
self type, and instead uses a TyKind::BoundVar. This then erroneously matches
with types that do not implement the trait. In other words, unconnected types
appear to inherit the trait's methods.

The fix is to insert an optional heuristic that tells the method-lookup algorithm to
continue looking for other possibly better matches, in the case where the initial match
is affected by the above situation. It may find a better match, or fall back
to returning the initial match.

Includes a unit test that only passes after applying the fixes in this commit.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 27, 2024
@mckenfra mckenfra changed the title Fix for issue #17497 - Invalid RA diagnostic error: expected 2 arguments, found 1 #17497 - Invalid RA diagnostic error: expected 2 arguments, found 1 Jun 27, 2024
@mckenfra mckenfra closed this Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants