internal: intern TypeBounds

Doesn't save much memory (~2 mb), but interning things is generally a
good pattern to follow
This commit is contained in:
Jonas Schievink 2021-05-24 15:13:23 +02:00
parent 05fc97e31b
commit 8ebb8d29e1
12 changed files with 49 additions and 27 deletions

View file

@ -13,6 +13,7 @@ use hir_def::{
db::DefDatabase,
find_path,
generics::TypeParamProvenance,
intern::{Internable, Interned},
item_scope::ItemInNs,
path::{Path, PathKind},
type_ref::{TypeBound, TypeRef},
@ -256,6 +257,12 @@ impl<T: HirDisplay> HirDisplay for &'_ T {
}
}
impl<T: HirDisplay + Internable> HirDisplay for Interned<T> {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
HirDisplay::hir_fmt(self.as_ref(), f)
}
}
impl HirDisplay for ProjectionTy {
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
if f.should_truncate() {