@@ -330,22 +330,58 @@ macro_rules! setup_interned_struct {
330330 )
331331 }
332332 ) *
333+ }
333334
334- /// Default debug formatting for this struct (may be useful if you define your own `Debug` impl)
335- pub fn default_debug_fmt( this: Self , f: & mut std:: fmt:: Formatter <' _>) -> std:: fmt:: Result {
336- $zalsa:: with_attached_database( |db| {
337- let zalsa = db. zalsa( ) ;
338- let fields = $Configuration:: ingredient( zalsa) . fields( zalsa, this) ;
339- let mut f = f. debug_struct( stringify!( $Struct) ) ;
340- $(
341- let f = f. field( stringify!( $field_id) , & fields. $field_index) ;
342- ) *
343- f. finish( )
344- } ) . unwrap_or_else( || {
345- f. debug_tuple( stringify!( $Struct) )
346- . field( & $zalsa:: AsId :: as_id( & this) )
347- . finish( )
348- } )
335+ // Duplication can be dropped here once we no longer allow the `no_lifetime` hack
336+ $zalsa:: macro_if! {
337+ iftt ( $( $db_lt_arg) ?) {
338+ impl $Struct<' _> {
339+ /// Default debug formatting for this struct (may be useful if you define your own `Debug` impl)
340+ pub fn default_debug_fmt( this: Self , f: & mut std:: fmt:: Formatter <' _>) -> std:: fmt:: Result
341+ where
342+ // rustc rejects trivial bounds, but it cannot see through higher-ranked bounds
343+ // with its check :^)
344+ $( for <$db_lt> $field_ty: std:: fmt:: Debug ) ,*
345+ {
346+ $zalsa:: with_attached_database( |db| {
347+ let zalsa = db. zalsa( ) ;
348+ let fields = $Configuration:: ingredient( zalsa) . fields( zalsa, this) ;
349+ let mut f = f. debug_struct( stringify!( $Struct) ) ;
350+ $(
351+ let f = f. field( stringify!( $field_id) , & fields. $field_index) ;
352+ ) *
353+ f. finish( )
354+ } ) . unwrap_or_else( || {
355+ f. debug_tuple( stringify!( $Struct) )
356+ . field( & $zalsa:: AsId :: as_id( & this) )
357+ . finish( )
358+ } )
359+ }
360+ }
361+ } else {
362+ impl $Struct {
363+ /// Default debug formatting for this struct (may be useful if you define your own `Debug` impl)
364+ pub fn default_debug_fmt( this: Self , f: & mut std:: fmt:: Formatter <' _>) -> std:: fmt:: Result
365+ where
366+ // rustc rejects trivial bounds, but it cannot see through higher-ranked bounds
367+ // with its check :^)
368+ $( for <$db_lt> $field_ty: std:: fmt:: Debug ) ,*
369+ {
370+ $zalsa:: with_attached_database( |db| {
371+ let zalsa = db. zalsa( ) ;
372+ let fields = $Configuration:: ingredient( zalsa) . fields( zalsa, this) ;
373+ let mut f = f. debug_struct( stringify!( $Struct) ) ;
374+ $(
375+ let f = f. field( stringify!( $field_id) , & fields. $field_index) ;
376+ ) *
377+ f. finish( )
378+ } ) . unwrap_or_else( || {
379+ f. debug_tuple( stringify!( $Struct) )
380+ . field( & $zalsa:: AsId :: as_id( & this) )
381+ . finish( )
382+ } )
383+ }
384+ }
349385 }
350386 }
351387 } ;
0 commit comments