aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-15 12:51:27 +0000
committerGitHub <[email protected]>2021-03-15 12:51:27 +0000
commit6139bd764974318814edfd5427e2a2e8220b211b (patch)
tree70aa9b1a1b338f0c02545cb544ab37c4547f7ce2 /crates/hir
parenta8b319cf28c0985d964ef6624c3ee6e7f09afb2d (diff)
parent42217738e0b121a8e5d48a9a55cb51ef6c98975f (diff)
Merge #8018
8018: Make Ty wrap TyKind in an Arc r=flodiebold a=flodiebold ... to further move towards Chalk. This is a bit of a slowdown (218ginstr vs 213ginstr for inference on RA), even though it allows us to unwrap the Substs in `TyKind::Ref` etc.. Co-authored-by: Florian Diebold <[email protected]>
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 caa760d21..25e5bfb01 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1597,7 +1597,7 @@ impl Type {
1597 1597
1598 pub fn remove_ref(&self) -> Option<Type> { 1598 pub fn remove_ref(&self) -> Option<Type> {
1599 match &self.ty.value.interned(&Interner) { 1599 match &self.ty.value.interned(&Interner) {
1600 TyKind::Ref(.., substs) => Some(self.derived(substs[0].clone())), 1600 TyKind::Ref(.., ty) => Some(self.derived(ty.clone())),
1601 _ => None, 1601 _ => None,
1602 } 1602 }
1603 } 1603 }
@@ -1751,10 +1751,30 @@ impl Type {
1751 return go(&self.ty.value); 1751 return go(&self.ty.value);
1752 1752
1753 fn go(ty: &Ty) -> bool { 1753 fn go(ty: &Ty) -> bool {
1754 if ty.is_unknown() { 1754 match ty.interned(&Interner) {
1755 true 1755 TyKind::Unknown => true,
1756 } else { 1756
1757 ty.substs().map_or(false, |substs| substs.iter().any(go)) 1757 TyKind::Adt(_, substs)
1758 | TyKind::AssociatedType(_, substs)
1759 | TyKind::Tuple(_, substs)
1760 | TyKind::OpaqueType(_, substs)
1761 | TyKind::FnDef(_, substs)
1762 | TyKind::Closure(_, substs) => substs.iter().any(go),
1763
1764 TyKind::Array(ty) | TyKind::Slice(ty) | TyKind::Raw(_, ty) | TyKind::Ref(_, ty) => {
1765 go(ty)
1766 }
1767
1768 TyKind::Scalar(_)
1769 | TyKind::Str
1770 | TyKind::Never
1771 | TyKind::Placeholder(_)
1772 | TyKind::BoundVar(_)
1773 | TyKind::InferenceVar(_, _)
1774 | TyKind::Dyn(_)
1775 | TyKind::Function(_)
1776 | TyKind::Alias(_)
1777 | TyKind::ForeignType(_) => false,
1758 } 1778 }
1759 } 1779 }
1760 } 1780 }
@@ -1989,6 +2009,10 @@ impl Type {
1989 walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb); 2009 walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb);
1990 } 2010 }
1991 2011
2012 TyKind::Ref(_, ty) | TyKind::Raw(_, ty) | TyKind::Array(ty) | TyKind::Slice(ty) => {
2013 walk_type(db, &type_.derived(ty.clone()), cb);
2014 }
2015
1992 _ => {} 2016 _ => {}
1993 } 2017 }
1994 if let Some(substs) = ty.substs() { 2018 if let Some(substs) = ty.substs() {