aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/adt.rs6
-rw-r--r--crates/ra_hir_def/src/attr.rs7
-rw-r--r--crates/ra_hir_def/src/body.rs9
-rw-r--r--crates/ra_hir_def/src/body/lower.rs16
-rw-r--r--crates/ra_hir_def/src/docs.rs6
-rw-r--r--crates/ra_hir_def/src/nameres.rs8
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs6
-rw-r--r--crates/ra_hir_def/src/path.rs10
8 files changed, 33 insertions, 35 deletions
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 @@
2 2
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use either::Either;
5use hir_expand::{ 6use hir_expand::{
6 either::Either,
7 name::{AsName, Name}, 7 name::{AsName, Name},
8 InFile, 8 InFile,
9}; 9};
@@ -184,7 +184,7 @@ fn lower_struct(
184 ast::StructKind::Tuple(fl) => { 184 ast::StructKind::Tuple(fl) => {
185 for (i, fd) in fl.fields().enumerate() { 185 for (i, fd) in fl.fields().enumerate() {
186 trace.alloc( 186 trace.alloc(
187 || Either::A(fd.clone()), 187 || Either::Left(fd.clone()),
188 || StructFieldData { 188 || StructFieldData {
189 name: Name::new_tuple_field(i), 189 name: Name::new_tuple_field(i),
190 type_ref: TypeRef::from_ast_opt(fd.type_ref()), 190 type_ref: TypeRef::from_ast_opt(fd.type_ref()),
@@ -196,7 +196,7 @@ fn lower_struct(
196 ast::StructKind::Record(fl) => { 196 ast::StructKind::Record(fl) => {
197 for fd in fl.fields() { 197 for fd in fl.fields() {
198 trace.alloc( 198 trace.alloc(
199 || Either::B(fd.clone()), 199 || Either::Right(fd.clone()),
200 || StructFieldData { 200 || StructFieldData {
201 name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), 201 name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing),
202 type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), 202 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 @@
2 2
3use std::{ops, sync::Arc}; 3use std::{ops, sync::Arc};
4 4
5use hir_expand::{either::Either, hygiene::Hygiene, AstId, InFile}; 5use either::Either;
6use hir_expand::{hygiene::Hygiene, AstId, InFile};
6use mbe::ast_to_token_tree; 7use mbe::ast_to_token_tree;
7use ra_syntax::{ 8use ra_syntax::{
8 ast::{self, AstNode, AttrsOwner}, 9 ast::{self, AstNode, AttrsOwner},
@@ -45,8 +46,8 @@ impl Attrs {
45 AttrDefId::StructFieldId(it) => { 46 AttrDefId::StructFieldId(it) => {
46 let src = it.parent.child_source(db); 47 let src = it.parent.child_source(db);
47 match &src.value[it.local_id] { 48 match &src.value[it.local_id] {
48 Either::A(_tuple) => Attrs::default(), 49 Either::Left(_tuple) => Attrs::default(),
49 Either::B(record) => Attrs::from_attrs_owner(db, src.with_value(record)), 50 Either::Right(record) => Attrs::from_attrs_owner(db, src.with_value(record)),
50 } 51 }
51 } 52 }
52 AttrDefId::EnumVariantId(var_id) => { 53 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;
5 5
6use std::{ops::Index, sync::Arc}; 6use std::{ops::Index, sync::Arc};
7 7
8use hir_expand::{ 8use either::Either;
9 either::Either, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId, MacroFileKind, 9use hir_expand::{hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId, MacroFileKind};
10};
11use ra_arena::{map::ArenaMap, Arena}; 10use ra_arena::{map::ArenaMap, Arena};
12use ra_syntax::{ast, AstNode, AstPtr}; 11use ra_syntax::{ast, AstNode, AstPtr};
13use rustc_hash::FxHashMap; 12use rustc_hash::FxHashMap;
@@ -210,7 +209,7 @@ impl BodySourceMap {
210 } 209 }
211 210
212 pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option<ExprId> { 211 pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option<ExprId> {
213 let src = node.map(|it| Either::A(AstPtr::new(it))); 212 let src = node.map(|it| Either::Left(AstPtr::new(it)));
214 self.expr_map.get(&src).cloned() 213 self.expr_map.get(&src).cloned()
215 } 214 }
216 215
@@ -219,7 +218,7 @@ impl BodySourceMap {
219 } 218 }
220 219
221 pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option<PatId> { 220 pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option<PatId> {
222 let src = node.map(|it| Either::A(AstPtr::new(it))); 221 let src = node.map(|it| Either::Left(AstPtr::new(it)));
223 self.pat_map.get(&src).cloned() 222 self.pat_map.get(&src).cloned()
224 } 223 }
225 224
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 @@
1//! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr` 1//! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr`
2//! representation. 2//! representation.
3 3
4use hir_expand::{ 4use either::Either;
5 either::Either, 5use hir_expand::name::{self, AsName, Name};
6 name::{self, AsName, Name},
7};
8use ra_arena::Arena; 6use ra_arena::Arena;
9use ra_syntax::{ 7use ra_syntax::{
10 ast::{ 8 ast::{
@@ -74,7 +72,7 @@ where
74 mode: BindingAnnotation::Unannotated, 72 mode: BindingAnnotation::Unannotated,
75 subpat: None, 73 subpat: None,
76 }, 74 },
77 Either::B(ptr), 75 Either::Right(ptr),
78 ); 76 );
79 self.body.params.push(param_pat); 77 self.body.params.push(param_pat);
80 } 78 }
@@ -94,7 +92,7 @@ where
94 } 92 }
95 93
96 fn alloc_expr(&mut self, expr: Expr, ptr: AstPtr<ast::Expr>) -> ExprId { 94 fn alloc_expr(&mut self, expr: Expr, ptr: AstPtr<ast::Expr>) -> ExprId {
97 let ptr = Either::A(ptr); 95 let ptr = Either::Left(ptr);
98 let id = self.body.exprs.alloc(expr); 96 let id = self.body.exprs.alloc(expr);
99 let src = self.expander.to_source(ptr); 97 let src = self.expander.to_source(ptr);
100 self.source_map.expr_map.insert(src, id); 98 self.source_map.expr_map.insert(src, id);
@@ -107,7 +105,7 @@ where
107 self.body.exprs.alloc(expr) 105 self.body.exprs.alloc(expr)
108 } 106 }
109 fn alloc_expr_field_shorthand(&mut self, expr: Expr, ptr: AstPtr<ast::RecordField>) -> ExprId { 107 fn alloc_expr_field_shorthand(&mut self, expr: Expr, ptr: AstPtr<ast::RecordField>) -> ExprId {
110 let ptr = Either::B(ptr); 108 let ptr = Either::Right(ptr);
111 let id = self.body.exprs.alloc(expr); 109 let id = self.body.exprs.alloc(expr);
112 let src = self.expander.to_source(ptr); 110 let src = self.expander.to_source(ptr);
113 self.source_map.expr_map.insert(src, id); 111 self.source_map.expr_map.insert(src, id);
@@ -277,7 +275,7 @@ where
277 ast::Expr::ParenExpr(e) => { 275 ast::Expr::ParenExpr(e) => {
278 let inner = self.collect_expr_opt(e.expr()); 276 let inner = self.collect_expr_opt(e.expr());
279 // make the paren expr point to the inner expression as well 277 // make the paren expr point to the inner expression as well
280 let src = self.expander.to_source(Either::A(syntax_ptr)); 278 let src = self.expander.to_source(Either::Left(syntax_ptr));
281 self.source_map.expr_map.insert(src, inner); 279 self.source_map.expr_map.insert(src, inner);
282 inner 280 inner
283 } 281 }
@@ -550,7 +548,7 @@ where
550 ast::Pat::SlicePat(_) | ast::Pat::RangePat(_) => Pat::Missing, 548 ast::Pat::SlicePat(_) | ast::Pat::RangePat(_) => Pat::Missing,
551 }; 549 };
552 let ptr = AstPtr::new(&pat); 550 let ptr = AstPtr::new(&pat);
553 self.alloc_pat(pattern, Either::A(ptr)) 551 self.alloc_pat(pattern, Either::Left(ptr))
554 } 552 }
555 553
556 fn collect_pat_opt(&mut self, pat: Option<ast::Pat>) -> PatId { 554 fn collect_pat_opt(&mut self, pat: Option<ast::Pat>) -> 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 @@
5 5
6use std::sync::Arc; 6use std::sync::Arc;
7 7
8use hir_expand::either::Either; 8use either::Either;
9use ra_syntax::ast; 9use ra_syntax::ast;
10 10
11use crate::{ 11use crate::{
@@ -46,8 +46,8 @@ impl Documentation {
46 AttrDefId::StructFieldId(it) => { 46 AttrDefId::StructFieldId(it) => {
47 let src = it.parent.child_source(db); 47 let src = it.parent.child_source(db);
48 match &src.value[it.local_id] { 48 match &src.value[it.local_id] {
49 Either::A(_tuple) => None, 49 Either::Left(_tuple) => None,
50 Either::B(record) => docs_from_ast(record), 50 Either::Right(record) => docs_from_ast(record),
51 } 51 }
52 } 52 }
53 AttrDefId::AdtId(it) => match it { 53 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;
57 57
58use std::sync::Arc; 58use std::sync::Arc;
59 59
60use either::Either;
60use hir_expand::{ 61use hir_expand::{
61 ast_id_map::FileAstId, diagnostics::DiagnosticSink, either::Either, name::Name, InFile, 62 ast_id_map::FileAstId, diagnostics::DiagnosticSink, name::Name, InFile, MacroDefId,
62 MacroDefId,
63}; 63};
64use once_cell::sync::Lazy; 64use once_cell::sync::Lazy;
65use ra_arena::Arena; 65use ra_arena::Arena;
@@ -287,10 +287,10 @@ impl ModuleData {
287 ) -> InFile<Either<ast::SourceFile, ast::Module>> { 287 ) -> InFile<Either<ast::SourceFile, ast::Module>> {
288 if let Some(file_id) = self.definition { 288 if let Some(file_id) = self.definition {
289 let sf = db.parse(file_id).tree(); 289 let sf = db.parse(file_id).tree();
290 return InFile::new(file_id.into(), Either::A(sf)); 290 return InFile::new(file_id.into(), Either::Left(sf));
291 } 291 }
292 let decl = self.declaration.unwrap(); 292 let decl = self.declaration.unwrap();
293 InFile::new(decl.file_id, Either::B(decl.to_node(db))) 293 InFile::new(decl.file_id, Either::Right(decl.to_node(db)))
294 } 294 }
295 295
296 /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. 296 /// 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 @@
7 7
8use std::{ops::Index, sync::Arc}; 8use std::{ops::Index, sync::Arc};
9 9
10use either::Either;
10use hir_expand::{ 11use hir_expand::{
11 ast_id_map::AstIdMap, 12 ast_id_map::AstIdMap,
12 db::AstDatabase, 13 db::AstDatabase,
13 either::Either,
14 hygiene::Hygiene, 14 hygiene::Hygiene,
15 name::{AsName, Name}, 15 name::{AsName, Name},
16}; 16};
@@ -324,7 +324,7 @@ impl RawItemsCollector {
324 is_extern_crate: false, 324 is_extern_crate: false,
325 is_macro_use: false, 325 is_macro_use: false,
326 }; 326 };
327 buf.push((import_data, Either::A(AstPtr::new(use_tree)))); 327 buf.push((import_data, Either::Left(AstPtr::new(use_tree))));
328 }, 328 },
329 ); 329 );
330 for (import_data, ptr) in buf { 330 for (import_data, ptr) in buf {
@@ -355,7 +355,7 @@ impl RawItemsCollector {
355 current_module, 355 current_module,
356 attrs, 356 attrs,
357 import_data, 357 import_data,
358 Either::B(AstPtr::new(&extern_crate)), 358 Either::Right(AstPtr::new(&extern_crate)),
359 ); 359 );
360 } 360 }
361 } 361 }
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 @@
2 2
3use std::{iter, sync::Arc}; 3use std::{iter, sync::Arc};
4 4
5use either::Either;
5use hir_expand::{ 6use hir_expand::{
6 either::Either,
7 hygiene::Hygiene, 7 hygiene::Hygiene,
8 name::{self, AsName, Name}, 8 name::{self, AsName, Name},
9}; 9};
@@ -111,7 +111,7 @@ impl Path {
111 ast::PathSegmentKind::Name(name_ref) => { 111 ast::PathSegmentKind::Name(name_ref) => {
112 // FIXME: this should just return name 112 // FIXME: this should just return name
113 match hygiene.name_ref_to_name(name_ref) { 113 match hygiene.name_ref_to_name(name_ref) {
114 Either::A(name) => { 114 Either::Left(name) => {
115 let args = segment 115 let args = segment
116 .type_arg_list() 116 .type_arg_list()
117 .and_then(GenericArgs::from_ast) 117 .and_then(GenericArgs::from_ast)
@@ -125,7 +125,7 @@ impl Path {
125 let segment = PathSegment { name, args_and_bindings: args }; 125 let segment = PathSegment { name, args_and_bindings: args };
126 segments.push(segment); 126 segments.push(segment);
127 } 127 }
128 Either::B(crate_id) => { 128 Either::Right(crate_id) => {
129 kind = PathKind::DollarCrate(crate_id); 129 kind = PathKind::DollarCrate(crate_id);
130 break; 130 break;
131 } 131 }
@@ -347,7 +347,7 @@ fn convert_path(prefix: Option<Path>, path: ast::Path, hygiene: &Hygiene) -> Opt
347 let res = match segment.kind()? { 347 let res = match segment.kind()? {
348 ast::PathSegmentKind::Name(name_ref) => { 348 ast::PathSegmentKind::Name(name_ref) => {
349 match hygiene.name_ref_to_name(name_ref) { 349 match hygiene.name_ref_to_name(name_ref) {
350 Either::A(name) => { 350 Either::Left(name) => {
351 // no type args in use 351 // no type args in use
352 let mut res = prefix.unwrap_or_else(|| Path { 352 let mut res = prefix.unwrap_or_else(|| Path {
353 kind: PathKind::Plain, 353 kind: PathKind::Plain,
@@ -359,7 +359,7 @@ fn convert_path(prefix: Option<Path>, path: ast::Path, hygiene: &Hygiene) -> Opt
359 }); 359 });
360 res 360 res
361 } 361 }
362 Either::B(crate_id) => { 362 Either::Right(crate_id) => {
363 return Some(Path::from_simple_segments( 363 return Some(Path::from_simple_segments(
364 PathKind::DollarCrate(crate_id), 364 PathKind::DollarCrate(crate_id),
365 iter::empty(), 365 iter::empty(),