@@ -24,7 +24,7 @@ use crate::{
2424 traits:: chalk:: from_chalk, utils:: generics, AdtId , AliasEq , AliasTy , CallableDefId ,
2525 CallableSig , Const , ConstValue , DomainGoal , GenericArg , ImplTraitId , Interner , Lifetime ,
2626 LifetimeData , LifetimeOutlives , Mutability , OpaqueTy , ProjectionTy , ProjectionTyExt ,
27- QuantifiedWhereClause , Scalar , TraitRef , Ty , TyExt , TyKind , WhereClause ,
27+ QuantifiedWhereClause , Scalar , TraitRef , TraitRefExt , Ty , TyExt , TyKind , WhereClause ,
2828} ;
2929
3030pub struct HirFormatter < ' a > {
@@ -616,12 +616,12 @@ impl HirDisplay for Ty {
616616 . map ( |pred| pred. clone ( ) . substitute ( & Interner , & substs) )
617617 . filter ( |wc| match & wc. skip_binders ( ) {
618618 WhereClause :: Implemented ( tr) => {
619- tr. self_type_parameter ( & Interner ) == self
619+ & tr. self_type_parameter ( & Interner ) == self
620620 }
621621 WhereClause :: AliasEq ( AliasEq {
622622 alias : AliasTy :: Projection ( proj) ,
623623 ty : _,
624- } ) => proj. self_type_parameter ( & Interner ) == self ,
624+ } ) => & proj. self_type_parameter ( & Interner ) == self ,
625625 _ => false ,
626626 } )
627627 . collect :: < Vec < _ > > ( ) ;
@@ -745,7 +745,7 @@ fn write_bounds_like_dyn_trait(
745745 // existential) here, which is the only thing that's
746746 // possible in actual Rust, and hence don't print it
747747 write ! ( f, "{}" , f. db. trait_data( trait_) . name) ?;
748- if let [ _, params @ ..] = & * trait_ref. substitution . interned ( ) {
748+ if let [ _, params @ ..] = & * trait_ref. substitution . interned ( ) . as_slice ( ) {
749749 if is_fn_trait {
750750 if let Some ( args) =
751751 params. first ( ) . and_then ( |it| it. assert_ty_ref ( & Interner ) . as_tuple ( ) )
@@ -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
817815impl 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