diff options
author | Florian Diebold <[email protected]> | 2019-02-01 23:36:48 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-02-04 20:49:34 +0000 |
commit | 397d84ee292295ce1d19033e586467ef9148e5bc (patch) | |
tree | e9241f1b31e857ea1990b96c9c808614ca5a0835 /crates/ra_hir/src/nameres | |
parent | e163c908acff9260eff347541f0f3f57db551622 (diff) |
Add test for extern crate renames
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r-- | crates/ra_hir/src/nameres/tests.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs index 81c8a4f12..42c59f76f 100644 --- a/crates/ra_hir/src/nameres/tests.rs +++ b/crates/ra_hir/src/nameres/tests.rs | |||
@@ -335,6 +335,48 @@ fn item_map_across_crates() { | |||
335 | } | 335 | } |
336 | 336 | ||
337 | #[test] | 337 | #[test] |
338 | fn extern_crate_rename() { | ||
339 | let (mut db, sr) = MockDatabase::with_files( | ||
340 | " | ||
341 | //- /main.rs | ||
342 | extern crate alloc as alloc_crate; | ||
343 | |||
344 | mod alloc; | ||
345 | |||
346 | use alloc_crate::Arc; | ||
347 | |||
348 | //- /lib.rs | ||
349 | struct Arc; | ||
350 | ", | ||
351 | ); | ||
352 | let main_id = sr.files[RelativePath::new("/main.rs")]; | ||
353 | let lib_id = sr.files[RelativePath::new("/lib.rs")]; | ||
354 | |||
355 | let mut crate_graph = CrateGraph::default(); | ||
356 | let main_crate = crate_graph.add_crate_root(main_id); | ||
357 | let lib_crate = crate_graph.add_crate_root(lib_id); | ||
358 | crate_graph | ||
359 | .add_dep(main_crate, "alloc".into(), lib_crate) | ||
360 | .unwrap(); | ||
361 | |||
362 | db.set_crate_graph(Arc::new(crate_graph)); | ||
363 | |||
364 | let module = crate::source_binder::module_from_file_id(&db, main_id).unwrap(); | ||
365 | let krate = module.krate(&db).unwrap(); | ||
366 | let item_map = db.item_map(krate); | ||
367 | |||
368 | check_module_item_map( | ||
369 | &item_map, | ||
370 | module.module_id, | ||
371 | " | ||
372 | Arc: t v | ||
373 | alloc: t | ||
374 | alloc_crate: t | ||
375 | ", | ||
376 | ); | ||
377 | } | ||
378 | |||
379 | #[test] | ||
338 | fn import_across_source_roots() { | 380 | fn import_across_source_roots() { |
339 | let (mut db, sr) = MockDatabase::with_files( | 381 | let (mut db, sr) = MockDatabase::with_files( |
340 | " | 382 | " |