diff options
author | ice1000 <[email protected]> | 2019-12-03 16:07:56 +0000 |
---|---|---|
committer | ice1000 <[email protected]> | 2019-12-03 16:07:56 +0000 |
commit | 009437f5d9949d2276aa26040e03af0ab328acf3 (patch) | |
tree | 74a889d70e201d6997c6baf179261ab3ed8bf23c /crates/ra_hir/src | |
parent | 15f143f0c33cbd382a2ad7a407d9601cb843d164 (diff) |
Replace `ra_hir_expand::either` with crate
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 7 |
4 files changed, 16 insertions, 12 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index dddac915b..5877afefa 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -4,6 +4,7 @@ pub(crate) mod src; | |||
4 | 4 | ||
5 | use std::sync::Arc; | 5 | use std::sync::Arc; |
6 | 6 | ||
7 | use either::Either; | ||
7 | use hir_def::{ | 8 | use hir_def::{ |
8 | adt::VariantData, | 9 | adt::VariantData, |
9 | body::{Body, BodySourceMap}, | 10 | body::{Body, BodySourceMap}, |
@@ -30,7 +31,7 @@ use crate::{ | |||
30 | db::{DefDatabase, HirDatabase}, | 31 | db::{DefDatabase, HirDatabase}, |
31 | ty::display::HirFormatter, | 32 | ty::display::HirFormatter, |
32 | ty::{self, InEnvironment, InferenceResult, TraitEnvironment, Ty, TyDefId, TypeCtor, TypeWalk}, | 33 | ty::{self, InEnvironment, InferenceResult, TraitEnvironment, Ty, TyDefId, TypeCtor, TypeWalk}, |
33 | CallableDef, Either, HirDisplay, InFile, Name, | 34 | CallableDef, HirDisplay, InFile, Name, |
34 | }; | 35 | }; |
35 | 36 | ||
36 | /// hir::Crate describes a single crate. It's the main interface with which | 37 | /// hir::Crate describes a single crate. It's the main interface with which |
@@ -905,7 +906,9 @@ impl Local { | |||
905 | let (_body, source_map) = db.body_with_source_map(self.parent.into()); | 906 | let (_body, source_map) = db.body_with_source_map(self.parent.into()); |
906 | let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm... | 907 | let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm... |
907 | let root = src.file_syntax(db); | 908 | let root = src.file_syntax(db); |
908 | src.map(|ast| ast.map(|it| it.cast().unwrap().to_node(&root), |it| it.to_node(&root))) | 909 | src.map(|ast| { |
910 | ast.map_left(|it| it.cast().unwrap().to_node(&root)).map_right(|it| it.to_node(&root)) | ||
911 | }) | ||
909 | } | 912 | } |
910 | } | 913 | } |
911 | 914 | ||
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 2cf210349..36cfbc8f1 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -1,10 +1,10 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use either::Either; | ||
3 | use hir_def::{ | 4 | use hir_def::{ |
4 | src::{HasChildSource, HasSource as _}, | 5 | src::{HasChildSource, HasSource as _}, |
5 | AstItemDef, Lookup, VariantId, | 6 | AstItemDef, Lookup, VariantId, |
6 | }; | 7 | }; |
7 | use hir_expand::either::Either; | ||
8 | use ra_syntax::ast; | 8 | use ra_syntax::ast; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
@@ -27,8 +27,8 @@ impl Module { | |||
27 | let def_map = db.crate_def_map(self.id.krate); | 27 | let def_map = db.crate_def_map(self.id.krate); |
28 | let src = def_map[self.id.local_id].definition_source(db); | 28 | let src = def_map[self.id.local_id].definition_source(db); |
29 | src.map(|it| match it { | 29 | src.map(|it| match it { |
30 | Either::A(it) => ModuleSource::SourceFile(it), | 30 | Either::Left(it) => ModuleSource::SourceFile(it), |
31 | Either::B(it) => ModuleSource::Module(it), | 31 | Either::Right(it) => ModuleSource::Module(it), |
32 | }) | 32 | }) |
33 | } | 33 | } |
34 | 34 | ||
@@ -46,8 +46,8 @@ impl HasSource for StructField { | |||
46 | let var = VariantId::from(self.parent); | 46 | let var = VariantId::from(self.parent); |
47 | let src = var.child_source(db); | 47 | let src = var.child_source(db); |
48 | src.map(|it| match it[self.id].clone() { | 48 | src.map(|it| match it[self.id].clone() { |
49 | Either::A(it) => FieldSource::Pos(it), | 49 | Either::Left(it) => FieldSource::Pos(it), |
50 | Either::B(it) => FieldSource::Named(it), | 50 | Either::Right(it) => FieldSource::Named(it), |
51 | }) | 51 | }) |
52 | } | 52 | } |
53 | } | 53 | } |
@@ -126,6 +126,6 @@ impl HasSource for Import { | |||
126 | let (_, source_map) = db.raw_items_with_source_map(src.file_id); | 126 | let (_, source_map) = db.raw_items_with_source_map(src.file_id); |
127 | let root = db.parse_or_expand(src.file_id).unwrap(); | 127 | let root = db.parse_or_expand(src.file_id).unwrap(); |
128 | let ptr = source_map.get(self.id); | 128 | let ptr = source_map.get(self.id); |
129 | src.with_value(ptr.map(|it| it.to_node(&root), |it| it.to_node(&root))) | 129 | src.with_value(ptr.map_left(|it| it.to_node(&root)).map_right(|it| it.to_node(&root))) |
130 | } | 130 | } |
131 | } | 131 | } |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 88d2f6e02..853760cb1 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -63,5 +63,5 @@ pub use hir_def::{ | |||
63 | type_ref::Mutability, | 63 | type_ref::Mutability, |
64 | }; | 64 | }; |
65 | pub use hir_expand::{ | 65 | pub use hir_expand::{ |
66 | either::Either, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, | 66 | name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, |
67 | }; | 67 | }; |
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 0df7a7cb4..28d41b647 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -7,6 +7,7 @@ | |||
7 | //! purely for "IDE needs". | 7 | //! purely for "IDE needs". |
8 | use std::sync::Arc; | 8 | use std::sync::Arc; |
9 | 9 | ||
10 | use either::Either; | ||
10 | use hir_def::{ | 11 | use hir_def::{ |
11 | body::{ | 12 | body::{ |
12 | scope::{ExprScopes, ScopeId}, | 13 | scope::{ExprScopes, ScopeId}, |
@@ -33,8 +34,8 @@ use crate::{ | |||
33 | method_resolution::{self, implements_trait}, | 34 | method_resolution::{self, implements_trait}, |
34 | InEnvironment, TraitEnvironment, Ty, | 35 | InEnvironment, TraitEnvironment, Ty, |
35 | }, | 36 | }, |
36 | Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function, | 37 | Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, GenericParam, |
37 | GenericParam, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, | 38 | Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, |
38 | }; | 39 | }; |
39 | 40 | ||
40 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option<Resolver> { | 41 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option<Resolver> { |
@@ -349,7 +350,7 @@ impl SourceAnalyzer { | |||
349 | // should switch to general reference search infra there. | 350 | // should switch to general reference search infra there. |
350 | pub fn find_all_refs(&self, pat: &ast::BindPat) -> Vec<ReferenceDescriptor> { | 351 | pub fn find_all_refs(&self, pat: &ast::BindPat) -> Vec<ReferenceDescriptor> { |
351 | let fn_def = pat.syntax().ancestors().find_map(ast::FnDef::cast).unwrap(); | 352 | let fn_def = pat.syntax().ancestors().find_map(ast::FnDef::cast).unwrap(); |
352 | let ptr = Either::A(AstPtr::new(&ast::Pat::from(pat.clone()))); | 353 | let ptr = Either::Left(AstPtr::new(&ast::Pat::from(pat.clone()))); |
353 | fn_def | 354 | fn_def |
354 | .syntax() | 355 | .syntax() |
355 | .descendants() | 356 | .descendants() |