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/references.rs') 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 From 5258c817f78ecdfe12d7eec44ab3169134cba71d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 11:54:57 +0200 Subject: Remove cross-crate marks They create quite a bit of friction. Really, we should just move the tests to the same crate, rather than paper over existing split. --- crates/ra_ide/src/references.rs | 3 --- 1 file changed, 3 deletions(-) (limited to 'crates/ra_ide/src/references.rs') diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 074284b42..96444bf6a 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -190,8 +190,6 @@ fn get_struct_def_name_for_struct_literal_search( #[cfg(test)] mod tests { - use test_utils::covers; - use crate::{ mock_analysis::{analysis_and_position, single_file_with_position, MockAnalysis}, Declaration, Reference, ReferenceSearchResult, SearchScope, @@ -301,7 +299,6 @@ mod tests { #[test] fn search_filters_by_range() { - covers!(ra_ide_db::search_filters_by_range); let code = r#" fn foo() { let spam<|> = 92; -- cgit v1.2.3