aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/adt.rs2
-rw-r--r--crates/ra_hir/src/code_model.rs12
-rw-r--r--crates/ra_hir/src/code_model/src.rs4
-rw-r--r--crates/ra_hir/src/expr/scope.rs5
-rw-r--r--crates/ra_hir/src/from_source.rs10
-rw-r--r--crates/ra_hir/src/ty/lower.rs4
6 files changed, 18 insertions, 19 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs
index 0436d20b7..945f236c2 100644
--- a/crates/ra_hir/src/adt.rs
+++ b/crates/ra_hir/src/adt.rs
@@ -12,7 +12,7 @@ use crate::{
12 12
13impl Struct { 13impl Struct {
14 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { 14 pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
15 db.struct_data(self.id).variant_data.clone() 15 db.struct_data(self.id.into()).variant_data.clone()
16 } 16 }
17} 17}
18 18
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 9d0db8024..e5bfad3ca 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -288,7 +288,7 @@ pub struct Struct {
288 288
289impl Struct { 289impl Struct {
290 pub fn module(self, db: &impl DefDatabase) -> Module { 290 pub fn module(self, db: &impl DefDatabase) -> Module {
291 Module { id: self.id.module(db) } 291 Module { id: self.id.0.module(db) }
292 } 292 }
293 293
294 pub fn krate(self, db: &impl DefDatabase) -> Option<Crate> { 294 pub fn krate(self, db: &impl DefDatabase) -> Option<Crate> {
@@ -296,11 +296,11 @@ impl Struct {
296 } 296 }
297 297
298 pub fn name(self, db: &impl DefDatabase) -> Option<Name> { 298 pub fn name(self, db: &impl DefDatabase) -> Option<Name> {
299 db.struct_data(self.id).name.clone() 299 db.struct_data(self.id.into()).name.clone()
300 } 300 }
301 301
302 pub fn fields(self, db: &impl HirDatabase) -> Vec<StructField> { 302 pub fn fields(self, db: &impl HirDatabase) -> Vec<StructField> {
303 db.struct_data(self.id) 303 db.struct_data(self.id.into())
304 .variant_data 304 .variant_data
305 .fields() 305 .fields()
306 .into_iter() 306 .into_iter()
@@ -310,7 +310,7 @@ impl Struct {
310 } 310 }
311 311
312 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> { 312 pub fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
313 db.struct_data(self.id) 313 db.struct_data(self.id.into())
314 .variant_data 314 .variant_data
315 .fields() 315 .fields()
316 .into_iter() 316 .into_iter()
@@ -346,11 +346,11 @@ pub struct Union {
346 346
347impl Union { 347impl Union {
348 pub fn name(self, db: &impl DefDatabase) -> Option<Name> { 348 pub fn name(self, db: &impl DefDatabase) -> Option<Name> {
349 db.union_data(self.id).name.clone() 349 db.struct_data(self.id.into()).name.clone()
350 } 350 }
351 351
352 pub fn module(self, db: &impl HirDatabase) -> Module { 352 pub fn module(self, db: &impl HirDatabase) -> Module {
353 Module { id: self.id.module(db) } 353 Module { id: self.id.0.module(db) }
354 } 354 }
355 355
356 pub fn ty(self, db: &impl HirDatabase) -> Ty { 356 pub fn ty(self, db: &impl HirDatabase) -> Ty {
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs
index 6d116ee75..247ae3e55 100644
--- a/crates/ra_hir/src/code_model/src.rs
+++ b/crates/ra_hir/src/code_model/src.rs
@@ -78,13 +78,13 @@ impl HasSource for StructField {
78impl HasSource for Struct { 78impl HasSource for Struct {
79 type Ast = ast::StructDef; 79 type Ast = ast::StructDef;
80 fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::StructDef> { 80 fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::StructDef> {
81 self.id.source(db) 81 self.id.0.source(db)
82 } 82 }
83} 83}
84impl HasSource for Union { 84impl HasSource for Union {
85 type Ast = ast::StructDef; 85 type Ast = ast::StructDef;
86 fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::StructDef> { 86 fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::StructDef> {
87 self.id.source(db) 87 self.id.0.source(db)
88 } 88 }
89} 89}
90impl HasSource for Enum { 90impl HasSource for Enum {
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs
index c14c2ab66..5a1eade2c 100644
--- a/crates/ra_hir/src/expr/scope.rs
+++ b/crates/ra_hir/src/expr/scope.rs
@@ -67,10 +67,7 @@ impl ExprScopes {
67 &self.scopes[scope].entries 67 &self.scopes[scope].entries
68 } 68 }
69 69
70 pub(crate) fn scope_chain<'a>( 70 pub(crate) fn scope_chain(&self, scope: Option<ScopeId>) -> impl Iterator<Item = ScopeId> + '_ {
71 &'a self,
72 scope: Option<ScopeId>,
73 ) -> impl Iterator<Item = ScopeId> + 'a {
74 std::iter::successors(scope, move |&scope| self.scopes[scope].parent) 71 std::iter::successors(scope, move |&scope| self.scopes[scope].parent)
75 } 72 }
76 73
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs
index 9899bdbbc..c95d2cdd0 100644
--- a/crates/ra_hir/src/from_source.rs
+++ b/crates/ra_hir/src/from_source.rs
@@ -1,5 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir_def::{StructId, StructOrUnionId, UnionId};
3use hir_expand::name::AsName; 4use hir_expand::name::AsName;
4use ra_syntax::ast::{self, AstNode, NameOwner}; 5use ra_syntax::ast::{self, AstNode, NameOwner};
5 6
@@ -15,18 +16,19 @@ pub trait FromSource: Sized {
15 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self>; 16 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self>;
16} 17}
17 18
19// FIXIME: these two impls are wrong, `ast::StructDef` might produce either a struct or a union
18impl FromSource for Struct { 20impl FromSource for Struct {
19 type Ast = ast::StructDef; 21 type Ast = ast::StructDef;
20 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 22 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> {
21 let id = from_source(db, src)?; 23 let id: StructOrUnionId = from_source(db, src)?;
22 Some(Struct { id }) 24 Some(Struct { id: StructId(id) })
23 } 25 }
24} 26}
25impl FromSource for Union { 27impl FromSource for Union {
26 type Ast = ast::StructDef; 28 type Ast = ast::StructDef;
27 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 29 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> {
28 let id = from_source(db, src)?; 30 let id: StructOrUnionId = from_source(db, src)?;
29 Some(Union { id }) 31 Some(Union { id: UnionId(id) })
30 } 32 }
31} 33}
32impl FromSource for Enum { 34impl FromSource for Enum {
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index d26b16cb2..1fed5025e 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -665,7 +665,7 @@ fn type_for_builtin(def: BuiltinType) -> Ty {
665} 665}
666 666
667fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> FnSig { 667fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> FnSig {
668 let struct_data = db.struct_data(def.id); 668 let struct_data = db.struct_data(def.id.into());
669 let fields = match struct_data.variant_data.fields() { 669 let fields = match struct_data.variant_data.fields() {
670 Some(fields) => fields, 670 Some(fields) => fields,
671 None => panic!("fn_sig_for_struct_constructor called on unit struct"), 671 None => panic!("fn_sig_for_struct_constructor called on unit struct"),
@@ -681,7 +681,7 @@ fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> FnSig {
681 681
682/// Build the type of a tuple struct constructor. 682/// Build the type of a tuple struct constructor.
683fn type_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> Ty { 683fn type_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> Ty {
684 let struct_data = db.struct_data(def.id); 684 let struct_data = db.struct_data(def.id.into());
685 if struct_data.variant_data.fields().is_none() { 685 if struct_data.variant_data.fields().is_none() {
686 return type_for_adt(db, def); // Unit struct 686 return type_for_adt(db, def); // Unit struct
687 } 687 }