diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-20 06:44:37 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-20 06:44:37 +0000 |
commit | 4dae39a609fb58b42cbe152e66d30fe6471a34d7 (patch) | |
tree | 166ee3c45f99611f7c20740c2a246f5b3bed41a3 /crates/ra_hir | |
parent | eec68e6f451ee7675ce2cb29b696df091e6aed13 (diff) | |
parent | 36e3fc9d5413f7e6e17e82867aae1318645880a3 (diff) |
Merge #2319
2319: Rename Source::ast -> Source::value r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model/attrs.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model/docs.rs | 24 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 24 | ||||
-rw-r--r-- | crates/ra_hir/src/diagnostics.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/from_source.rs | 38 | ||||
-rw-r--r-- | crates/ra_hir/src/generics.rs | 16 | ||||
-rw-r--r-- | crates/ra_hir/src/lang_item.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 24 | ||||
-rw-r--r-- | crates/ra_hir/src/traits.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/type_alias.rs | 2 |
13 files changed, 91 insertions, 89 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 731cc1fff..cb990f4e2 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -139,7 +139,7 @@ impl Module { | |||
139 | ) -> Either<ast::UseTree, ast::ExternCrateItem> { | 139 | ) -> Either<ast::UseTree, ast::ExternCrateItem> { |
140 | let src = self.definition_source(db); | 140 | let src = self.definition_source(db); |
141 | let (_, source_map) = db.raw_items_with_source_map(src.file_id); | 141 | let (_, source_map) = db.raw_items_with_source_map(src.file_id); |
142 | source_map.get(&src.ast, import) | 142 | source_map.get(&src.value, import) |
143 | } | 143 | } |
144 | 144 | ||
145 | /// Returns the crate this module is part of. | 145 | /// Returns the crate this module is part of. |
@@ -206,7 +206,7 @@ impl Module { | |||
206 | crate::ModuleDef::Function(f) => f.diagnostics(db, sink), | 206 | crate::ModuleDef::Function(f) => f.diagnostics(db, sink), |
207 | crate::ModuleDef::Module(m) => { | 207 | crate::ModuleDef::Module(m) => { |
208 | // Only add diagnostics from inline modules | 208 | // Only add diagnostics from inline modules |
209 | if let ModuleSource::Module(_) = m.definition_source(db).ast { | 209 | if let ModuleSource::Module(_) = m.definition_source(db).value { |
210 | m.diagnostics(db, sink) | 210 | m.diagnostics(db, sink) |
211 | } | 211 | } |
212 | } | 212 | } |
@@ -598,10 +598,10 @@ impl FnData { | |||
598 | func: Function, | 598 | func: Function, |
599 | ) -> Arc<FnData> { | 599 | ) -> Arc<FnData> { |
600 | let src = func.source(db); | 600 | let src = func.source(db); |
601 | let name = src.ast.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); | 601 | let name = src.value.name().map(|n| n.as_name()).unwrap_or_else(Name::missing); |
602 | let mut params = Vec::new(); | 602 | let mut params = Vec::new(); |
603 | let mut has_self_param = false; | 603 | let mut has_self_param = false; |
604 | if let Some(param_list) = src.ast.param_list() { | 604 | if let Some(param_list) = src.value.param_list() { |
605 | if let Some(self_param) = param_list.self_param() { | 605 | if let Some(self_param) = param_list.self_param() { |
606 | let self_type = if let Some(type_ref) = self_param.ascribed_type() { | 606 | let self_type = if let Some(type_ref) = self_param.ascribed_type() { |
607 | TypeRef::from_ast(type_ref) | 607 | TypeRef::from_ast(type_ref) |
@@ -625,7 +625,7 @@ impl FnData { | |||
625 | params.push(type_ref); | 625 | params.push(type_ref); |
626 | } | 626 | } |
627 | } | 627 | } |
628 | let ret_type = if let Some(type_ref) = src.ast.ret_type().and_then(|rt| rt.type_ref()) { | 628 | let ret_type = if let Some(type_ref) = src.value.ret_type().and_then(|rt| rt.type_ref()) { |
629 | TypeRef::from_ast(type_ref) | 629 | TypeRef::from_ast(type_ref) |
630 | } else { | 630 | } else { |
631 | TypeRef::unit() | 631 | TypeRef::unit() |
@@ -801,7 +801,7 @@ impl ConstData { | |||
801 | db: &(impl DefDatabase + AstDatabase), | 801 | db: &(impl DefDatabase + AstDatabase), |
802 | konst: Const, | 802 | konst: Const, |
803 | ) -> Arc<ConstData> { | 803 | ) -> Arc<ConstData> { |
804 | let node = konst.source(db).ast; | 804 | let node = konst.source(db).value; |
805 | const_data_for(&node) | 805 | const_data_for(&node) |
806 | } | 806 | } |
807 | 807 | ||
@@ -809,7 +809,7 @@ impl ConstData { | |||
809 | db: &(impl DefDatabase + AstDatabase), | 809 | db: &(impl DefDatabase + AstDatabase), |
810 | konst: Static, | 810 | konst: Static, |
811 | ) -> Arc<ConstData> { | 811 | ) -> Arc<ConstData> { |
812 | let node = konst.source(db).ast; | 812 | let node = konst.source(db).value; |
813 | const_data_for(&node) | 813 | const_data_for(&node) |
814 | } | 814 | } |
815 | } | 815 | } |
diff --git a/crates/ra_hir/src/code_model/attrs.rs b/crates/ra_hir/src/code_model/attrs.rs index f7db36b66..9e304217c 100644 --- a/crates/ra_hir/src/code_model/attrs.rs +++ b/crates/ra_hir/src/code_model/attrs.rs | |||
@@ -49,9 +49,9 @@ pub(crate) fn attributes_query( | |||
49 | AttrDef::Module(it) => { | 49 | AttrDef::Module(it) => { |
50 | let src = it.declaration_source(db)?; | 50 | let src = it.declaration_source(db)?; |
51 | let hygiene = Hygiene::new(db, src.file_id); | 51 | let hygiene = Hygiene::new(db, src.file_id); |
52 | Attr::from_attrs_owner(&src.ast, &hygiene) | 52 | Attr::from_attrs_owner(&src.value, &hygiene) |
53 | } | 53 | } |
54 | AttrDef::StructField(it) => match it.source(db).ast { | 54 | AttrDef::StructField(it) => match it.source(db).value { |
55 | FieldSource::Named(named) => { | 55 | FieldSource::Named(named) => { |
56 | let src = it.source(db); | 56 | let src = it.source(db); |
57 | let hygiene = Hygiene::new(db, src.file_id); | 57 | let hygiene = Hygiene::new(db, src.file_id); |
@@ -82,7 +82,7 @@ where | |||
82 | { | 82 | { |
83 | let src = node.source(db); | 83 | let src = node.source(db); |
84 | let hygiene = Hygiene::new(db, src.file_id); | 84 | let hygiene = Hygiene::new(db, src.file_id); |
85 | Attr::from_attrs_owner(&src.ast, &hygiene) | 85 | Attr::from_attrs_owner(&src.value, &hygiene) |
86 | } | 86 | } |
87 | 87 | ||
88 | impl<T: Into<AttrDef> + Copy> Attrs for T { | 88 | impl<T: Into<AttrDef> + Copy> Attrs for T { |
diff --git a/crates/ra_hir/src/code_model/docs.rs b/crates/ra_hir/src/code_model/docs.rs index 8533b4f5e..e40efef34 100644 --- a/crates/ra_hir/src/code_model/docs.rs +++ b/crates/ra_hir/src/code_model/docs.rs | |||
@@ -70,23 +70,23 @@ pub(crate) fn documentation_query( | |||
70 | def: DocDef, | 70 | def: DocDef, |
71 | ) -> Option<Documentation> { | 71 | ) -> Option<Documentation> { |
72 | match def { | 72 | match def { |
73 | DocDef::Module(it) => docs_from_ast(&it.declaration_source(db)?.ast), | 73 | DocDef::Module(it) => docs_from_ast(&it.declaration_source(db)?.value), |
74 | DocDef::StructField(it) => match it.source(db).ast { | 74 | DocDef::StructField(it) => match it.source(db).value { |
75 | FieldSource::Named(named) => docs_from_ast(&named), | 75 | FieldSource::Named(named) => docs_from_ast(&named), |
76 | FieldSource::Pos(..) => None, | 76 | FieldSource::Pos(..) => None, |
77 | }, | 77 | }, |
78 | DocDef::Adt(it) => match it { | 78 | DocDef::Adt(it) => match it { |
79 | Adt::Struct(it) => docs_from_ast(&it.source(db).ast), | 79 | Adt::Struct(it) => docs_from_ast(&it.source(db).value), |
80 | Adt::Enum(it) => docs_from_ast(&it.source(db).ast), | 80 | Adt::Enum(it) => docs_from_ast(&it.source(db).value), |
81 | Adt::Union(it) => docs_from_ast(&it.source(db).ast), | 81 | Adt::Union(it) => docs_from_ast(&it.source(db).value), |
82 | }, | 82 | }, |
83 | DocDef::EnumVariant(it) => docs_from_ast(&it.source(db).ast), | 83 | DocDef::EnumVariant(it) => docs_from_ast(&it.source(db).value), |
84 | DocDef::Static(it) => docs_from_ast(&it.source(db).ast), | 84 | DocDef::Static(it) => docs_from_ast(&it.source(db).value), |
85 | DocDef::Const(it) => docs_from_ast(&it.source(db).ast), | 85 | DocDef::Const(it) => docs_from_ast(&it.source(db).value), |
86 | DocDef::Function(it) => docs_from_ast(&it.source(db).ast), | 86 | DocDef::Function(it) => docs_from_ast(&it.source(db).value), |
87 | DocDef::Trait(it) => docs_from_ast(&it.source(db).ast), | 87 | DocDef::Trait(it) => docs_from_ast(&it.source(db).value), |
88 | DocDef::TypeAlias(it) => docs_from_ast(&it.source(db).ast), | 88 | DocDef::TypeAlias(it) => docs_from_ast(&it.source(db).value), |
89 | DocDef::MacroDef(it) => docs_from_ast(&it.source(db).ast), | 89 | DocDef::MacroDef(it) => docs_from_ast(&it.source(db).value), |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 247ae3e55..556417b0f 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -25,9 +25,9 @@ impl Module { | |||
25 | let def_map = db.crate_def_map(self.id.krate); | 25 | let def_map = db.crate_def_map(self.id.krate); |
26 | let decl_id = def_map[self.id.module_id].declaration; | 26 | let decl_id = def_map[self.id.module_id].declaration; |
27 | let file_id = def_map[self.id.module_id].definition; | 27 | let file_id = def_map[self.id.module_id].definition; |
28 | let ast = ModuleSource::new(db, file_id, decl_id); | 28 | let value = ModuleSource::new(db, file_id, decl_id); |
29 | let file_id = file_id.map(HirFileId::from).unwrap_or_else(|| decl_id.unwrap().file_id()); | 29 | let file_id = file_id.map(HirFileId::from).unwrap_or_else(|| decl_id.unwrap().file_id()); |
30 | Source { file_id, ast } | 30 | Source { file_id, value } |
31 | } | 31 | } |
32 | 32 | ||
33 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. | 33 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. |
@@ -38,8 +38,8 @@ impl Module { | |||
38 | ) -> Option<Source<ast::Module>> { | 38 | ) -> Option<Source<ast::Module>> { |
39 | let def_map = db.crate_def_map(self.id.krate); | 39 | let def_map = db.crate_def_map(self.id.krate); |
40 | let decl = def_map[self.id.module_id].declaration?; | 40 | let decl = def_map[self.id.module_id].declaration?; |
41 | let ast = decl.to_node(db); | 41 | let value = decl.to_node(db); |
42 | Some(Source { file_id: decl.file_id(), ast }) | 42 | Some(Source { file_id: decl.file_id(), value }) |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
@@ -53,11 +53,11 @@ impl HasSource for StructField { | |||
53 | let (file_id, struct_kind) = match self.parent { | 53 | let (file_id, struct_kind) = match self.parent { |
54 | VariantDef::Struct(s) => { | 54 | VariantDef::Struct(s) => { |
55 | ss = s.source(db); | 55 | ss = s.source(db); |
56 | (ss.file_id, ss.ast.kind()) | 56 | (ss.file_id, ss.value.kind()) |
57 | } | 57 | } |
58 | VariantDef::EnumVariant(e) => { | 58 | VariantDef::EnumVariant(e) => { |
59 | es = e.source(db); | 59 | es = e.source(db); |
60 | (es.file_id, es.ast.kind()) | 60 | (es.file_id, es.value.kind()) |
61 | } | 61 | } |
62 | }; | 62 | }; |
63 | 63 | ||
@@ -66,13 +66,13 @@ impl HasSource for StructField { | |||
66 | ast::StructKind::Named(fl) => fl.fields().map(|it| FieldSource::Named(it)).collect(), | 66 | ast::StructKind::Named(fl) => fl.fields().map(|it| FieldSource::Named(it)).collect(), |
67 | ast::StructKind::Unit => Vec::new(), | 67 | ast::StructKind::Unit => Vec::new(), |
68 | }; | 68 | }; |
69 | let ast = field_sources | 69 | let value = field_sources |
70 | .into_iter() | 70 | .into_iter() |
71 | .zip(fields.iter()) | 71 | .zip(fields.iter()) |
72 | .find(|(_syntax, (id, _))| *id == self.id) | 72 | .find(|(_syntax, (id, _))| *id == self.id) |
73 | .unwrap() | 73 | .unwrap() |
74 | .0; | 74 | .0; |
75 | Source { file_id, ast } | 75 | Source { file_id, value } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | impl HasSource for Struct { | 78 | impl HasSource for Struct { |
@@ -98,8 +98,8 @@ impl HasSource for EnumVariant { | |||
98 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::EnumVariant> { | 98 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::EnumVariant> { |
99 | let enum_data = db.enum_data(self.parent.id); | 99 | let enum_data = db.enum_data(self.parent.id); |
100 | let src = self.parent.id.source(db); | 100 | let src = self.parent.id.source(db); |
101 | let ast = src | 101 | let value = src |
102 | .ast | 102 | .value |
103 | .variant_list() | 103 | .variant_list() |
104 | .into_iter() | 104 | .into_iter() |
105 | .flat_map(|it| it.variants()) | 105 | .flat_map(|it| it.variants()) |
@@ -107,7 +107,7 @@ impl HasSource for EnumVariant { | |||
107 | .find(|(_syntax, (id, _))| *id == self.id) | 107 | .find(|(_syntax, (id, _))| *id == self.id) |
108 | .unwrap() | 108 | .unwrap() |
109 | .0; | 109 | .0; |
110 | Source { file_id: src.file_id, ast } | 110 | Source { file_id: src.file_id, value } |
111 | } | 111 | } |
112 | } | 112 | } |
113 | impl HasSource for Function { | 113 | impl HasSource for Function { |
@@ -143,7 +143,7 @@ impl HasSource for TypeAlias { | |||
143 | impl HasSource for MacroDef { | 143 | impl HasSource for MacroDef { |
144 | type Ast = ast::MacroCall; | 144 | type Ast = ast::MacroCall; |
145 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::MacroCall> { | 145 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::MacroCall> { |
146 | Source { file_id: self.id.ast_id.file_id(), ast: self.id.ast_id.to_node(db) } | 146 | Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) } |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs index 1751e7be3..7d1b64858 100644 --- a/crates/ra_hir/src/diagnostics.rs +++ b/crates/ra_hir/src/diagnostics.rs | |||
@@ -21,7 +21,7 @@ impl Diagnostic for NoSuchField { | |||
21 | } | 21 | } |
22 | 22 | ||
23 | fn source(&self) -> Source<SyntaxNodePtr> { | 23 | fn source(&self) -> Source<SyntaxNodePtr> { |
24 | Source { file_id: self.file, ast: self.field.into() } | 24 | Source { file_id: self.file, value: self.field.into() } |
25 | } | 25 | } |
26 | 26 | ||
27 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | 27 | fn as_any(&self) -> &(dyn Any + Send + 'static) { |
@@ -41,7 +41,7 @@ impl Diagnostic for MissingFields { | |||
41 | "fill structure fields".to_string() | 41 | "fill structure fields".to_string() |
42 | } | 42 | } |
43 | fn source(&self) -> Source<SyntaxNodePtr> { | 43 | fn source(&self) -> Source<SyntaxNodePtr> { |
44 | Source { file_id: self.file, ast: self.field_list.into() } | 44 | Source { file_id: self.file, value: self.field_list.into() } |
45 | } | 45 | } |
46 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | 46 | fn as_any(&self) -> &(dyn Any + Send + 'static) { |
47 | self | 47 | self |
@@ -53,7 +53,7 @@ impl AstDiagnostic for MissingFields { | |||
53 | 53 | ||
54 | fn ast(&self, db: &impl AstDatabase) -> Self::AST { | 54 | fn ast(&self, db: &impl AstDatabase) -> Self::AST { |
55 | let root = db.parse_or_expand(self.source().file_id).unwrap(); | 55 | let root = db.parse_or_expand(self.source().file_id).unwrap(); |
56 | let node = self.source().ast.to_node(&root); | 56 | let node = self.source().value.to_node(&root); |
57 | ast::RecordFieldList::cast(node).unwrap() | 57 | ast::RecordFieldList::cast(node).unwrap() |
58 | } | 58 | } |
59 | } | 59 | } |
@@ -69,7 +69,7 @@ impl Diagnostic for MissingOkInTailExpr { | |||
69 | "wrap return expression in Ok".to_string() | 69 | "wrap return expression in Ok".to_string() |
70 | } | 70 | } |
71 | fn source(&self) -> Source<SyntaxNodePtr> { | 71 | fn source(&self) -> Source<SyntaxNodePtr> { |
72 | Source { file_id: self.file, ast: self.expr.into() } | 72 | Source { file_id: self.file, value: self.expr.into() } |
73 | } | 73 | } |
74 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | 74 | fn as_any(&self) -> &(dyn Any + Send + 'static) { |
75 | self | 75 | self |
@@ -81,7 +81,7 @@ impl AstDiagnostic for MissingOkInTailExpr { | |||
81 | 81 | ||
82 | fn ast(&self, db: &impl AstDatabase) -> Self::AST { | 82 | fn ast(&self, db: &impl AstDatabase) -> Self::AST { |
83 | let root = db.parse_or_expand(self.file).unwrap(); | 83 | let root = db.parse_or_expand(self.file).unwrap(); |
84 | let node = self.source().ast.to_node(&root); | 84 | let node = self.source().value.to_node(&root); |
85 | ast::Expr::cast(node).unwrap() | 85 | ast::Expr::cast(node).unwrap() |
86 | } | 86 | } |
87 | } | 87 | } |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index e3733779e..8bfdda45e 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -116,7 +116,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
116 | let source_map = self.func.body_source_map(db); | 116 | let source_map = self.func.body_source_map(db); |
117 | 117 | ||
118 | if let Some(source_ptr) = source_map.expr_syntax(id) { | 118 | if let Some(source_ptr) = source_map.expr_syntax(id) { |
119 | if let Some(expr) = source_ptr.ast.a() { | 119 | if let Some(expr) = source_ptr.value.a() { |
120 | let root = source_ptr.file_syntax(db); | 120 | let root = source_ptr.file_syntax(db); |
121 | if let ast::Expr::RecordLit(record_lit) = expr.to_node(&root) { | 121 | if let ast::Expr::RecordLit(record_lit) = expr.to_node(&root) { |
122 | if let Some(field_list) = record_lit.record_field_list() { | 122 | if let Some(field_list) = record_lit.record_field_list() { |
@@ -161,7 +161,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
161 | let source_map = self.func.body_source_map(db); | 161 | let source_map = self.func.body_source_map(db); |
162 | 162 | ||
163 | if let Some(source_ptr) = source_map.expr_syntax(id) { | 163 | if let Some(source_ptr) = source_map.expr_syntax(id) { |
164 | if let Some(expr) = source_ptr.ast.a() { | 164 | if let Some(expr) = source_ptr.value.a() { |
165 | self.sink.push(MissingOkInTailExpr { file: source_ptr.file_id, expr }); | 165 | self.sink.push(MissingOkInTailExpr { file: source_ptr.file_id, expr }); |
166 | } | 166 | } |
167 | } | 167 | } |
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 1c26756c9..f4dca25cb 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs | |||
@@ -87,7 +87,7 @@ impl FromSource for MacroDef { | |||
87 | let module = Module::from_definition(db, Source::new(src.file_id, module_src))?; | 87 | let module = Module::from_definition(db, Source::new(src.file_id, module_src))?; |
88 | let krate = module.krate().crate_id(); | 88 | let krate = module.krate().crate_id(); |
89 | 89 | ||
90 | let ast_id = AstId::new(src.file_id, db.ast_id_map(src.file_id).ast_id(&src.ast)); | 90 | let ast_id = AstId::new(src.file_id, db.ast_id_map(src.file_id).ast_id(&src.value)); |
91 | 91 | ||
92 | let id: MacroDefId = MacroDefId { krate, ast_id, kind }; | 92 | let id: MacroDefId = MacroDefId { krate, ast_id, kind }; |
93 | Some(MacroDef { id }) | 93 | Some(MacroDef { id }) |
@@ -105,8 +105,8 @@ impl FromSource for ImplBlock { | |||
105 | impl FromSource for EnumVariant { | 105 | impl FromSource for EnumVariant { |
106 | type Ast = ast::EnumVariant; | 106 | type Ast = ast::EnumVariant; |
107 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { | 107 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { |
108 | let parent_enum = src.ast.parent_enum(); | 108 | let parent_enum = src.value.parent_enum(); |
109 | let src_enum = Source { file_id: src.file_id, ast: parent_enum }; | 109 | let src_enum = Source { file_id: src.file_id, value: parent_enum }; |
110 | let variants = Enum::from_source(db, src_enum)?.variants(db); | 110 | let variants = Enum::from_source(db, src_enum)?.variants(db); |
111 | variants.into_iter().find(|v| v.source(db) == src) | 111 | variants.into_iter().find(|v| v.source(db) == src) |
112 | } | 112 | } |
@@ -115,16 +115,16 @@ impl FromSource for EnumVariant { | |||
115 | impl FromSource for StructField { | 115 | impl FromSource for StructField { |
116 | type Ast = FieldSource; | 116 | type Ast = FieldSource; |
117 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { | 117 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { |
118 | let variant_def: VariantDef = match src.ast { | 118 | let variant_def: VariantDef = match src.value { |
119 | FieldSource::Named(ref field) => { | 119 | FieldSource::Named(ref field) => { |
120 | let ast = field.syntax().ancestors().find_map(ast::StructDef::cast)?; | 120 | let value = field.syntax().ancestors().find_map(ast::StructDef::cast)?; |
121 | let src = Source { file_id: src.file_id, ast }; | 121 | let src = Source { file_id: src.file_id, value }; |
122 | let def = Struct::from_source(db, src)?; | 122 | let def = Struct::from_source(db, src)?; |
123 | VariantDef::from(def) | 123 | VariantDef::from(def) |
124 | } | 124 | } |
125 | FieldSource::Pos(ref field) => { | 125 | FieldSource::Pos(ref field) => { |
126 | let ast = field.syntax().ancestors().find_map(ast::EnumVariant::cast)?; | 126 | let value = field.syntax().ancestors().find_map(ast::EnumVariant::cast)?; |
127 | let src = Source { file_id: src.file_id, ast }; | 127 | let src = Source { file_id: src.file_id, value }; |
128 | let def = EnumVariant::from_source(db, src)?; | 128 | let def = EnumVariant::from_source(db, src)?; |
129 | VariantDef::from(def) | 129 | VariantDef::from(def) |
130 | } | 130 | } |
@@ -142,12 +142,12 @@ impl FromSource for StructField { | |||
142 | impl Local { | 142 | impl Local { |
143 | pub fn from_source(db: &impl HirDatabase, src: Source<ast::BindPat>) -> Option<Self> { | 143 | pub fn from_source(db: &impl HirDatabase, src: Source<ast::BindPat>) -> Option<Self> { |
144 | let file_id = src.file_id; | 144 | let file_id = src.file_id; |
145 | let parent: DefWithBody = src.ast.syntax().ancestors().find_map(|it| { | 145 | let parent: DefWithBody = src.value.syntax().ancestors().find_map(|it| { |
146 | let res = match_ast! { | 146 | let res = match_ast! { |
147 | match it { | 147 | match it { |
148 | ast::ConstDef(ast) => { Const::from_source(db, Source { ast, file_id})?.into() }, | 148 | ast::ConstDef(value) => { Const::from_source(db, Source { value, file_id})?.into() }, |
149 | ast::StaticDef(ast) => { Static::from_source(db, Source { ast, file_id})?.into() }, | 149 | ast::StaticDef(value) => { Static::from_source(db, Source { value, file_id})?.into() }, |
150 | ast::FnDef(ast) => { Function::from_source(db, Source { ast, file_id})?.into() }, | 150 | ast::FnDef(value) => { Function::from_source(db, Source { value, file_id})?.into() }, |
151 | _ => return None, | 151 | _ => return None, |
152 | } | 152 | } |
153 | }; | 153 | }; |
@@ -162,33 +162,33 @@ impl Local { | |||
162 | 162 | ||
163 | impl Module { | 163 | impl Module { |
164 | pub fn from_declaration(db: &impl DefDatabase, src: Source<ast::Module>) -> Option<Self> { | 164 | pub fn from_declaration(db: &impl DefDatabase, src: Source<ast::Module>) -> Option<Self> { |
165 | let parent_declaration = src.ast.syntax().ancestors().skip(1).find_map(ast::Module::cast); | 165 | let parent_declaration = src.value.syntax().ancestors().skip(1).find_map(ast::Module::cast); |
166 | 166 | ||
167 | let parent_module = match parent_declaration { | 167 | let parent_module = match parent_declaration { |
168 | Some(parent_declaration) => { | 168 | Some(parent_declaration) => { |
169 | let src_parent = Source { file_id: src.file_id, ast: parent_declaration }; | 169 | let src_parent = Source { file_id: src.file_id, value: parent_declaration }; |
170 | Module::from_declaration(db, src_parent) | 170 | Module::from_declaration(db, src_parent) |
171 | } | 171 | } |
172 | _ => { | 172 | _ => { |
173 | let src_parent = Source { | 173 | let src_parent = Source { |
174 | file_id: src.file_id, | 174 | file_id: src.file_id, |
175 | ast: ModuleSource::new(db, Some(src.file_id.original_file(db)), None), | 175 | value: ModuleSource::new(db, Some(src.file_id.original_file(db)), None), |
176 | }; | 176 | }; |
177 | Module::from_definition(db, src_parent) | 177 | Module::from_definition(db, src_parent) |
178 | } | 178 | } |
179 | }?; | 179 | }?; |
180 | 180 | ||
181 | let child_name = src.ast.name()?; | 181 | let child_name = src.value.name()?; |
182 | parent_module.child(db, &child_name.as_name()) | 182 | parent_module.child(db, &child_name.as_name()) |
183 | } | 183 | } |
184 | 184 | ||
185 | pub fn from_definition(db: &impl DefDatabase, src: Source<ModuleSource>) -> Option<Self> { | 185 | pub fn from_definition(db: &impl DefDatabase, src: Source<ModuleSource>) -> Option<Self> { |
186 | match src.ast { | 186 | match src.value { |
187 | ModuleSource::Module(ref module) => { | 187 | ModuleSource::Module(ref module) => { |
188 | assert!(!module.has_semi()); | 188 | assert!(!module.has_semi()); |
189 | return Module::from_declaration( | 189 | return Module::from_declaration( |
190 | db, | 190 | db, |
191 | Source { file_id: src.file_id, ast: module.clone() }, | 191 | Source { file_id: src.file_id, value: module.clone() }, |
192 | ); | 192 | ); |
193 | } | 193 | } |
194 | ModuleSource::SourceFile(_) => (), | 194 | ModuleSource::SourceFile(_) => (), |
@@ -214,5 +214,5 @@ where | |||
214 | let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax())); | 214 | let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax())); |
215 | let module = Module::from_definition(db, Source::new(src.file_id, module_src))?; | 215 | let module = Module::from_definition(db, Source::new(src.file_id, module_src))?; |
216 | let ctx = LocationCtx::new(db, module.id, src.file_id); | 216 | let ctx = LocationCtx::new(db, module.id, src.file_id); |
217 | Some(DEF::from_ast(ctx, &src.ast)) | 217 | Some(DEF::from_ast(ctx, &src.value)) |
218 | } | 218 | } |
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs index c35482ae8..8925ba3a9 100644 --- a/crates/ra_hir/src/generics.rs +++ b/crates/ra_hir/src/generics.rs | |||
@@ -91,10 +91,10 @@ impl GenericParams { | |||
91 | let start = generics.parent_params.as_ref().map(|p| p.params.len()).unwrap_or(0) as u32; | 91 | let start = generics.parent_params.as_ref().map(|p| p.params.len()).unwrap_or(0) as u32; |
92 | // FIXME: add `: Sized` bound for everything except for `Self` in traits | 92 | // FIXME: add `: Sized` bound for everything except for `Self` in traits |
93 | match def { | 93 | match def { |
94 | GenericDef::Function(it) => generics.fill(&it.source(db).ast, start), | 94 | GenericDef::Function(it) => generics.fill(&it.source(db).value, start), |
95 | GenericDef::Adt(Adt::Struct(it)) => generics.fill(&it.source(db).ast, start), | 95 | GenericDef::Adt(Adt::Struct(it)) => generics.fill(&it.source(db).value, start), |
96 | GenericDef::Adt(Adt::Union(it)) => generics.fill(&it.source(db).ast, start), | 96 | GenericDef::Adt(Adt::Union(it)) => generics.fill(&it.source(db).value, start), |
97 | GenericDef::Adt(Adt::Enum(it)) => generics.fill(&it.source(db).ast, start), | 97 | GenericDef::Adt(Adt::Enum(it)) => generics.fill(&it.source(db).value, start), |
98 | GenericDef::Trait(it) => { | 98 | GenericDef::Trait(it) => { |
99 | // traits get the Self type as an implicit first type parameter | 99 | // traits get the Self type as an implicit first type parameter |
100 | generics.params.push(GenericParam { | 100 | generics.params.push(GenericParam { |
@@ -102,17 +102,17 @@ impl GenericParams { | |||
102 | name: name::SELF_TYPE, | 102 | name: name::SELF_TYPE, |
103 | default: None, | 103 | default: None, |
104 | }); | 104 | }); |
105 | generics.fill(&it.source(db).ast, start + 1); | 105 | generics.fill(&it.source(db).value, start + 1); |
106 | // add super traits as bounds on Self | 106 | // add super traits as bounds on Self |
107 | // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar | 107 | // i.e., trait Foo: Bar is equivalent to trait Foo where Self: Bar |
108 | let self_param = TypeRef::Path(name::SELF_TYPE.into()); | 108 | let self_param = TypeRef::Path(name::SELF_TYPE.into()); |
109 | generics.fill_bounds(&it.source(db).ast, self_param); | 109 | generics.fill_bounds(&it.source(db).value, self_param); |
110 | } | 110 | } |
111 | GenericDef::TypeAlias(it) => generics.fill(&it.source(db).ast, start), | 111 | GenericDef::TypeAlias(it) => generics.fill(&it.source(db).value, start), |
112 | // Note that we don't add `Self` here: in `impl`s, `Self` is not a | 112 | // Note that we don't add `Self` here: in `impl`s, `Self` is not a |
113 | // type-parameter, but rather is a type-alias for impl's target | 113 | // type-parameter, but rather is a type-alias for impl's target |
114 | // type, so this is handled by the resolver. | 114 | // type, so this is handled by the resolver. |
115 | GenericDef::ImplBlock(it) => generics.fill(&it.source(db).ast, start), | 115 | GenericDef::ImplBlock(it) => generics.fill(&it.source(db).value, start), |
116 | GenericDef::EnumVariant(_) | GenericDef::Const(_) => {} | 116 | GenericDef::EnumVariant(_) | GenericDef::Const(_) => {} |
117 | } | 117 | } |
118 | 118 | ||
diff --git a/crates/ra_hir/src/lang_item.rs b/crates/ra_hir/src/lang_item.rs index fa2ef8a17..89fd85f59 100644 --- a/crates/ra_hir/src/lang_item.rs +++ b/crates/ra_hir/src/lang_item.rs | |||
@@ -97,7 +97,7 @@ impl LangItems { | |||
97 | // Look for impl targets | 97 | // Look for impl targets |
98 | for impl_block in module.impl_blocks(db) { | 98 | for impl_block in module.impl_blocks(db) { |
99 | let src = impl_block.source(db); | 99 | let src = impl_block.source(db); |
100 | if let Some(lang_item_name) = lang_item_name(&src.ast) { | 100 | if let Some(lang_item_name) = lang_item_name(&src.value) { |
101 | self.items | 101 | self.items |
102 | .entry(lang_item_name) | 102 | .entry(lang_item_name) |
103 | .or_insert_with(|| LangItemTarget::ImplBlock(impl_block)); | 103 | .or_insert_with(|| LangItemTarget::ImplBlock(impl_block)); |
@@ -144,7 +144,7 @@ impl LangItems { | |||
144 | T: Copy + HasSource<Ast = N>, | 144 | T: Copy + HasSource<Ast = N>, |
145 | N: AttrsOwner, | 145 | N: AttrsOwner, |
146 | { | 146 | { |
147 | let node = item.source(db).ast; | 147 | let node = item.source(db).value; |
148 | if let Some(lang_item_name) = lang_item_name(&node) { | 148 | if let Some(lang_item_name) = lang_item_name(&node) { |
149 | self.items.entry(lang_item_name).or_insert_with(|| constructor(item)); | 149 | self.items.entry(lang_item_name).or_insert_with(|| constructor(item)); |
150 | } | 150 | } |
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 5d3196c2a..471b0b089 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -31,7 +31,7 @@ use crate::{ | |||
31 | 31 | ||
32 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { | 32 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { |
33 | match_ast! { | 33 | match_ast! { |
34 | match (node.ast) { | 34 | match (node.value) { |
35 | ast::Module(it) => { | 35 | ast::Module(it) => { |
36 | let src = node.with_ast(it); | 36 | let src = node.with_ast(it); |
37 | Some(crate::Module::from_declaration(db, src)?.resolver(db)) | 37 | Some(crate::Module::from_declaration(db, src)?.resolver(db)) |
@@ -48,7 +48,7 @@ fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) - | |||
48 | let src = node.with_ast(it); | 48 | let src = node.with_ast(it); |
49 | Some(Enum::from_source(db, src)?.resolver(db)) | 49 | Some(Enum::from_source(db, src)?.resolver(db)) |
50 | }, | 50 | }, |
51 | _ => match node.ast.kind() { | 51 | _ => match node.value.kind() { |
52 | FN_DEF | CONST_DEF | STATIC_DEF => { | 52 | FN_DEF | CONST_DEF | STATIC_DEF => { |
53 | Some(def_with_body_from_child_node(db, node)?.resolver(db)) | 53 | Some(def_with_body_from_child_node(db, node)?.resolver(db)) |
54 | } | 54 | } |
@@ -67,7 +67,7 @@ fn def_with_body_from_child_node( | |||
67 | let module = Module::from_definition(db, Source::new(child.file_id, module_source))?; | 67 | let module = Module::from_definition(db, Source::new(child.file_id, module_source))?; |
68 | let ctx = LocationCtx::new(db, module.id, child.file_id); | 68 | let ctx = LocationCtx::new(db, module.id, child.file_id); |
69 | 69 | ||
70 | child.ast.ancestors().find_map(|node| { | 70 | child.value.ancestors().find_map(|node| { |
71 | match_ast! { | 71 | match_ast! { |
72 | match node { | 72 | match node { |
73 | ast::FnDef(def) => { Some(Function {id: ctx.to_def(&def) }.into()) }, | 73 | ast::FnDef(def) => { Some(Function {id: ctx.to_def(&def) }.into()) }, |
@@ -171,7 +171,7 @@ impl SourceAnalyzer { | |||
171 | } else { | 171 | } else { |
172 | SourceAnalyzer { | 172 | SourceAnalyzer { |
173 | resolver: node | 173 | resolver: node |
174 | .ast | 174 | .value |
175 | .ancestors() | 175 | .ancestors() |
176 | .find_map(|it| try_get_resolver_for_node(db, node.with_ast(&it))) | 176 | .find_map(|it| try_get_resolver_for_node(db, node.with_ast(&it))) |
177 | .unwrap_or_default(), | 177 | .unwrap_or_default(), |
@@ -185,12 +185,12 @@ impl SourceAnalyzer { | |||
185 | } | 185 | } |
186 | 186 | ||
187 | fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> { | 187 | fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> { |
188 | let src = Source { file_id: self.file_id, ast: expr }; | 188 | let src = Source { file_id: self.file_id, value: expr }; |
189 | self.body_source_map.as_ref()?.node_expr(src) | 189 | self.body_source_map.as_ref()?.node_expr(src) |
190 | } | 190 | } |
191 | 191 | ||
192 | fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> { | 192 | fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> { |
193 | let src = Source { file_id: self.file_id, ast: pat }; | 193 | let src = Source { file_id: self.file_id, value: pat }; |
194 | self.body_source_map.as_ref()?.node_pat(src) | 194 | self.body_source_map.as_ref()?.node_pat(src) |
195 | } | 195 | } |
196 | 196 | ||
@@ -302,7 +302,7 @@ impl SourceAnalyzer { | |||
302 | let entry = scopes.resolve_name_in_scope(scope, &name)?; | 302 | let entry = scopes.resolve_name_in_scope(scope, &name)?; |
303 | Some(ScopeEntryWithSyntax { | 303 | Some(ScopeEntryWithSyntax { |
304 | name: entry.name().clone(), | 304 | name: entry.name().clone(), |
305 | ptr: source_map.pat_syntax(entry.pat())?.ast, | 305 | ptr: source_map.pat_syntax(entry.pat())?.value, |
306 | }) | 306 | }) |
307 | } | 307 | } |
308 | 308 | ||
@@ -428,7 +428,7 @@ fn scope_for( | |||
428 | source_map: &BodySourceMap, | 428 | source_map: &BodySourceMap, |
429 | node: Source<&SyntaxNode>, | 429 | node: Source<&SyntaxNode>, |
430 | ) -> Option<ScopeId> { | 430 | ) -> Option<ScopeId> { |
431 | node.ast | 431 | node.value |
432 | .ancestors() | 432 | .ancestors() |
433 | .filter_map(ast::Expr::cast) | 433 | .filter_map(ast::Expr::cast) |
434 | .filter_map(|it| source_map.node_expr(Source::new(node.file_id, &it))) | 434 | .filter_map(|it| source_map.node_expr(Source::new(node.file_id, &it))) |
@@ -450,18 +450,18 @@ fn scope_for_offset( | |||
450 | return None; | 450 | return None; |
451 | } | 451 | } |
452 | let syntax_node_ptr = | 452 | let syntax_node_ptr = |
453 | source.ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); | 453 | source.value.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); |
454 | Some((syntax_node_ptr, scope)) | 454 | Some((syntax_node_ptr, scope)) |
455 | }) | 455 | }) |
456 | // find containing scope | 456 | // find containing scope |
457 | .min_by_key(|(ptr, _scope)| { | 457 | .min_by_key(|(ptr, _scope)| { |
458 | ( | 458 | ( |
459 | !(ptr.range().start() <= offset.ast && offset.ast <= ptr.range().end()), | 459 | !(ptr.range().start() <= offset.value && offset.value <= ptr.range().end()), |
460 | ptr.range().len(), | 460 | ptr.range().len(), |
461 | ) | 461 | ) |
462 | }) | 462 | }) |
463 | .map(|(ptr, scope)| { | 463 | .map(|(ptr, scope)| { |
464 | adjust(scopes, source_map, ptr, offset.file_id, offset.ast).unwrap_or(*scope) | 464 | adjust(scopes, source_map, ptr, offset.file_id, offset.value).unwrap_or(*scope) |
465 | }) | 465 | }) |
466 | } | 466 | } |
467 | 467 | ||
@@ -485,7 +485,7 @@ fn adjust( | |||
485 | return None; | 485 | return None; |
486 | } | 486 | } |
487 | let syntax_node_ptr = | 487 | let syntax_node_ptr = |
488 | source.ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); | 488 | source.value.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); |
489 | Some((syntax_node_ptr, scope)) | 489 | Some((syntax_node_ptr, scope)) |
490 | }) | 490 | }) |
491 | .map(|(ptr, scope)| (ptr.range(), scope)) | 491 | .map(|(ptr, scope)| (ptr.range(), scope)) |
diff --git a/crates/ra_hir/src/traits.rs b/crates/ra_hir/src/traits.rs index 1a45dacba..858972c6f 100644 --- a/crates/ra_hir/src/traits.rs +++ b/crates/ra_hir/src/traits.rs | |||
@@ -26,11 +26,11 @@ impl TraitData { | |||
26 | tr: Trait, | 26 | tr: Trait, |
27 | ) -> Arc<TraitData> { | 27 | ) -> Arc<TraitData> { |
28 | let src = tr.source(db); | 28 | let src = tr.source(db); |
29 | let name = src.ast.name().map(|n| n.as_name()); | 29 | let name = src.value.name().map(|n| n.as_name()); |
30 | let module = tr.module(db); | 30 | let module = tr.module(db); |
31 | let ctx = LocationCtx::new(db, module.id, src.file_id); | 31 | let ctx = LocationCtx::new(db, module.id, src.file_id); |
32 | let auto = src.ast.is_auto(); | 32 | let auto = src.value.is_auto(); |
33 | let items = if let Some(item_list) = src.ast.item_list() { | 33 | let items = if let Some(item_list) = src.value.item_list() { |
34 | item_list | 34 | item_list |
35 | .impl_items() | 35 | .impl_items() |
36 | .map(|item_node| match item_node { | 36 | .map(|item_node| match item_node { |
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index ca1693679..c1024d03c 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -4694,14 +4694,16 @@ fn infer(content: &str) -> String { | |||
4694 | } | 4694 | } |
4695 | 4695 | ||
4696 | // sort ranges for consistency | 4696 | // sort ranges for consistency |
4697 | types.sort_by_key(|(src_ptr, _)| (src_ptr.ast.range().start(), src_ptr.ast.range().end())); | 4697 | types.sort_by_key(|(src_ptr, _)| { |
4698 | (src_ptr.value.range().start(), src_ptr.value.range().end()) | ||
4699 | }); | ||
4698 | for (src_ptr, ty) in &types { | 4700 | for (src_ptr, ty) in &types { |
4699 | let node = src_ptr.ast.to_node(&src_ptr.file_syntax(&db)); | 4701 | let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db)); |
4700 | 4702 | ||
4701 | let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) { | 4703 | let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) { |
4702 | (self_param.self_kw_token().text_range(), "self".to_string()) | 4704 | (self_param.self_kw_token().text_range(), "self".to_string()) |
4703 | } else { | 4705 | } else { |
4704 | (src_ptr.ast.range(), node.text().to_string().replace("\n", " ")) | 4706 | (src_ptr.value.range(), node.text().to_string().replace("\n", " ")) |
4705 | }; | 4707 | }; |
4706 | let macro_prefix = if src_ptr.file_id != file_id.into() { "!" } else { "" }; | 4708 | let macro_prefix = if src_ptr.file_id != file_id.into() { "!" } else { "" }; |
4707 | write!( | 4709 | write!( |
diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir/src/type_alias.rs index 078e6295e..392f244cf 100644 --- a/crates/ra_hir/src/type_alias.rs +++ b/crates/ra_hir/src/type_alias.rs | |||
@@ -23,7 +23,7 @@ impl TypeAliasData { | |||
23 | db: &(impl DefDatabase + AstDatabase), | 23 | db: &(impl DefDatabase + AstDatabase), |
24 | typ: TypeAlias, | 24 | typ: TypeAlias, |
25 | ) -> Arc<TypeAliasData> { | 25 | ) -> Arc<TypeAliasData> { |
26 | let node = typ.source(db).ast; | 26 | let node = typ.source(db).value; |
27 | let name = node.name().map_or_else(Name::missing, |n| n.as_name()); | 27 | let name = node.name().map_or_else(Name::missing, |n| n.as_name()); |
28 | let type_ref = node.type_ref().map(TypeRef::from_ast); | 28 | let type_ref = node.type_ref().map(TypeRef::from_ast); |
29 | Arc::new(TypeAliasData { name, type_ref }) | 29 | Arc::new(TypeAliasData { name, type_ref }) |