diff options
Diffstat (limited to 'crates/ra_hir_def/src/adt.rs')
-rw-r--r-- | crates/ra_hir_def/src/adt.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 753becc3d..8eef51828 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -12,9 +12,15 @@ use ra_prof::profile; | |||
12 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner, VisibilityOwner}; | 12 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner, VisibilityOwner}; |
13 | 13 | ||
14 | use crate::{ | 14 | use crate::{ |
15 | body::CfgExpander, db::DefDatabase, src::HasChildSource, src::HasSource, trace::Trace, | 15 | body::{CfgExpander, LowerCtx}, |
16 | type_ref::TypeRef, visibility::RawVisibility, EnumId, HasModule, LocalEnumVariantId, | 16 | db::DefDatabase, |
17 | LocalFieldId, Lookup, ModuleId, StructId, UnionId, VariantId, | 17 | src::HasChildSource, |
18 | src::HasSource, | ||
19 | trace::Trace, | ||
20 | type_ref::TypeRef, | ||
21 | visibility::RawVisibility, | ||
22 | EnumId, HasModule, LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StructId, UnionId, | ||
23 | VariantId, | ||
18 | }; | 24 | }; |
19 | 25 | ||
20 | /// Note that we use `StructData` for unions as well! | 26 | /// Note that we use `StructData` for unions as well! |
@@ -198,6 +204,8 @@ fn lower_struct( | |||
198 | trace: &mut Trace<FieldData, Either<ast::TupleFieldDef, ast::RecordFieldDef>>, | 204 | trace: &mut Trace<FieldData, Either<ast::TupleFieldDef, ast::RecordFieldDef>>, |
199 | ast: &InFile<ast::StructKind>, | 205 | ast: &InFile<ast::StructKind>, |
200 | ) -> StructKind { | 206 | ) -> StructKind { |
207 | let ctx = LowerCtx::new(db, ast.file_id); | ||
208 | |||
201 | match &ast.value { | 209 | match &ast.value { |
202 | ast::StructKind::Tuple(fl) => { | 210 | ast::StructKind::Tuple(fl) => { |
203 | for (i, fd) in fl.fields().enumerate() { | 211 | for (i, fd) in fl.fields().enumerate() { |
@@ -210,7 +218,7 @@ fn lower_struct( | |||
210 | || Either::Left(fd.clone()), | 218 | || Either::Left(fd.clone()), |
211 | || FieldData { | 219 | || FieldData { |
212 | name: Name::new_tuple_field(i), | 220 | name: Name::new_tuple_field(i), |
213 | type_ref: TypeRef::from_ast_opt(fd.type_ref()), | 221 | type_ref: TypeRef::from_ast_opt(&ctx, fd.type_ref()), |
214 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), | 222 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), |
215 | }, | 223 | }, |
216 | ); | 224 | ); |
@@ -228,7 +236,7 @@ fn lower_struct( | |||
228 | || Either::Right(fd.clone()), | 236 | || Either::Right(fd.clone()), |
229 | || FieldData { | 237 | || FieldData { |
230 | name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), | 238 | name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), |
231 | type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), | 239 | type_ref: TypeRef::from_ast_opt(&ctx, fd.ascribed_type()), |
232 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), | 240 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), |
233 | }, | 241 | }, |
234 | ); | 242 | ); |