diff options
author | Florian Diebold <[email protected]> | 2020-01-24 14:22:00 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2020-02-07 17:28:10 +0000 |
commit | 7ea4bce1b292d455c313f914b3aa3051293c502b (patch) | |
tree | 9dffb37e0cc74135d0c92e2ee9a714ed2ff4d5be /crates/ra_hir/src | |
parent | 22a65b11b3a69b3dae561b34c6b28cb2107169d1 (diff) |
Add impl trait lowering mode
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir/src/source_analyzer.rs | 3 |
2 files changed, 9 insertions, 8 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 837a3ed6d..fda31d517 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -733,8 +733,7 @@ impl Local { | |||
733 | let ty = infer[self.pat_id].clone(); | 733 | let ty = infer[self.pat_id].clone(); |
734 | let resolver = def.resolver(db); | 734 | let resolver = def.resolver(db); |
735 | let krate = def.module(db).krate; | 735 | let krate = def.module(db).krate; |
736 | let ctx = hir_ty::TyLoweringContext { db, resolver: &resolver }; | 736 | let environment = TraitEnvironment::lower(db, &resolver); |
737 | let environment = TraitEnvironment::lower(&ctx); | ||
738 | Type { krate, ty: InEnvironment { value: ty, environment } } | 737 | Type { krate, ty: InEnvironment { value: ty, environment } } |
739 | } | 738 | } |
740 | 739 | ||
@@ -790,8 +789,12 @@ impl ImplBlock { | |||
790 | pub fn target_ty(&self, db: &impl HirDatabase) -> Type { | 789 | pub fn target_ty(&self, db: &impl HirDatabase) -> Type { |
791 | let impl_data = db.impl_data(self.id); | 790 | let impl_data = db.impl_data(self.id); |
792 | let resolver = self.id.resolver(db); | 791 | let resolver = self.id.resolver(db); |
793 | let ctx = hir_ty::TyLoweringContext { db, resolver: &resolver }; | 792 | let ctx = hir_ty::TyLoweringContext { |
794 | let environment = TraitEnvironment::lower(&ctx); | 793 | db, |
794 | resolver: &resolver, | ||
795 | impl_trait_mode: hir_ty::ImplTraitLoweringMode::Disallowed, | ||
796 | }; | ||
797 | let environment = TraitEnvironment::lower(db, &resolver); | ||
795 | let ty = Ty::from_hir(&ctx, &impl_data.target_type); | 798 | let ty = Ty::from_hir(&ctx, &impl_data.target_type); |
796 | Type { | 799 | Type { |
797 | krate: self.id.lookup(db).container.module(db).krate, | 800 | krate: self.id.lookup(db).container.module(db).krate, |
@@ -846,8 +849,7 @@ pub struct Type { | |||
846 | impl Type { | 849 | impl Type { |
847 | fn new(db: &impl HirDatabase, krate: CrateId, lexical_env: impl HasResolver, ty: Ty) -> Type { | 850 | fn new(db: &impl HirDatabase, krate: CrateId, lexical_env: impl HasResolver, ty: Ty) -> Type { |
848 | let resolver = lexical_env.resolver(db); | 851 | let resolver = lexical_env.resolver(db); |
849 | let ctx = hir_ty::TyLoweringContext { db, resolver: &resolver }; | 852 | let environment = TraitEnvironment::lower(db, &resolver); |
850 | let environment = TraitEnvironment::lower(&ctx); | ||
851 | Type { krate, ty: InEnvironment { value: ty, environment } } | 853 | Type { krate, ty: InEnvironment { value: ty, environment } } |
852 | } | 854 | } |
853 | 855 | ||
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index 9cfd52856..bb9a35c5d 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs | |||
@@ -179,8 +179,7 @@ impl SourceAnalyzer { | |||
179 | } | 179 | } |
180 | 180 | ||
181 | fn trait_env(&self, db: &impl HirDatabase) -> Arc<TraitEnvironment> { | 181 | fn trait_env(&self, db: &impl HirDatabase) -> Arc<TraitEnvironment> { |
182 | let ctx = hir_ty::TyLoweringContext { db, resolver: &self.resolver }; | 182 | TraitEnvironment::lower(db, &self.resolver) |
183 | TraitEnvironment::lower(&ctx) | ||
184 | } | 183 | } |
185 | 184 | ||
186 | pub fn type_of(&self, db: &impl HirDatabase, expr: &ast::Expr) -> Option<Type> { | 185 | pub fn type_of(&self, db: &impl HirDatabase, expr: &ast::Expr) -> Option<Type> { |