@@ -817,25 +817,18 @@ pub trait PrettyPrinter<'tcx>:
817
817
}
818
818
}
819
819
820
- {
821
- define_scoped_cx ! ( self ) ;
822
- p ! ( "impl " ) ;
823
- }
820
+ write ! ( self , "impl " ) ?;
824
821
825
822
let mut first = true ;
826
823
// Insert parenthesis around (Fn(A, B) -> C) if the opaque ty has more than one other trait
827
824
let paren_needed = fn_traits. len ( ) > 1 || traits. len ( ) > 0 || !is_sized;
828
825
829
826
for ( fn_once_trait_ref, entry) in fn_traits {
830
- {
831
- define_scoped_cx ! ( self ) ;
832
- p ! (
833
- write( "{}" , if first { "" } else { " + " } ) ,
834
- write( "{}" , if paren_needed { "(" } else { "" } )
835
- ) ;
836
- }
827
+ write ! ( self , "{}" , if first { "" } else { " + " } ) ?;
828
+ write ! ( self , "{}" , if paren_needed { "(" } else { "" } ) ?;
837
829
838
- self = self . wrap_binder ( & fn_once_trait_ref, |trait_ref, mut self_| {
830
+ self = self . wrap_binder ( & fn_once_trait_ref, |trait_ref, mut cx| {
831
+ define_scoped_cx ! ( cx) ;
839
832
// Get the (single) generic ty (the args) of this FnOnce trait ref.
840
833
let generics = tcx. generics_of ( trait_ref. def_id ) ;
841
834
let args = generics. own_substs_no_defaults ( tcx, trait_ref. substs ) ;
@@ -852,7 +845,6 @@ pub trait PrettyPrinter<'tcx>:
852
845
"FnOnce"
853
846
} ;
854
847
855
- define_scoped_cx ! ( self_) ;
856
848
p ! ( write( "{}(" , name) ) ;
857
849
858
850
for ( idx, ty) in arg_tys. tuple_fields ( ) . iter ( ) . enumerate ( ) {
@@ -892,19 +884,16 @@ pub trait PrettyPrinter<'tcx>:
892
884
}
893
885
}
894
886
895
- Ok ( self_ )
887
+ Ok ( cx )
896
888
} ) ?;
897
889
}
898
890
899
891
// Print the rest of the trait types (that aren't Fn* family of traits)
900
892
for ( trait_ref, assoc_items) in traits {
901
- {
902
- define_scoped_cx ! ( self ) ;
903
- p ! ( write( "{}" , if first { "" } else { " + " } ) ) ;
904
- }
893
+ write ! ( self , "{}" , if first { "" } else { " + " } ) ?;
905
894
906
- self = self . wrap_binder ( & trait_ref, |trait_ref, mut self_ | {
907
- define_scoped_cx ! ( self_ ) ;
895
+ self = self . wrap_binder ( & trait_ref, |trait_ref, mut cx | {
896
+ define_scoped_cx ! ( cx ) ;
908
897
p ! ( print( trait_ref. print_only_trait_name( ) ) ) ;
909
898
910
899
let generics = tcx. generics_of ( trait_ref. def_id ) ;
@@ -969,16 +958,14 @@ pub trait PrettyPrinter<'tcx>:
969
958
}
970
959
971
960
first = false ;
972
- Ok ( self_ )
961
+ Ok ( cx )
973
962
} ) ?;
974
963
}
975
964
976
- define_scoped_cx ! ( self ) ;
977
-
978
965
if !is_sized {
979
- p ! ( write ( "{}?Sized" , if first { "" } else { " + " } ) ) ;
966
+ write ! ( self , "{}?Sized" , if first { "" } else { " + " } ) ? ;
980
967
} else if first {
981
- p ! ( "Sized" ) ;
968
+ write ! ( self , "Sized" ) ? ;
982
969
}
983
970
984
971
Ok ( self )
0 commit comments