From aa5f6a1ee8b56343e9f3dc9b1578d56f29dd2bc8 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 2 Feb 2019 00:17:48 +0100 Subject: Add test for `use as` --- crates/ra_hir/src/nameres/tests.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'crates/ra_hir/src/nameres') diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs index 0e0683db7..81c8a4f12 100644 --- a/crates/ra_hir/src/nameres/tests.rs +++ b/crates/ra_hir/src/nameres/tests.rs @@ -90,6 +90,30 @@ fn item_map_smoke_test() { ); } +#[test] +fn use_as() { + let (item_map, module_id) = item_map( + " + //- /lib.rs + mod foo; + + use crate::foo::Baz as Foo; + <|> + + //- /foo/mod.rs + pub struct Baz; + ", + ); + check_module_item_map( + &item_map, + module_id, + " + Foo: t v + foo: t + ", + ); +} + #[test] fn use_trees() { let (item_map, module_id) = item_map( -- cgit v1.2.3 From 5a7fce4e4cd8846a49ce007910f72340007d9c8c Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 2 Feb 2019 00:18:10 +0100 Subject: Pass aliases to ImportData --- crates/ra_hir/src/nameres/lower.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src/nameres') diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs index 9a45fa61c..df87f520f 100644 --- a/crates/ra_hir/src/nameres/lower.rs +++ b/crates/ra_hir/src/nameres/lower.rs @@ -21,6 +21,7 @@ impl_arena_id!(ImportId); #[derive(Debug, PartialEq, Eq)] pub(super) struct ImportData { pub(super) path: Path, + pub(super) alias: Option, pub(super) is_glob: bool, } @@ -209,9 +210,10 @@ impl LoweredModule { } fn add_use_item(&mut self, source_map: &mut ImportSourceMap, item: &ast::UseItem) { - Path::expand_use_item(item, |path, segment| { + Path::expand_use_item(item, |path, segment, alias| { let import = self.imports.alloc(ImportData { path, + alias, is_glob: segment.is_none(), }); if let Some(segment) = segment { -- cgit v1.2.3