aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/references.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/references.rs')
-rw-r--r--crates/ra_ide_api/src/references.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs
index 3d647d2cb..aadd52616 100644
--- a/crates/ra_ide_api/src/references.rs
+++ b/crates/ra_ide_api/src/references.rs
@@ -270,9 +270,8 @@ mod tests {
270 assert_eq!(refs.len(), 3); 270 assert_eq!(refs.len(), 3);
271 } 271 }
272 272
273
274 // `mod foo;` is not in the results because `foo` is an `ast::Name`. 273 // `mod foo;` is not in the results because `foo` is an `ast::Name`.
275 // So, there are two references: the first one is a definition of the `foo` module, 274 // So, there are two references: the first one is a definition of the `foo` module,
276 // which is the whole `foo.rs`, and the second one is in `use foo::Foo`. 275 // which is the whole `foo.rs`, and the second one is in `use foo::Foo`.
277 #[test] 276 #[test]
278 fn test_find_all_refs_decl_module() { 277 fn test_find_all_refs_decl_module() {
@@ -297,6 +296,31 @@ mod tests {
297 assert_eq!(refs.len(), 2); 296 assert_eq!(refs.len(), 2);
298 } 297 }
299 298
299 #[test]
300 fn test_find_all_refs_super_mod_vis() {
301 let code = r#"
302 //- /lib.rs
303 mod foo;
304
305 //- /foo.rs
306 mod some;
307 use some::Foo;
308
309 fn f() {
310 let i = Foo { n: 5 };
311 }
312
313 //- /foo/some.rs
314 pub(super) struct Foo<|> {
315 pub n: u32,
316 }
317 "#;
318
319 let (analysis, pos) = analysis_and_position(code);
320 let refs = analysis.find_all_refs(pos).unwrap().unwrap();
321 assert_eq!(refs.len(), 3);
322 }
323
300 fn get_all_refs(text: &str) -> ReferenceSearchResult { 324 fn get_all_refs(text: &str) -> ReferenceSearchResult {
301 let (analysis, position) = single_file_with_position(text); 325 let (analysis, position) = single_file_with_position(text);
302 analysis.find_all_refs(position).unwrap().unwrap() 326 analysis.find_all_refs(position).unwrap().unwrap()