diff options
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/lib.rs | 37 | ||||
-rw-r--r-- | crates/hir/src/source_analyzer.rs | 5 |
2 files changed, 33 insertions, 9 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index d13b4d5fd..c5161dadd 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -267,8 +267,7 @@ impl ModuleDef { | |||
267 | } | 267 | } |
268 | 268 | ||
269 | pub fn canonical_path(&self, db: &dyn HirDatabase) -> Option<String> { | 269 | pub fn canonical_path(&self, db: &dyn HirDatabase) -> Option<String> { |
270 | let mut segments = Vec::new(); | 270 | let mut segments = vec![self.name(db)?.to_string()]; |
271 | segments.push(self.name(db)?.to_string()); | ||
272 | for m in self.module(db)?.path_to_root(db) { | 271 | for m in self.module(db)?.path_to_root(db) { |
273 | segments.extend(m.name(db).map(|it| it.to_string())) | 272 | segments.extend(m.name(db).map(|it| it.to_string())) |
274 | } | 273 | } |
@@ -1634,7 +1633,7 @@ impl Type { | |||
1634 | 1633 | ||
1635 | pub fn remove_ref(&self) -> Option<Type> { | 1634 | pub fn remove_ref(&self) -> Option<Type> { |
1636 | match &self.ty.value.interned(&Interner) { | 1635 | match &self.ty.value.interned(&Interner) { |
1637 | TyKind::Ref(.., substs) => Some(self.derived(substs[0].clone())), | 1636 | TyKind::Ref(.., ty) => Some(self.derived(ty.clone())), |
1638 | _ => None, | 1637 | _ => None, |
1639 | } | 1638 | } |
1640 | } | 1639 | } |
@@ -1788,10 +1787,30 @@ impl Type { | |||
1788 | return go(&self.ty.value); | 1787 | return go(&self.ty.value); |
1789 | 1788 | ||
1790 | fn go(ty: &Ty) -> bool { | 1789 | fn go(ty: &Ty) -> bool { |
1791 | if ty.is_unknown() { | 1790 | match ty.interned(&Interner) { |
1792 | true | 1791 | TyKind::Unknown => true, |
1793 | } else { | 1792 | |
1794 | ty.substs().map_or(false, |substs| substs.iter().any(go)) | 1793 | TyKind::Adt(_, substs) |
1794 | | TyKind::AssociatedType(_, substs) | ||
1795 | | TyKind::Tuple(_, substs) | ||
1796 | | TyKind::OpaqueType(_, substs) | ||
1797 | | TyKind::FnDef(_, substs) | ||
1798 | | TyKind::Closure(_, substs) => substs.iter().any(go), | ||
1799 | |||
1800 | TyKind::Array(ty) | TyKind::Slice(ty) | TyKind::Raw(_, ty) | TyKind::Ref(_, ty) => { | ||
1801 | go(ty) | ||
1802 | } | ||
1803 | |||
1804 | TyKind::Scalar(_) | ||
1805 | | TyKind::Str | ||
1806 | | TyKind::Never | ||
1807 | | TyKind::Placeholder(_) | ||
1808 | | TyKind::BoundVar(_) | ||
1809 | | TyKind::InferenceVar(_, _) | ||
1810 | | TyKind::Dyn(_) | ||
1811 | | TyKind::Function(_) | ||
1812 | | TyKind::Alias(_) | ||
1813 | | TyKind::ForeignType(_) => false, | ||
1795 | } | 1814 | } |
1796 | } | 1815 | } |
1797 | } | 1816 | } |
@@ -2020,6 +2039,10 @@ impl Type { | |||
2020 | walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb); | 2039 | walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb); |
2021 | } | 2040 | } |
2022 | 2041 | ||
2042 | TyKind::Ref(_, ty) | TyKind::Raw(_, ty) | TyKind::Array(ty) | TyKind::Slice(ty) => { | ||
2043 | walk_type(db, &type_.derived(ty.clone()), cb); | ||
2044 | } | ||
2045 | |||
2023 | _ => {} | 2046 | _ => {} |
2024 | } | 2047 | } |
2025 | if let Some(substs) = ty.substs() { | 2048 | if let Some(substs) = ty.substs() { |
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index d546512cb..4d59293e9 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs | |||
@@ -161,8 +161,9 @@ impl SourceAnalyzer { | |||
161 | db: &dyn HirDatabase, | 161 | db: &dyn HirDatabase, |
162 | field: &ast::RecordExprField, | 162 | field: &ast::RecordExprField, |
163 | ) -> Option<(Field, Option<Local>)> { | 163 | ) -> Option<(Field, Option<Local>)> { |
164 | let expr = field.expr()?; | 164 | let expr_id = |
165 | let expr_id = self.expr_id(db, &expr)?; | 165 | self.body_source_map.as_ref()?.node_field(InFile::new(self.file_id, field))?; |
166 | |||
166 | let local = if field.name_ref().is_some() { | 167 | let local = if field.name_ref().is_some() { |
167 | None | 168 | None |
168 | } else { | 169 | } else { |