Auto merge of #18337 - dqkqd:issue-18287, r=Veykril
fix: private items are shown in completions for modules in fn body Close: #18287
This commit is contained in:
commit
a41e3155dd
@ -139,13 +139,11 @@ fn is_visible_from_def_map_(
|
|||||||
let def_map_block = def_map.block_id();
|
let def_map_block = def_map.block_id();
|
||||||
loop {
|
loop {
|
||||||
match (to_module.block, def_map_block) {
|
match (to_module.block, def_map_block) {
|
||||||
// to_module is not a block, so there is no parent def map to use
|
// `to_module` is not a block, so there is no parent def map to use.
|
||||||
(None, _) => (),
|
(None, _) => (),
|
||||||
|
// `to_module` is at `def_map`'s block, no need to move further.
|
||||||
(Some(a), Some(b)) if a == b => {
|
(Some(a), Some(b)) if a == b => {
|
||||||
cov_mark::hit!(is_visible_from_same_block_def_map);
|
cov_mark::hit!(is_visible_from_same_block_def_map);
|
||||||
if let Some(parent) = def_map.parent() {
|
|
||||||
to_module = parent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if let Some(parent) = to_module.def_map(db).parent() {
|
if let Some(parent) = to_module.def_map(db).parent() {
|
||||||
|
@ -923,3 +923,21 @@ fn foo() {
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn private_item_in_module_in_function_body() {
|
||||||
|
check_empty(
|
||||||
|
r#"
|
||||||
|
fn main() {
|
||||||
|
mod foo {
|
||||||
|
struct Private;
|
||||||
|
pub struct Public;
|
||||||
|
}
|
||||||
|
foo::$0
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
st Public Public
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user