Skip to content

Commit 86feac1

Browse files
committed
Change TraitRef::hir_fmt_ext to free-standing function
1 parent eb248d8 commit 86feac1

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

crates/hir_ty/src/display.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -792,31 +792,29 @@ fn write_bounds_like_dyn_trait(
792792
Ok(())
793793
}
794794

795-
impl TraitRef {
796-
fn hir_fmt_ext(&self, f: &mut HirFormatter, use_as: bool) -> Result<(), HirDisplayError> {
797-
if f.should_truncate() {
798-
return write!(f, "{}", TYPE_HINT_TRUNCATION);
799-
}
795+
fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter, use_as: bool) -> Result<(), HirDisplayError> {
796+
if f.should_truncate() {
797+
return write!(f, "{}", TYPE_HINT_TRUNCATION);
798+
}
800799

801-
self.self_type_parameter(&Interner).hir_fmt(f)?;
802-
if use_as {
803-
write!(f, " as ")?;
804-
} else {
805-
write!(f, ": ")?;
806-
}
807-
write!(f, "{}", f.db.trait_data(self.hir_trait_id()).name)?;
808-
if self.substitution.len(&Interner) > 1 {
809-
write!(f, "<")?;
810-
f.write_joined(&self.substitution.interned()[1..], ", ")?;
811-
write!(f, ">")?;
812-
}
813-
Ok(())
800+
tr.self_type_parameter(&Interner).hir_fmt(f)?;
801+
if use_as {
802+
write!(f, " as ")?;
803+
} else {
804+
write!(f, ": ")?;
814805
}
806+
write!(f, "{}", f.db.trait_data(tr.hir_trait_id()).name)?;
807+
if tr.substitution.len(&Interner) > 1 {
808+
write!(f, "<")?;
809+
f.write_joined(&tr.substitution.interned()[1..], ", ")?;
810+
write!(f, ">")?;
811+
}
812+
Ok(())
815813
}
816814

817815
impl HirDisplay for TraitRef {
818816
fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
819-
self.hir_fmt_ext(f, false)
817+
fmt_trait_ref(self, f, false)
820818
}
821819
}
822820

@@ -830,7 +828,7 @@ impl HirDisplay for WhereClause {
830828
WhereClause::Implemented(trait_ref) => trait_ref.hir_fmt(f)?,
831829
WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => {
832830
write!(f, "<")?;
833-
projection_ty.trait_ref(f.db).hir_fmt_ext(f, true)?;
831+
fmt_trait_ref(&projection_ty.trait_ref(f.db), f, true)?;
834832
write!(
835833
f,
836834
">::{} = ",

0 commit comments

Comments
 (0)