From 009437f5d9949d2276aa26040e03af0ab328acf3 Mon Sep 17 00:00:00 2001 From: ice1000 Date: Tue, 3 Dec 2019 11:07:56 -0500 Subject: Replace `ra_hir_expand::either` with crate --- crates/ra_hir/Cargo.toml | 1 + crates/ra_hir/src/code_model.rs | 7 +++- crates/ra_hir/src/code_model/src.rs | 12 +++--- crates/ra_hir/src/lib.rs | 2 +- crates/ra_hir/src/source_binder.rs | 7 ++-- crates/ra_hir_def/Cargo.toml | 1 + crates/ra_hir_def/src/adt.rs | 6 +-- crates/ra_hir_def/src/attr.rs | 7 ++-- crates/ra_hir_def/src/body.rs | 9 ++--- crates/ra_hir_def/src/body/lower.rs | 16 ++++---- crates/ra_hir_def/src/docs.rs | 6 +-- crates/ra_hir_def/src/nameres.rs | 8 ++-- crates/ra_hir_def/src/nameres/raw.rs | 6 +-- crates/ra_hir_def/src/path.rs | 10 ++--- crates/ra_hir_expand/Cargo.toml | 1 + crates/ra_hir_expand/src/either.rs | 54 -------------------------- crates/ra_hir_expand/src/hygiene.rs | 6 +-- crates/ra_hir_expand/src/lib.rs | 1 - crates/ra_hir_ty/src/expr.rs | 4 +- crates/ra_ide/Cargo.toml | 1 + crates/ra_ide/src/completion/complete_path.rs | 5 ++- crates/ra_ide/src/display/navigation_target.rs | 7 ++-- 22 files changed, 65 insertions(+), 112 deletions(-) delete mode 100644 crates/ra_hir_expand/src/either.rs (limited to 'crates') diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index e79361e7c..6ca9cc2e7 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -10,6 +10,7 @@ doctest = false [dependencies] log = "0.4.5" rustc-hash = "1.0" +either = "1.5" ra_syntax = { path = "../ra_syntax" } ra_db = { path = "../ra_db" } 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; use std::sync::Arc; +use either::Either; use hir_def::{ adt::VariantData, body::{Body, BodySourceMap}, @@ -30,7 +31,7 @@ use crate::{ db::{DefDatabase, HirDatabase}, ty::display::HirFormatter, ty::{self, InEnvironment, InferenceResult, TraitEnvironment, Ty, TyDefId, TypeCtor, TypeWalk}, - CallableDef, Either, HirDisplay, InFile, Name, + CallableDef, HirDisplay, InFile, Name, }; /// hir::Crate describes a single crate. It's the main interface with which @@ -905,7 +906,9 @@ impl Local { let (_body, source_map) = db.body_with_source_map(self.parent.into()); let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm... let root = src.file_syntax(db); - src.map(|ast| ast.map(|it| it.cast().unwrap().to_node(&root), |it| it.to_node(&root))) + src.map(|ast| { + ast.map_left(|it| it.cast().unwrap().to_node(&root)).map_right(|it| it.to_node(&root)) + }) } } 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 @@ //! FIXME: write short doc here +use either::Either; use hir_def::{ src::{HasChildSource, HasSource as _}, AstItemDef, Lookup, VariantId, }; -use hir_expand::either::Either; use ra_syntax::ast; use crate::{ @@ -27,8 +27,8 @@ impl Module { let def_map = db.crate_def_map(self.id.krate); let src = def_map[self.id.local_id].definition_source(db); src.map(|it| match it { - Either::A(it) => ModuleSource::SourceFile(it), - Either::B(it) => ModuleSource::Module(it), + Either::Left(it) => ModuleSource::SourceFile(it), + Either::Right(it) => ModuleSource::Module(it), }) } @@ -46,8 +46,8 @@ impl HasSource for StructField { let var = VariantId::from(self.parent); let src = var.child_source(db); src.map(|it| match it[self.id].clone() { - Either::A(it) => FieldSource::Pos(it), - Either::B(it) => FieldSource::Named(it), + Either::Left(it) => FieldSource::Pos(it), + Either::Right(it) => FieldSource::Named(it), }) } } @@ -126,6 +126,6 @@ impl HasSource for Import { let (_, source_map) = db.raw_items_with_source_map(src.file_id); let root = db.parse_or_expand(src.file_id).unwrap(); let ptr = source_map.get(self.id); - src.with_value(ptr.map(|it| it.to_node(&root), |it| it.to_node(&root))) + src.with_value(ptr.map_left(|it| it.to_node(&root)).map_right(|it| it.to_node(&root))) } } 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::{ type_ref::Mutability, }; pub use hir_expand::{ - either::Either, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, + name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, }; 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 @@ //! purely for "IDE needs". use std::sync::Arc; +use either::Either; use hir_def::{ body::{ scope::{ExprScopes, ScopeId}, @@ -33,8 +34,8 @@ use crate::{ method_resolution::{self, implements_trait}, InEnvironment, TraitEnvironment, Ty, }, - Adt, AssocItem, Const, DefWithBody, Either, Enum, EnumVariant, FromSource, Function, - GenericParam, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, + Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, GenericParam, + Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, }; fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option { @@ -349,7 +350,7 @@ impl SourceAnalyzer { // should switch to general reference search infra there. pub fn find_all_refs(&self, pat: &ast::BindPat) -> Vec { let fn_def = pat.syntax().ancestors().find_map(ast::FnDef::cast).unwrap(); - let ptr = Either::A(AstPtr::new(&ast::Pat::from(pat.clone()))); + let ptr = Either::Left(AstPtr::new(&ast::Pat::from(pat.clone()))); fn_def .syntax() .descendants() diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index 7e65f4c1d..cf3a446fc 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -11,6 +11,7 @@ doctest = false log = "0.4.5" once_cell = "1.0.1" rustc-hash = "1.0" +either = "1.5" ra_arena = { path = "../ra_arena" } ra_db = { path = "../ra_db" } diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 9ab829aab..db3e63ef8 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -2,8 +2,8 @@ use std::sync::Arc; +use either::Either; use hir_expand::{ - either::Either, name::{AsName, Name}, InFile, }; @@ -184,7 +184,7 @@ fn lower_struct( ast::StructKind::Tuple(fl) => { for (i, fd) in fl.fields().enumerate() { trace.alloc( - || Either::A(fd.clone()), + || Either::Left(fd.clone()), || StructFieldData { name: Name::new_tuple_field(i), type_ref: TypeRef::from_ast_opt(fd.type_ref()), @@ -196,7 +196,7 @@ fn lower_struct( ast::StructKind::Record(fl) => { for fd in fl.fields() { trace.alloc( - || Either::B(fd.clone()), + || Either::Right(fd.clone()), || StructFieldData { name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index bc7ade921..7f9a6e7ca 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs @@ -2,7 +2,8 @@ use std::{ops, sync::Arc}; -use hir_expand::{either::Either, hygiene::Hygiene, AstId, InFile}; +use either::Either; +use hir_expand::{hygiene::Hygiene, AstId, InFile}; use mbe::ast_to_token_tree; use ra_syntax::{ ast::{self, AstNode, AttrsOwner}, @@ -45,8 +46,8 @@ impl Attrs { AttrDefId::StructFieldId(it) => { let src = it.parent.child_source(db); match &src.value[it.local_id] { - Either::A(_tuple) => Attrs::default(), - Either::B(record) => Attrs::from_attrs_owner(db, src.with_value(record)), + Either::Left(_tuple) => Attrs::default(), + Either::Right(record) => Attrs::from_attrs_owner(db, src.with_value(record)), } } AttrDefId::EnumVariantId(var_id) => { diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 239f35229..ef1816836 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -5,9 +5,8 @@ pub mod scope; use std::{ops::Index, sync::Arc}; -use hir_expand::{ - either::Either, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId, MacroFileKind, -}; +use either::Either; +use hir_expand::{hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId, MacroFileKind}; use ra_arena::{map::ArenaMap, Arena}; use ra_syntax::{ast, AstNode, AstPtr}; use rustc_hash::FxHashMap; @@ -210,7 +209,7 @@ impl BodySourceMap { } pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option { - let src = node.map(|it| Either::A(AstPtr::new(it))); + let src = node.map(|it| Either::Left(AstPtr::new(it))); self.expr_map.get(&src).cloned() } @@ -219,7 +218,7 @@ impl BodySourceMap { } pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option { - let src = node.map(|it| Either::A(AstPtr::new(it))); + let src = node.map(|it| Either::Left(AstPtr::new(it))); self.pat_map.get(&src).cloned() } diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index be1eaa523..71c08f024 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -1,10 +1,8 @@ //! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr` //! representation. -use hir_expand::{ - either::Either, - name::{self, AsName, Name}, -}; +use either::Either; +use hir_expand::name::{self, AsName, Name}; use ra_arena::Arena; use ra_syntax::{ ast::{ @@ -74,7 +72,7 @@ where mode: BindingAnnotation::Unannotated, subpat: None, }, - Either::B(ptr), + Either::Right(ptr), ); self.body.params.push(param_pat); } @@ -94,7 +92,7 @@ where } fn alloc_expr(&mut self, expr: Expr, ptr: AstPtr) -> ExprId { - let ptr = Either::A(ptr); + let ptr = Either::Left(ptr); let id = self.body.exprs.alloc(expr); let src = self.expander.to_source(ptr); self.source_map.expr_map.insert(src, id); @@ -107,7 +105,7 @@ where self.body.exprs.alloc(expr) } fn alloc_expr_field_shorthand(&mut self, expr: Expr, ptr: AstPtr) -> ExprId { - let ptr = Either::B(ptr); + let ptr = Either::Right(ptr); let id = self.body.exprs.alloc(expr); let src = self.expander.to_source(ptr); self.source_map.expr_map.insert(src, id); @@ -277,7 +275,7 @@ where ast::Expr::ParenExpr(e) => { let inner = self.collect_expr_opt(e.expr()); // make the paren expr point to the inner expression as well - let src = self.expander.to_source(Either::A(syntax_ptr)); + let src = self.expander.to_source(Either::Left(syntax_ptr)); self.source_map.expr_map.insert(src, inner); inner } @@ -550,7 +548,7 @@ where ast::Pat::SlicePat(_) | ast::Pat::RangePat(_) => Pat::Missing, }; let ptr = AstPtr::new(&pat); - self.alloc_pat(pattern, Either::A(ptr)) + self.alloc_pat(pattern, Either::Left(ptr)) } fn collect_pat_opt(&mut self, pat: Option) -> PatId { diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs index ec944373d..3fc6d6934 100644 --- a/crates/ra_hir_def/src/docs.rs +++ b/crates/ra_hir_def/src/docs.rs @@ -5,7 +5,7 @@ use std::sync::Arc; -use hir_expand::either::Either; +use either::Either; use ra_syntax::ast; use crate::{ @@ -46,8 +46,8 @@ impl Documentation { AttrDefId::StructFieldId(it) => { let src = it.parent.child_source(db); match &src.value[it.local_id] { - Either::A(_tuple) => None, - Either::B(record) => docs_from_ast(record), + Either::Left(_tuple) => None, + Either::Right(record) => docs_from_ast(record), } } AttrDefId::AdtId(it) => match it { diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 3e1521870..faf3566f4 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -57,9 +57,9 @@ mod tests; use std::sync::Arc; +use either::Either; use hir_expand::{ - ast_id_map::FileAstId, diagnostics::DiagnosticSink, either::Either, name::Name, InFile, - MacroDefId, + ast_id_map::FileAstId, diagnostics::DiagnosticSink, name::Name, InFile, MacroDefId, }; use once_cell::sync::Lazy; use ra_arena::Arena; @@ -287,10 +287,10 @@ impl ModuleData { ) -> InFile> { if let Some(file_id) = self.definition { let sf = db.parse(file_id).tree(); - return InFile::new(file_id.into(), Either::A(sf)); + return InFile::new(file_id.into(), Either::Left(sf)); } let decl = self.declaration.unwrap(); - InFile::new(decl.file_id, Either::B(decl.to_node(db))) + InFile::new(decl.file_id, Either::Right(decl.to_node(db))) } /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 5196b67ca..de4e706c2 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -7,10 +7,10 @@ use std::{ops::Index, sync::Arc}; +use either::Either; use hir_expand::{ ast_id_map::AstIdMap, db::AstDatabase, - either::Either, hygiene::Hygiene, name::{AsName, Name}, }; @@ -324,7 +324,7 @@ impl RawItemsCollector { is_extern_crate: false, is_macro_use: false, }; - buf.push((import_data, Either::A(AstPtr::new(use_tree)))); + buf.push((import_data, Either::Left(AstPtr::new(use_tree)))); }, ); for (import_data, ptr) in buf { @@ -355,7 +355,7 @@ impl RawItemsCollector { current_module, attrs, import_data, - Either::B(AstPtr::new(&extern_crate)), + Either::Right(AstPtr::new(&extern_crate)), ); } } diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index ff252fe44..3030dcdf6 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -2,8 +2,8 @@ use std::{iter, sync::Arc}; +use either::Either; use hir_expand::{ - either::Either, hygiene::Hygiene, name::{self, AsName, Name}, }; @@ -111,7 +111,7 @@ impl Path { ast::PathSegmentKind::Name(name_ref) => { // FIXME: this should just return name match hygiene.name_ref_to_name(name_ref) { - Either::A(name) => { + Either::Left(name) => { let args = segment .type_arg_list() .and_then(GenericArgs::from_ast) @@ -125,7 +125,7 @@ impl Path { let segment = PathSegment { name, args_and_bindings: args }; segments.push(segment); } - Either::B(crate_id) => { + Either::Right(crate_id) => { kind = PathKind::DollarCrate(crate_id); break; } @@ -347,7 +347,7 @@ fn convert_path(prefix: Option, path: ast::Path, hygiene: &Hygiene) -> Opt let res = match segment.kind()? { ast::PathSegmentKind::Name(name_ref) => { match hygiene.name_ref_to_name(name_ref) { - Either::A(name) => { + Either::Left(name) => { // no type args in use let mut res = prefix.unwrap_or_else(|| Path { kind: PathKind::Plain, @@ -359,7 +359,7 @@ fn convert_path(prefix: Option, path: ast::Path, hygiene: &Hygiene) -> Opt }); res } - Either::B(crate_id) => { + Either::Right(crate_id) => { return Some(Path::from_simple_segments( PathKind::DollarCrate(crate_id), iter::empty(), diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index c60152a79..3ae4376dc 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -9,6 +9,7 @@ doctest = false [dependencies] log = "0.4.5" +either = "1.5" ra_arena = { path = "../ra_arena" } ra_db = { path = "../ra_db" } diff --git a/crates/ra_hir_expand/src/either.rs b/crates/ra_hir_expand/src/either.rs deleted file mode 100644 index 83583ef8b..000000000 --- a/crates/ra_hir_expand/src/either.rs +++ /dev/null @@ -1,54 +0,0 @@ -//! FIXME: write short doc here - -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum Either { - A(A), - B(B), -} - -impl Either { - pub fn either(self, f1: F1, f2: F2) -> R - where - F1: FnOnce(A) -> R, - F2: FnOnce(B) -> R, - { - match self { - Either::A(a) => f1(a), - Either::B(b) => f2(b), - } - } - pub fn map(self, f1: F1, f2: F2) -> Either - where - F1: FnOnce(A) -> U, - F2: FnOnce(B) -> V, - { - match self { - Either::A(a) => Either::A(f1(a)), - Either::B(b) => Either::B(f2(b)), - } - } - pub fn map_a(self, f: F) -> Either - where - F: FnOnce(A) -> U, - { - self.map(f, |it| it) - } - pub fn a(self) -> Option { - match self { - Either::A(it) => Some(it), - Either::B(_) => None, - } - } - pub fn b(self) -> Option { - match self { - Either::A(_) => None, - Either::B(it) => Some(it), - } - } - pub fn as_ref(&self) -> Either<&A, &B> { - match self { - Either::A(it) => Either::A(it), - Either::B(it) => Either::B(it), - } - } -} diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs index 379562a2c..64c8b06c6 100644 --- a/crates/ra_hir_expand/src/hygiene.rs +++ b/crates/ra_hir_expand/src/hygiene.rs @@ -2,12 +2,12 @@ //! //! Specifically, `ast` + `Hygiene` allows you to create a `Name`. Note that, at //! this moment, this is horribly incomplete and handles only `$crate`. +use either::Either; use ra_db::CrateId; use ra_syntax::ast; use crate::{ db::AstDatabase, - either::Either, name::{AsName, Name}, HirFileId, HirFileIdRepr, MacroDefKind, }; @@ -41,9 +41,9 @@ impl Hygiene { pub fn name_ref_to_name(&self, name_ref: ast::NameRef) -> Either { if let Some(def_crate) = self.def_crate { if name_ref.text() == "$crate" { - return Either::B(def_crate); + return Either::Right(def_crate); } } - Either::A(name_ref.as_name()) + Either::Left(name_ref.as_name()) } } diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index fb88d2ac2..3be9bdf86 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -6,7 +6,6 @@ pub mod db; pub mod ast_id_map; -pub mod either; pub mod name; pub mod hygiene; pub mod diagnostics; diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index 5c65f9370..d2bd64e5c 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -97,7 +97,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { let (_, source_map) = db.body_with_source_map(self.func.into()); if let Some(source_ptr) = source_map.expr_syntax(id) { - if let Some(expr) = source_ptr.value.a() { + if let Some(expr) = source_ptr.value.left() { let root = source_ptr.file_syntax(db); if let ast::Expr::RecordLit(record_lit) = expr.to_node(&root) { if let Some(field_list) = record_lit.record_field_list() { @@ -142,7 +142,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { let (_, source_map) = db.body_with_source_map(self.func.into()); if let Some(source_ptr) = source_map.expr_syntax(id) { - if let Some(expr) = source_ptr.value.a() { + if let Some(expr) = source_ptr.value.left() { self.sink.push(MissingOkInTailExpr { file: source_ptr.file_id, expr }); } } diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index e6383dd35..e3439ae31 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -11,6 +11,7 @@ doctest = false wasm = [] [dependencies] +either = "1.5" format-buf = "1.0.0" itertools = "0.8.0" join_to_string = "0.1.3" diff --git a/crates/ra_ide/src/completion/complete_path.rs b/crates/ra_ide/src/completion/complete_path.rs index 89e0009a1..28f94e0a7 100644 --- a/crates/ra_ide/src/completion/complete_path.rs +++ b/crates/ra_ide/src/completion/complete_path.rs @@ -1,6 +1,7 @@ //! FIXME: write short doc here -use hir::{Adt, Either, HasSource, PathResolution}; +use either::Either; +use hir::{Adt, HasSource, PathResolution}; use ra_syntax::AstNode; use test_utils::tested_by; @@ -27,7 +28,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { } if Some(module) == ctx.module { if let Some(import) = import { - if let Either::A(use_tree) = import.source(ctx.db).value { + if let Either::Left(use_tree) = import.source(ctx.db).value { if use_tree.syntax().text_range().contains_inclusive(ctx.offset) { // for `use self::foo<|>`, don't suggest `foo` as a completion tested_by!(dont_complete_current_use); diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 61dca14ac..f920d3db6 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -1,6 +1,7 @@ //! FIXME: write short doc here -use hir::{AssocItem, Either, FieldSource, HasSource, InFile, ModuleSource}; +use either::Either; +use hir::{AssocItem, FieldSource, HasSource, InFile, ModuleSource}; use ra_db::{FileId, SourceDatabase}; use ra_syntax::{ ast::{self, DocCommentsOwner, NameOwner}, @@ -342,10 +343,10 @@ impl ToNav for hir::Local { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { let src = self.source(db); let (full_range, focus_range) = match src.value { - Either::A(it) => { + Either::Left(it) => { (it.syntax().text_range(), it.name().map(|it| it.syntax().text_range())) } - Either::B(it) => (it.syntax().text_range(), Some(it.self_kw_token().text_range())), + Either::Right(it) => (it.syntax().text_range(), Some(it.self_kw_token().text_range())), }; let name = match self.name(db) { Some(it) => it.to_string().into(), -- cgit v1.2.3