Auto merge of #15486 - petr-tik:n15134_hide_private_from_autocomplete_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
This commit is contained in:
commit
4f3d862fcf
@ -370,3 +370,15 @@ fn generics_with_attributes() {
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pub_self() {
|
||||
check(
|
||||
r#"
|
||||
pub(self) struct S;
|
||||
"#,
|
||||
expect![[r#"
|
||||
pub(self) struct S;
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ pub(crate) fn resolve_visibility(
|
||||
let types = result.take_types()?;
|
||||
match types {
|
||||
ModuleDefId::ModuleId(m) => Visibility::Module(m),
|
||||
// error: visibility needs to refer to module
|
||||
_ => {
|
||||
// error: visibility needs to refer to module
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ pub(crate) fn from_ast_with_span_map_and_default(
|
||||
RawVisibility::Module(path)
|
||||
}
|
||||
ast::VisibilityKind::PubSelf => {
|
||||
let path = ModPath::from_kind(PathKind::Plain);
|
||||
let path = ModPath::from_kind(PathKind::Super(0));
|
||||
RawVisibility::Module(path)
|
||||
}
|
||||
ast::VisibilityKind::Pub => RawVisibility::Public,
|
||||
|
@ -1286,6 +1286,30 @@ fn here_we_go() fn()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_only_public() {
|
||||
check(
|
||||
r#"
|
||||
//- /e.rs
|
||||
pub(self) fn i_should_be_hidden() {}
|
||||
pub(in crate::e) fn i_should_also_be_hidden() {}
|
||||
pub fn i_am_public () {}
|
||||
|
||||
//- /lib.rs crate:krate
|
||||
pub mod e;
|
||||
|
||||
//- /main.rs deps:krate crate:main
|
||||
use krate::e;
|
||||
fn main() {
|
||||
e::$0
|
||||
}"#,
|
||||
expect![
|
||||
"fn i_am_public() fn()
|
||||
"
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completion_filtering_excludes_non_identifier_doc_aliases() {
|
||||
check_edit(
|
||||
|
Loading…
Reference in New Issue
Block a user