@@ -2623,46 +2623,6 @@ where
26232623 }
26242624}
26252625
2626- macro_rules! forward_display_to_print {
2627- ( $( $ty: ty) ,+) => {
2628- // Some of the $ty arguments may not actually use 'tcx
2629- $( #[ allow( unused_lifetimes) ] impl <' tcx> fmt:: Display for $ty {
2630- fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
2631- ty:: tls:: with( |tcx| {
2632- let mut cx = FmtPrinter :: new( tcx, Namespace :: TypeNS ) ;
2633- tcx. lift( * self )
2634- . expect( "could not lift for printing" )
2635- . print( & mut cx) ?;
2636- f. write_str( & cx. into_buffer( ) ) ?;
2637- Ok ( ( ) )
2638- } )
2639- }
2640- } ) +
2641- } ;
2642- }
2643-
2644- macro_rules! define_print_and_forward_display {
2645- ( ( $self: ident, $cx: ident) : $( $ty: ty $print: block) +) => {
2646- define_print!( ( $self, $cx) : $( $ty $print) * ) ;
2647- forward_display_to_print!( $( $ty) ,+) ;
2648- } ;
2649- }
2650-
2651- macro_rules! define_print {
2652- ( ( $self: ident, $cx: ident) : $( $ty: ty $print: block) +) => {
2653- $( impl <' tcx, P : PrettyPrinter <' tcx>> Print <' tcx, P > for $ty {
2654- fn print( & $self, $cx: & mut P ) -> Result <( ) , PrintError > {
2655- #[ allow( unused_mut) ]
2656- let mut $cx = $cx;
2657- define_scoped_cx!( $cx) ;
2658- let _: ( ) = $print;
2659- #[ allow( unreachable_code) ]
2660- Ok ( ( ) )
2661- }
2662- } ) +
2663- } ;
2664- }
2665-
26662626/// Wrapper type for `ty::TraitRef` which opts-in to pretty printing only
26672627/// the trait path. That is, it will print `Trait<U>` instead of
26682628/// `<T as Trait<U>>`.
@@ -2737,6 +2697,46 @@ pub struct PrintClosureAsImpl<'tcx> {
27372697 pub closure : ty:: ClosureArgs < ' tcx > ,
27382698}
27392699
2700+ macro_rules! forward_display_to_print {
2701+ ( $( $ty: ty) ,+) => {
2702+ // Some of the $ty arguments may not actually use 'tcx
2703+ $( #[ allow( unused_lifetimes) ] impl <' tcx> fmt:: Display for $ty {
2704+ fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
2705+ ty:: tls:: with( |tcx| {
2706+ let mut cx = FmtPrinter :: new( tcx, Namespace :: TypeNS ) ;
2707+ tcx. lift( * self )
2708+ . expect( "could not lift for printing" )
2709+ . print( & mut cx) ?;
2710+ f. write_str( & cx. into_buffer( ) ) ?;
2711+ Ok ( ( ) )
2712+ } )
2713+ }
2714+ } ) +
2715+ } ;
2716+ }
2717+
2718+ macro_rules! define_print {
2719+ ( ( $self: ident, $cx: ident) : $( $ty: ty $print: block) +) => {
2720+ $( impl <' tcx, P : PrettyPrinter <' tcx>> Print <' tcx, P > for $ty {
2721+ fn print( & $self, $cx: & mut P ) -> Result <( ) , PrintError > {
2722+ #[ allow( unused_mut) ]
2723+ let mut $cx = $cx;
2724+ define_scoped_cx!( $cx) ;
2725+ let _: ( ) = $print;
2726+ #[ allow( unreachable_code) ]
2727+ Ok ( ( ) )
2728+ }
2729+ } ) +
2730+ } ;
2731+ }
2732+
2733+ macro_rules! define_print_and_forward_display {
2734+ ( ( $self: ident, $cx: ident) : $( $ty: ty $print: block) +) => {
2735+ define_print!( ( $self, $cx) : $( $ty $print) * ) ;
2736+ forward_display_to_print!( $( $ty) ,+) ;
2737+ } ;
2738+ }
2739+
27402740forward_display_to_print ! {
27412741 ty:: Region <' tcx>,
27422742 Ty <' tcx>,
0 commit comments