aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-07 19:26:27 +0100
committerFlorian Diebold <[email protected]>2021-04-07 19:34:58 +0100
commit86feac18e8f96a99830defd707eb221f12d02924 (patch)
tree632c95c0e5d7cd997755f838d9581d8596f0a9e4
parenteb248d85a0eb91bae7bafcd69ffe4dfed3e32fce (diff)
Change TraitRef::hir_fmt_ext to free-standing function
-rw-r--r--crates/hir_ty/src/display.rs38
1 files changed, 18 insertions, 20 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 9e6bbcdf1..266016786 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -792,31 +792,29 @@ fn write_bounds_like_dyn_trait(
792 Ok(()) 792 Ok(())
793} 793}
794 794
795impl TraitRef { 795fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter, use_as: bool) -> Result<(), HirDisplayError> {
796 fn hir_fmt_ext(&self, f: &mut HirFormatter, use_as: bool) -> Result<(), HirDisplayError> { 796 if f.should_truncate() {
797 if f.should_truncate() { 797 return write!(f, "{}", TYPE_HINT_TRUNCATION);
798 return write!(f, "{}", TYPE_HINT_TRUNCATION); 798 }
799 }
800 799
801 self.self_type_parameter(&Interner).hir_fmt(f)?; 800 tr.self_type_parameter(&Interner).hir_fmt(f)?;
802 if use_as { 801 if use_as {
803 write!(f, " as ")?; 802 write!(f, " as ")?;
804 } else { 803 } else {
805 write!(f, ": ")?; 804 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(())
814 } 805 }
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(())
815} 813}
816 814
817impl HirDisplay for TraitRef { 815impl HirDisplay for TraitRef {
818 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> { 816 fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
819 self.hir_fmt_ext(f, false) 817 fmt_trait_ref(self, f, false)
820 } 818 }
821} 819}
822 820
@@ -830,7 +828,7 @@ impl HirDisplay for WhereClause {
830 WhereClause::Implemented(trait_ref) => trait_ref.hir_fmt(f)?, 828 WhereClause::Implemented(trait_ref) => trait_ref.hir_fmt(f)?,
831 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => { 829 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => {
832 write!(f, "<")?; 830 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)?;
834 write!( 832 write!(
835 f, 833 f,
836 ">::{} = ", 834 ">::{} = ",