Skip to content

Commit 762ec95

Browse files
committed
Find references to a function outside module
1 parent 4578154 commit 762ec95

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

crates/ra_ide/src/references.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,31 @@ mod tests {
593593
check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]);
594594
}
595595

596+
#[test]
597+
fn test_find_struct_function_refs_outside_module() {
598+
let code = r#"
599+
mod foo {
600+
pub struct Foo;
601+
602+
impl Foo {
603+
pub fn new<|>() -> Foo {
604+
Foo
605+
}
606+
}
607+
}
608+
609+
fn main() {
610+
let _f = foo::Foo::new();
611+
}"#;
612+
613+
let refs = get_all_refs(code);
614+
check_result(
615+
refs,
616+
"new FN_DEF FileId(1) 87..150 94..97 Other",
617+
&["FileId(1) 227..230 StructLiteral"],
618+
);
619+
}
620+
596621
fn get_all_refs(text: &str) -> ReferenceSearchResult {
597622
let (analysis, position) = single_file_with_position(text);
598623
analysis.find_all_refs(position, None).unwrap().unwrap()

crates/ra_ide_db/src/defs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ impl Definition {
5252
let parent = id.parent_enum(db);
5353
module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent)))
5454
}
55+
ModuleDef::Function(f) => Some(f.visibility(db)),
5556
_ => module?.visibility_of(db, def),
5657
},
5758
Definition::SelfType(_) => None,

0 commit comments

Comments
 (0)