Build source map for hir_def::TypeRefs

So that given a `TypeRef` we will be able to trace it back to source code.

This is necessary to be able to provide diagnostics for lowering to chalk tys, since the input to that is `TypeRef`.

This means that `TypeRef`s now have an identity, which means storing them in arena and not interning them, which is an unfortunate (but necessary) loss but also a pretty massive change. Luckily, because of the separation layer we have for IDE and HIR, this change never crosses the IDE boundary.
This commit is contained in:
Chayim Refael Friedman 2024-09-06 16:25:22 +03:00
parent 6a67a4d3cd
commit 89c0ffa6b0
40 changed files with 1712 additions and 778 deletions

View file

@ -2420,7 +2420,7 @@ impl SelfParam {
func_data
.params
.first()
.map(|param| match &**param {
.map(|&param| match func_data.types_map[param] {
TypeRef::Reference(.., mutability) => match mutability {
hir_def::type_ref::Mutability::Shared => Access::Shared,
hir_def::type_ref::Mutability::Mut => Access::Exclusive,
@ -2747,10 +2747,6 @@ impl TypeAlias {
Module { id: self.id.module(db.upcast()) }
}
pub fn type_ref(self, db: &dyn HirDatabase) -> Option<TypeRef> {
db.type_alias_data(self.id).type_ref.as_deref().cloned()
}
pub fn ty(self, db: &dyn HirDatabase) -> Type {
Type::from_def(db, self.id)
}