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

private visibility is shown in autocompletion #15134

Closed
asyncci opened this issue Jun 25, 2023 · 6 comments · Fixed by #15486
Closed

private visibility is shown in autocompletion #15134

asyncci opened this issue Jun 25, 2023 · 6 comments · Fixed by #15486
Assignees
Labels
A-completion autocompletion C-bug Category: bug

Comments

@asyncci
Copy link

asyncci commented Jun 25, 2023

I have pub(self) fn function() {} in module named becoding , and autocomplete in outer files shows that function .
image
but the error is ok
image

But when it comes to pub(in crate::becoding)fn function(){} , autocomplete hides that function .
image
image

@asyncci asyncci added the C-bug Category: bug label Jun 25, 2023
@Veykril Veykril added the A-completion autocompletion label Jun 27, 2023
petr-tik added a commit to petr-tik/rust-analyzer that referenced this issue Jul 24, 2023
I might be missing something in the crate/module setup
that isn't being propagated
@petr-tik
Copy link
Contributor

@asyncci Can you please help me reproduce your failure.

I recreated a test case from your screenshots here

master...petr-tik:rust-analyzer:n15134_hide_private_from_autocomplete

but I am not seeing i_should_be_hidden, which is equivalent to your bencoding::function.

What is the name of the file where function and function2 are defined? Are they nested in a module?

@petr-tik
Copy link
Contributor

@rustbot claim

@asyncci
Copy link
Author

asyncci commented Jul 27, 2023

Hello again ! Sorry for late response . Here is it https://github.com/asyncci/physarum . I've checked again, same as on screenshots

petr-tik added a commit to petr-tik/rust-analyzer that referenced this issue Aug 20, 2023
Before
Private functions have RawVisibility module, but were
missed because take_types returned None early. After resolve_visibility
returned None, Visibility::Public was set instead and private functions
ended up being offered in autocompletion.

Choosing such a function results in an immediate error diagnostic
about using a private function.

After
Pattern match of take_types that returns None and
query for Module-level visibility from the original_module

Fix rust-lang#15134 - tested with a unit test and a manual end-to-end
test of building rust-analyzer from my branch and opening
the reproduction repository

REVIEW
Refactor to move scope_def_applicable and check function visibility
from a module

Please let me know what's the best way to add a unit tests to
nameres, which is where the root cause was
@petr-tik
Copy link
Contributor

@asyncci hey would appreciate if you could build rust-analyzer from my PR branch and test drive it in your project.

When I tried it, only the public function were offered as completions, so I would appreciate if I missed anything

@asyncci
Copy link
Author

asyncci commented Aug 20, 2023

@asyncci hey would appreciate if you could build rust-analyzer from my PR branch and test drive it in your project.

When I tried it, only the public function were offered as completions, so I would appreciate if I missed anything

Yes of course, but I’m not at home currently , probably in two-three days . Is that okay?

@asyncci
Copy link
Author

asyncci commented Aug 30, 2023

Now it works correctly
main.rs:
image
decoder.rs:
image
Thanks ! Sorry for delay.

@asyncci asyncci closed this as completed Aug 30, 2023
@asyncci asyncci reopened this Aug 30, 2023
bors added a commit that referenced this issue Dec 8, 2023
…_2, r=Veykril

fix: Fix item tree lowering pub(self) to pub()

Prior to this, the item tree lowered `pub(self)` visibility to `pub()`
Fix #15134 - tested with a unit test and
a manual end-to-end test of building rust-analyzer from my branch and opening the reproduction repository
@bors bors closed this as completed in 2d879e0 Dec 8, 2023
mustakimali pushed a commit to mustakimali/rust-analyzer that referenced this issue Dec 13, 2023
Before
Private functions have RawVisibility module, but were
missed because take_types returned None early. After resolve_visibility
returned None, Visibility::Public was set instead and private functions
ended up being offered in autocompletion.

Choosing such a function results in an immediate error diagnostic
about using a private function.

After
Pattern match of take_types that returns None and
query for Module-level visibility from the original_module

Fix rust-lang#15134 - tested with a unit test and a manual end-to-end
test of building rust-analyzer from my branch and opening
the reproduction repository

REVIEW
Refactor to move scope_def_applicable and check function visibility
from a module

Please let me know what's the best way to add a unit tests to
nameres, which is where the root cause was
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion autocompletion C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants