aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-11 13:21:08 +0100
committerGitHub <[email protected]>2020-05-11 13:21:08 +0100
commit05399250d47cdceffbf1ded08983b13a9dcc87c1 (patch)
treec3165d3c3236893c23deb881a792c2c34be2e2bf /crates/ra_ide/src
parenteb892d707c379eff514df9c2a6b2203f38874b14 (diff)
parent3d66aa054230ad788162ce49f0d334e900458cac (diff)
Merge #4421
4421: Find references to a function outside module r=flodiebold a=montekki Fixes #4188 Yet again, it looks like although the code in https://github.com/rust-analyzer/rust-analyzer/blob/da1f316b0246ce41d7cb8560181e294089f06ef3/crates/ra_ide_db/src/search.rs#L128-L132 may be wrong, it is not hit since the `vis` is `None` at this point. The fix is similar to the #4237 case: just add another special case to `Definition::visibility()`. Co-authored-by: Fedor Sakharov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/references.rs25
1 files changed, 25 insertions, 0 deletions
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 {
593 check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]); 593 check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]);
594 } 594 }
595 595
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
596 fn get_all_refs(text: &str) -> ReferenceSearchResult { 621 fn get_all_refs(text: &str) -> ReferenceSearchResult {
597 let (analysis, position) = single_file_with_position(text); 622 let (analysis, position) = single_file_with_position(text);
598 analysis.find_all_refs(position, None).unwrap().unwrap() 623 analysis.find_all_refs(position, None).unwrap().unwrap()