aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/item_tree
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/item_tree')
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs
index 19d165b5b..df909ee9e 100644
--- a/crates/ra_hir_def/src/item_tree/lower.rs
+++ b/crates/ra_hir_def/src/item_tree/lower.rs
@@ -1,10 +1,7 @@
1//! AST -> `ItemTree` lowering code. 1//! AST -> `ItemTree` lowering code.
2 2
3use super::*; 3use std::{collections::hash_map::Entry, mem, sync::Arc};
4use crate::{ 4
5 attr::Attrs,
6 generics::{GenericParams, TypeParamData, TypeParamProvenance},
7};
8use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId}; 5use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId};
9use ra_arena::map::ArenaMap; 6use ra_arena::map::ArenaMap;
10use ra_syntax::{ 7use ra_syntax::{
@@ -12,7 +9,13 @@ use ra_syntax::{
12 SyntaxNode, 9 SyntaxNode,
13}; 10};
14use smallvec::SmallVec; 11use smallvec::SmallVec;
15use std::{collections::hash_map::Entry, mem, sync::Arc}; 12
13use crate::{
14 attr::Attrs,
15 generics::{GenericParams, TypeParamData, TypeParamProvenance},
16};
17
18use super::*;
16 19
17fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> { 20fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> {
18 FileItemTreeId { index, _p: PhantomData } 21 FileItemTreeId { index, _p: PhantomData }
@@ -191,7 +194,7 @@ impl Ctx {
191 } 194 }
192 } 195 }
193 196
194 fn lower_record_fields(&mut self, fields: &ast::RecordFieldDefList) -> IdRange<Field> { 197 fn lower_record_fields(&mut self, fields: &ast::RecordFieldList) -> IdRange<Field> {
195 let start = self.next_field_idx(); 198 let start = self.next_field_idx();
196 for field in fields.fields() { 199 for field in fields.fields() {
197 if let Some(data) = self.lower_record_field(&field) { 200 if let Some(data) = self.lower_record_field(&field) {
@@ -203,7 +206,7 @@ impl Ctx {
203 IdRange::new(start..end) 206 IdRange::new(start..end)
204 } 207 }
205 208
206 fn lower_record_field(&mut self, field: &ast::RecordFieldDef) -> Option<Field> { 209 fn lower_record_field(&mut self, field: &ast::RecordField) -> Option<Field> {
207 let name = field.name()?.as_name(); 210 let name = field.name()?.as_name();
208 let visibility = self.lower_visibility(field); 211 let visibility = self.lower_visibility(field);
209 let type_ref = self.lower_type_ref_opt(field.ascribed_type()); 212 let type_ref = self.lower_type_ref_opt(field.ascribed_type());
@@ -211,7 +214,7 @@ impl Ctx {
211 Some(res) 214 Some(res)
212 } 215 }
213 216
214 fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldDefList) -> IdRange<Field> { 217 fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldList) -> IdRange<Field> {
215 let start = self.next_field_idx(); 218 let start = self.next_field_idx();
216 for (i, field) in fields.fields().enumerate() { 219 for (i, field) in fields.fields().enumerate() {
217 let data = self.lower_tuple_field(i, &field); 220 let data = self.lower_tuple_field(i, &field);
@@ -222,7 +225,7 @@ impl Ctx {
222 IdRange::new(start..end) 225 IdRange::new(start..end)
223 } 226 }
224 227
225 fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleFieldDef) -> Field { 228 fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleField) -> Field {
226 let name = Name::new_tuple_field(idx); 229 let name = Name::new_tuple_field(idx);
227 let visibility = self.lower_visibility(field); 230 let visibility = self.lower_visibility(field);
228 let type_ref = self.lower_type_ref_opt(field.type_ref()); 231 let type_ref = self.lower_type_ref_opt(field.type_ref());
@@ -234,10 +237,8 @@ impl Ctx {
234 let visibility = self.lower_visibility(union); 237 let visibility = self.lower_visibility(union);
235 let name = union.name()?.as_name(); 238 let name = union.name()?.as_name();
236 let generic_params = self.lower_generic_params(GenericsOwner::Union, union); 239 let generic_params = self.lower_generic_params(GenericsOwner::Union, union);
237 let fields = match union.record_field_def_list() { 240 let fields = match union.record_field_list() {
238 Some(record_field_def_list) => { 241 Some(record_field_list) => self.lower_fields(&StructKind::Record(record_field_list)),
239 self.lower_fields(&StructKind::Record(record_field_def_list))
240 }
241 None => Fields::Record(IdRange::new(self.next_field_idx()..self.next_field_idx())), 242 None => Fields::Record(IdRange::new(self.next_field_idx()..self.next_field_idx())),
242 }; 243 };
243 let ast_id = self.source_ast_id_map.ast_id(union); 244 let ast_id = self.source_ast_id_map.ast_id(union);