diff options
Diffstat (limited to 'crates/ra_hir_expand/src/hygiene.rs')
-rw-r--r-- | crates/ra_hir_expand/src/hygiene.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs index 379562a2c..2e8a533f7 100644 --- a/crates/ra_hir_expand/src/hygiene.rs +++ b/crates/ra_hir_expand/src/hygiene.rs | |||
@@ -2,12 +2,12 @@ | |||
2 | //! | 2 | //! |
3 | //! Specifically, `ast` + `Hygiene` allows you to create a `Name`. Note that, at | 3 | //! Specifically, `ast` + `Hygiene` allows you to create a `Name`. Note that, at |
4 | //! this moment, this is horribly incomplete and handles only `$crate`. | 4 | //! this moment, this is horribly incomplete and handles only `$crate`. |
5 | use either::Either; | ||
5 | use ra_db::CrateId; | 6 | use ra_db::CrateId; |
6 | use ra_syntax::ast; | 7 | use ra_syntax::ast; |
7 | 8 | ||
8 | use crate::{ | 9 | use crate::{ |
9 | db::AstDatabase, | 10 | db::AstDatabase, |
10 | either::Either, | ||
11 | name::{AsName, Name}, | 11 | name::{AsName, Name}, |
12 | HirFileId, HirFileIdRepr, MacroDefKind, | 12 | HirFileId, HirFileIdRepr, MacroDefKind, |
13 | }; | 13 | }; |
@@ -25,8 +25,9 @@ impl Hygiene { | |||
25 | HirFileIdRepr::MacroFile(macro_file) => { | 25 | HirFileIdRepr::MacroFile(macro_file) => { |
26 | let loc = db.lookup_intern_macro(macro_file.macro_call_id); | 26 | let loc = db.lookup_intern_macro(macro_file.macro_call_id); |
27 | match loc.def.kind { | 27 | match loc.def.kind { |
28 | MacroDefKind::Declarative => Some(loc.def.krate), | 28 | MacroDefKind::Declarative => loc.def.krate, |
29 | MacroDefKind::BuiltIn(_) => None, | 29 | MacroDefKind::BuiltIn(_) => None, |
30 | MacroDefKind::BuiltInDerive(_) => None, | ||
30 | } | 31 | } |
31 | } | 32 | } |
32 | }; | 33 | }; |
@@ -41,9 +42,9 @@ impl Hygiene { | |||
41 | pub fn name_ref_to_name(&self, name_ref: ast::NameRef) -> Either<Name, CrateId> { | 42 | pub fn name_ref_to_name(&self, name_ref: ast::NameRef) -> Either<Name, CrateId> { |
42 | if let Some(def_crate) = self.def_crate { | 43 | if let Some(def_crate) = self.def_crate { |
43 | if name_ref.text() == "$crate" { | 44 | if name_ref.text() == "$crate" { |
44 | return Either::B(def_crate); | 45 | return Either::Right(def_crate); |
45 | } | 46 | } |
46 | } | 47 | } |
47 | Either::A(name_ref.as_name()) | 48 | Either::Left(name_ref.as_name()) |
48 | } | 49 | } |
49 | } | 50 | } |