From 6dae5cbb1190cde6a20aa1758c7d87e84933378e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 2 Feb 2020 14:06:51 +0200 Subject: Require ModPath for importing --- crates/ra_hir_def/src/path.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_def/src/path.rs') diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index ab290e2c9..a150b899f 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -16,13 +16,13 @@ use ra_syntax::ast; use crate::{type_ref::TypeRef, InFile}; -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ModPath { pub kind: PathKind, pub segments: Vec, } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum PathKind { Plain, /// `self::` is `Super(0)` -- cgit v1.2.3 From 7d527159457420d55f1ee2f70615098a10176b91 Mon Sep 17 00:00:00 2001 From: zombiefungus Date: Thu, 30 Jan 2020 23:14:20 -0500 Subject: add new ImportAlias enum to differentiate no alias from an _ alias --- crates/ra_hir_def/src/path.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_def/src/path.rs') diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index ab290e2c9..27ccf6643 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -57,7 +57,12 @@ impl ModPath { pub(crate) fn expand_use_item( item_src: InFile, hygiene: &Hygiene, - mut cb: impl FnMut(ModPath, &ast::UseTree, /* is_glob */ bool, Option), + mut cb: impl FnMut( + ModPath, + &ast::UseTree, + /* is_glob */ bool, + crate::nameres::raw::ImportAlias, + ), ) { if let Some(tree) = item_src.value.use_tree() { lower::lower_use_tree(None, tree, hygiene, &mut cb); -- cgit v1.2.3 From f4f71e361ee632a7a09b633934a9c0a11f4a9be7 Mon Sep 17 00:00:00 2001 From: zombiefungus Date: Sun, 2 Feb 2020 08:04:06 -0500 Subject: include requested changes --- crates/ra_hir_def/src/path.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir_def/src/path.rs') diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 27ccf6643..fb7692191 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -34,6 +34,14 @@ pub enum PathKind { DollarCrate(CrateId), } +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum ImportAlias { + /// Unnamed alias, as in `use Foo as _;` + Underscore, + /// Named alias + Alias(Name), +} + impl ModPath { pub fn from_src(path: ast::Path, hygiene: &Hygiene) -> Option { lower::lower_path(path, hygiene).map(|it| it.mod_path) @@ -57,12 +65,7 @@ impl ModPath { pub(crate) fn expand_use_item( item_src: InFile, hygiene: &Hygiene, - mut cb: impl FnMut( - ModPath, - &ast::UseTree, - /* is_glob */ bool, - crate::nameres::raw::ImportAlias, - ), + mut cb: impl FnMut(ModPath, &ast::UseTree, /* is_glob */ bool, Option), ) { if let Some(tree) = item_src.value.use_tree() { lower::lower_use_tree(None, tree, hygiene, &mut cb); -- cgit v1.2.3