@@ -474,7 +474,9 @@ impl HirDisplay for ProjectionTy {
474
474
475
475
let trait_ref = self . trait_ref ( f. db ) ;
476
476
write ! ( f, "<" ) ?;
477
- fmt_trait_ref ( f, & trait_ref, TraitRefFormat :: SelfAsTrait ) ?;
477
+ trait_ref. self_type_parameter ( Interner ) . hir_fmt ( f) ?;
478
+ write ! ( f, " as " ) ?;
479
+ trait_ref. hir_fmt ( f) ?;
478
480
write ! (
479
481
f,
480
482
">::{}" ,
@@ -1775,50 +1777,14 @@ fn write_bounds_like_dyn_trait(
1775
1777
Ok ( ( ) )
1776
1778
}
1777
1779
1778
- #[ derive( Clone , Copy ) ]
1779
- pub enum TraitRefFormat {
1780
- SelfAsTrait ,
1781
- SelfImplementsTrait ,
1782
- OnlyTrait ,
1783
- }
1784
-
1785
- fn fmt_trait_ref (
1786
- f : & mut HirFormatter < ' _ > ,
1787
- tr : & TraitRef ,
1788
- format : TraitRefFormat ,
1789
- ) -> Result < ( ) , HirDisplayError > {
1790
- if f. should_truncate ( ) {
1791
- return write ! ( f, "{TYPE_HINT_TRUNCATION}" ) ;
1792
- }
1793
-
1794
- match format {
1795
- TraitRefFormat :: SelfAsTrait => {
1796
- tr. self_type_parameter ( Interner ) . hir_fmt ( f) ?;
1797
- write ! ( f, " as " ) ?;
1798
- }
1799
- TraitRefFormat :: SelfImplementsTrait => {
1800
- tr. self_type_parameter ( Interner ) . hir_fmt ( f) ?;
1801
- write ! ( f, ": " ) ?;
1802
- }
1803
- TraitRefFormat :: OnlyTrait => { }
1804
- }
1805
-
1806
- let trait_ = tr. hir_trait_id ( ) ;
1807
- f. start_location_link ( trait_. into ( ) ) ;
1808
- write ! ( f, "{}" , f. db. trait_data( trait_) . name. display( f. db. upcast( ) , f. edition( ) ) ) ?;
1809
- f. end_location_link ( ) ;
1810
- let substs = tr. substitution . as_slice ( Interner ) ;
1811
- hir_fmt_generics ( f, & substs[ 1 ..] , None , substs[ 0 ] . ty ( Interner ) )
1812
- }
1813
-
1814
- pub struct TraitRefDisplayWrapper {
1815
- pub trait_ref : TraitRef ,
1816
- pub format : TraitRefFormat ,
1817
- }
1818
-
1819
- impl HirDisplay for TraitRefDisplayWrapper {
1780
+ impl HirDisplay for TraitRef {
1820
1781
fn hir_fmt ( & self , f : & mut HirFormatter < ' _ > ) -> Result < ( ) , HirDisplayError > {
1821
- fmt_trait_ref ( f, & self . trait_ref , self . format )
1782
+ let trait_ = self . hir_trait_id ( ) ;
1783
+ f. start_location_link ( trait_. into ( ) ) ;
1784
+ write ! ( f, "{}" , f. db. trait_data( trait_) . name. display( f. db. upcast( ) , f. edition( ) ) ) ?;
1785
+ f. end_location_link ( ) ;
1786
+ let substs = self . substitution . as_slice ( Interner ) ;
1787
+ hir_fmt_generics ( f, & substs[ 1 ..] , None , substs[ 0 ] . ty ( Interner ) )
1822
1788
}
1823
1789
}
1824
1790
@@ -1830,11 +1796,16 @@ impl HirDisplay for WhereClause {
1830
1796
1831
1797
match self {
1832
1798
WhereClause :: Implemented ( trait_ref) => {
1833
- fmt_trait_ref ( f, trait_ref, TraitRefFormat :: SelfImplementsTrait ) ?;
1799
+ trait_ref. self_type_parameter ( Interner ) . hir_fmt ( f) ?;
1800
+ write ! ( f, ": " ) ?;
1801
+ trait_ref. hir_fmt ( f) ?;
1834
1802
}
1835
1803
WhereClause :: AliasEq ( AliasEq { alias : AliasTy :: Projection ( projection_ty) , ty } ) => {
1836
1804
write ! ( f, "<" ) ?;
1837
- fmt_trait_ref ( f, & projection_ty. trait_ref ( f. db ) , TraitRefFormat :: SelfAsTrait ) ?;
1805
+ let trait_ref = & projection_ty. trait_ref ( f. db ) ;
1806
+ trait_ref. self_type_parameter ( Interner ) . hir_fmt ( f) ?;
1807
+ write ! ( f, " as " ) ?;
1808
+ trait_ref. hir_fmt ( f) ?;
1838
1809
write ! ( f, ">::" , ) ?;
1839
1810
let type_alias = from_assoc_type_id ( projection_ty. associated_ty_id ) ;
1840
1811
f. start_location_link ( type_alias. into ( ) ) ;
0 commit comments