aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-03-14 16:40:55 +0000
committerFlorian Diebold <[email protected]>2021-03-14 19:21:05 +0000
commit42217738e0b121a8e5d48a9a55cb51ef6c98975f (patch)
tree63b3fc22a011ae0ee37a91cb19f5dcfe390507f1 /crates/hir
parentaf466f8542173002361eb134e66102908c7cd024 (diff)
Don't use Substs for Ref/Raw/Array/Slice
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/lib.rs34
1 files changed, 29 insertions, 5 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index eb1cd66fb..c0810c69b 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1598,7 +1598,7 @@ impl Type {
1598 1598
1599 pub fn remove_ref(&self) -> Option<Type> { 1599 pub fn remove_ref(&self) -> Option<Type> {
1600 match &self.ty.value.interned(&Interner) { 1600 match &self.ty.value.interned(&Interner) {
1601 TyKind::Ref(.., substs) => Some(self.derived(substs[0].clone())), 1601 TyKind::Ref(.., ty) => Some(self.derived(ty.clone())),
1602 _ => None, 1602 _ => None,
1603 } 1603 }
1604 } 1604 }
@@ -1752,10 +1752,30 @@ impl Type {
1752 return go(&self.ty.value); 1752 return go(&self.ty.value);
1753 1753
1754 fn go(ty: &Ty) -> bool { 1754 fn go(ty: &Ty) -> bool {
1755 if ty.is_unknown() { 1755 match ty.interned(&Interner) {
1756 true 1756 TyKind::Unknown => true,
1757 } else { 1757
1758 ty.substs().map_or(false, |substs| substs.iter().any(go)) 1758 TyKind::Adt(_, substs)
1759 | TyKind::AssociatedType(_, substs)
1760 | TyKind::Tuple(_, substs)
1761 | TyKind::OpaqueType(_, substs)
1762 | TyKind::FnDef(_, substs)
1763 | TyKind::Closure(_, substs) => substs.iter().any(go),
1764
1765 TyKind::Array(ty) | TyKind::Slice(ty) | TyKind::Raw(_, ty) | TyKind::Ref(_, ty) => {
1766 go(ty)
1767 }
1768
1769 TyKind::Scalar(_)
1770 | TyKind::Str
1771 | TyKind::Never
1772 | TyKind::Placeholder(_)
1773 | TyKind::BoundVar(_)
1774 | TyKind::InferenceVar(_, _)
1775 | TyKind::Dyn(_)
1776 | TyKind::Function(_)
1777 | TyKind::Alias(_)
1778 | TyKind::ForeignType(_) => false,
1759 } 1779 }
1760 } 1780 }
1761 } 1781 }
@@ -1990,6 +2010,10 @@ impl Type {
1990 walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb); 2010 walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb);
1991 } 2011 }
1992 2012
2013 TyKind::Ref(_, ty) | TyKind::Raw(_, ty) | TyKind::Array(ty) | TyKind::Slice(ty) => {
2014 walk_type(db, &type_.derived(ty.clone()), cb);
2015 }
2016
1993 _ => {} 2017 _ => {}
1994 } 2018 }
1995 if let Some(substs) = ty.substs() { 2019 if let Some(substs) = ty.substs() {