aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-27 13:41:55 +0000
committerGitHub <[email protected]>2019-11-27 13:41:55 +0000
commit2798beeeb05ab0e71773a2ed51b7b0c90bf6b06a (patch)
tree55f1a6eddc328b20e3a4f71036d59a9573bfaa9c /crates/ra_hir/src/code_model.rs
parent35f57f35ec484422f06772ebe109c8fd28966ec5 (diff)
parent12501fcdd02fec9d43dfd810d65e927ddebb1b56 (diff)
Merge #2428
2428: Remove TypableDef r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r--crates/ra_hir/src/code_model.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 54da937ea..52ad4e5d1 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -534,14 +534,6 @@ impl VariantDef {
534 } 534 }
535 } 535 }
536 536
537 pub(crate) fn field(self, db: &impl HirDatabase, name: &Name) -> Option<StructField> {
538 match self {
539 VariantDef::Struct(it) => it.field(db, name),
540 VariantDef::Union(it) => it.field(db, name),
541 VariantDef::EnumVariant(it) => it.field(db, name),
542 }
543 }
544
545 pub fn module(self, db: &impl HirDatabase) -> Module { 537 pub fn module(self, db: &impl HirDatabase) -> Module {
546 match self { 538 match self {
547 VariantDef::Struct(it) => it.module(db), 539 VariantDef::Struct(it) => it.module(db),
@@ -618,7 +610,7 @@ impl Function {
618 } 610 }
619 611
620 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { 612 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
621 db.infer(self.into()) 613 db.infer(self.id.into())
622 } 614 }
623 615
624 /// The containing impl block, if this is a method. 616 /// The containing impl block, if this is a method.
@@ -647,7 +639,7 @@ impl Function {
647 639
648 pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) { 640 pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) {
649 let infer = self.infer(db); 641 let infer = self.infer(db);
650 infer.add_diagnostics(db, self, sink); 642 infer.add_diagnostics(db, self.id, sink);
651 let mut validator = ExprValidator::new(self, infer, sink); 643 let mut validator = ExprValidator::new(self, infer, sink);
652 validator.validate_body(db); 644 validator.validate_body(db);
653 } 645 }
@@ -672,7 +664,7 @@ impl Const {
672 } 664 }
673 665
674 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { 666 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
675 db.infer(self.into()) 667 db.infer(self.id.into())
676 } 668 }
677 669
678 /// The containing impl block, if this is a type alias. 670 /// The containing impl block, if this is a type alias.
@@ -715,7 +707,7 @@ impl Static {
715 } 707 }
716 708
717 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> { 709 pub fn infer(self, db: &impl HirDatabase) -> Arc<InferenceResult> {
718 db.infer(self.into()) 710 db.infer(self.id.into())
719 } 711 }
720} 712}
721 713
@@ -908,9 +900,9 @@ impl Local {
908 } 900 }
909 901
910 pub fn ty(self, db: &impl HirDatabase) -> Type { 902 pub fn ty(self, db: &impl HirDatabase) -> Type {
911 let infer = db.infer(self.parent);
912 let ty = infer[self.pat_id].clone();
913 let def = DefWithBodyId::from(self.parent); 903 let def = DefWithBodyId::from(self.parent);
904 let infer = db.infer(def);
905 let ty = infer[self.pat_id].clone();
914 let resolver = def.resolver(db); 906 let resolver = def.resolver(db);
915 let krate = def.module(db).krate; 907 let krate = def.module(db).krate;
916 let environment = TraitEnvironment::lower(db, &resolver); 908 let environment = TraitEnvironment::lower(db, &resolver);