aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/lib.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 4a7d3a0d9..f16d1fc97 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -33,7 +33,6 @@ use hir_def::{
33 AdtId, AssocContainerId, DefWithBodyId, GenericDefId, HasModule, Lookup, TraitId, TypeAliasId, 33 AdtId, AssocContainerId, DefWithBodyId, GenericDefId, HasModule, Lookup, TraitId, TypeAliasId,
34 TypeParamId, 34 TypeParamId,
35}; 35};
36use hir_expand::name::name;
37use itertools::Itertools; 36use itertools::Itertools;
38 37
39use crate::{ 38use crate::{
@@ -848,26 +847,22 @@ impl Ty {
848 847
849 pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<GenericPredicate>> { 848 pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<GenericPredicate>> {
850 match self { 849 match self {
851 Ty::Apply(ApplicationTy { ctor: TypeCtor::OpaqueType(opaque_ty_id), parameters }) => { 850 Ty::Apply(ApplicationTy { ctor: TypeCtor::OpaqueType(opaque_ty_id), .. }) => {
852 match opaque_ty_id { 851 match opaque_ty_id {
853 OpaqueTyId::AsyncBlockTypeImplTrait(def, _expr) => { 852 OpaqueTyId::AsyncBlockTypeImplTrait(def, _expr) => {
854 let krate = def.module(db.upcast()).krate; 853 let krate = def.module(db.upcast()).krate;
855 if let Some(future_output) = db 854 if let Some(future_trait) = db
856 .lang_item(krate, "future_trait".into()) 855 .lang_item(krate, "future_trait".into())
857 .and_then(|item| item.as_trait()) 856 .and_then(|item| item.as_trait())
858 .and_then(|trait_| {
859 db.trait_data(trait_).associated_type_by_name(&name![Output])
860 })
861 { 857 {
862 let proj = GenericPredicate::Projection(ProjectionPredicate { 858 // This is only used by type walking.
863 projection_ty: ProjectionTy { 859 // Parameters will be walked outside, and projection predicate is not used.
864 associated_ty: future_output, 860 // So just provide the Future trait.
865 // Self type. 861 let impl_bound = GenericPredicate::Implemented(TraitRef {
866 parameters: Substs::single(self.clone()), 862 trait_: future_trait,
867 }, 863 substs: Substs::empty(),
868 ty: parameters[0].clone(),
869 }); 864 });
870 Some(vec![proj]) 865 Some(vec![impl_bound])
871 } else { 866 } else {
872 None 867 None
873 } 868 }