aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src')
-rw-r--r--crates/hir/src/lib.rs31
1 files changed, 22 insertions, 9 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 06fd6542d..fcc577384 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1829,9 +1829,11 @@ impl Type {
1829 ); 1829 );
1830 1830
1831 match db.trait_solve(self.krate, goal)? { 1831 match db.trait_solve(self.krate, goal)? {
1832 Solution::Unique(SolutionVariables(subst)) => { 1832 Solution::Unique(SolutionVariables(subst)) => subst
1833 subst.value.first().map(|ty| self.derived(ty.clone())) 1833 .value
1834 } 1834 .interned(&Interner)
1835 .first()
1836 .map(|ty| self.derived(ty.assert_ty_ref(&Interner).clone())),
1835 Solution::Ambig(_) => None, 1837 Solution::Ambig(_) => None,
1836 } 1838 }
1837 } 1839 }
@@ -1889,7 +1891,9 @@ impl Type {
1889 | TyKind::Tuple(_, substs) 1891 | TyKind::Tuple(_, substs)
1890 | TyKind::OpaqueType(_, substs) 1892 | TyKind::OpaqueType(_, substs)
1891 | TyKind::FnDef(_, substs) 1893 | TyKind::FnDef(_, substs)
1892 | TyKind::Closure(_, substs) => substs.iter().any(go), 1894 | TyKind::Closure(_, substs) => {
1895 substs.iter(&Interner).filter_map(|a| a.ty(&Interner)).any(go)
1896 }
1893 1897
1894 TyKind::Array(ty) | TyKind::Slice(ty) | TyKind::Raw(_, ty) | TyKind::Ref(_, ty) => { 1898 TyKind::Array(ty) | TyKind::Slice(ty) | TyKind::Raw(_, ty) | TyKind::Ref(_, ty) => {
1895 go(ty) 1899 go(ty)
@@ -1928,7 +1932,10 @@ impl Type {
1928 1932
1929 pub fn tuple_fields(&self, _db: &dyn HirDatabase) -> Vec<Type> { 1933 pub fn tuple_fields(&self, _db: &dyn HirDatabase) -> Vec<Type> {
1930 if let TyKind::Tuple(_, substs) = &self.ty.interned(&Interner) { 1934 if let TyKind::Tuple(_, substs) = &self.ty.interned(&Interner) {
1931 substs.iter().map(|ty| self.derived(ty.clone())).collect() 1935 substs
1936 .iter(&Interner)
1937 .map(|ty| self.derived(ty.assert_ty_ref(&Interner).clone()))
1938 .collect()
1932 } else { 1939 } else {
1933 Vec::new() 1940 Vec::new()
1934 } 1941 }
@@ -1973,8 +1980,9 @@ impl Type {
1973 .strip_references() 1980 .strip_references()
1974 .substs() 1981 .substs()
1975 .into_iter() 1982 .into_iter()
1976 .flat_map(|substs| substs.iter()) 1983 .flat_map(|substs| substs.iter(&Interner))
1977 .map(move |ty| self.derived(ty.clone())) 1984 .filter_map(|arg| arg.ty(&Interner).cloned())
1985 .map(move |ty| self.derived(ty))
1978 } 1986 }
1979 1987
1980 pub fn iterate_method_candidates<T>( 1988 pub fn iterate_method_candidates<T>(
@@ -2080,7 +2088,7 @@ impl Type {
2080 substs: &Substitution, 2088 substs: &Substitution,
2081 cb: &mut impl FnMut(Type), 2089 cb: &mut impl FnMut(Type),
2082 ) { 2090 ) {
2083 for ty in substs.iter() { 2091 for ty in substs.iter(&Interner).filter_map(|a| a.ty(&Interner)) {
2084 walk_type(db, &type_.derived(ty.clone()), cb); 2092 walk_type(db, &type_.derived(ty.clone()), cb);
2085 } 2093 }
2086 } 2094 }
@@ -2096,7 +2104,12 @@ impl Type {
2096 WhereClause::Implemented(trait_ref) => { 2104 WhereClause::Implemented(trait_ref) => {
2097 cb(type_.clone()); 2105 cb(type_.clone());
2098 // skip the self type. it's likely the type we just got the bounds from 2106 // skip the self type. it's likely the type we just got the bounds from
2099 for ty in trait_ref.substitution.iter().skip(1) { 2107 for ty in trait_ref
2108 .substitution
2109 .iter(&Interner)
2110 .skip(1)
2111 .filter_map(|a| a.ty(&Interner))
2112 {
2100 walk_type(db, &type_.derived(ty.clone()), cb); 2113 walk_type(db, &type_.derived(ty.clone()), cb);
2101 } 2114 }
2102 } 2115 }