From 762ec9581a4331a2726cc236c565323d0c8cdb07 Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Mon, 11 May 2020 12:25:18 +0300 Subject: Find references to a function outside module --- crates/ra_ide/src/references.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 555ccf295..074284b42 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -593,6 +593,31 @@ mod tests { check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]); } + #[test] + fn test_find_struct_function_refs_outside_module() { + let code = r#" + mod foo { + pub struct Foo; + + impl Foo { + pub fn new<|>() -> Foo { + Foo + } + } + } + + fn main() { + let _f = foo::Foo::new(); + }"#; + + let refs = get_all_refs(code); + check_result( + refs, + "new FN_DEF FileId(1) 87..150 94..97 Other", + &["FileId(1) 227..230 StructLiteral"], + ); + } + fn get_all_refs(text: &str) -> ReferenceSearchResult { let (analysis, position) = single_file_with_position(text); analysis.find_all_refs(position, None).unwrap().unwrap() -- cgit v1.2.3