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

fix: Resolve private fields in type inference #11540

Merged
merged 2 commits into from Feb 24, 2022
Merged

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Feb 23, 2022

Fixes #10253 (comment)
(the same issue probably exists for method calls, but I think fixing that might be trickier)

Visibility checks were introduced in #7841 for autoderef to work properly, so now we just record the first field we find unconditionally, and then overwrite it if autoderef manages to find another field in a later cycle.

@flodiebold
Copy link
Member

I would do it a bit differently -- by doing field resolution again if the first attempt fails, allowing private fields in the second try. That way the fallback field will also be used for type inference. The same approach can be used for method resolution as well.

But we can do this way for now, because I'm currently refactoring a lot around autoderef, so touching this code more would probably cause conflicts 😅

@Veykril
Copy link
Member Author

Veykril commented Feb 24, 2022

Ye, if you are touching this then we better change that later I agree 😄

bors r=flodiebold

@bors
Copy link
Contributor

bors bot commented Feb 24, 2022

@bors bors bot merged commit 6b55d2f into rust-lang:master Feb 24, 2022
@Veykril Veykril deleted the nameclass branch February 24, 2022 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Private struct members are suggested by IntelliSense in VS Code
2 participants