@@ -2992,197 +2992,175 @@ macro_rules! valueset_all {
29922992macro_rules! valueset {
29932993
29942994 // === base case ===
2995- ( @ { $( , ) * $( $val: expr) ,* $( , ) * } , $next: expr $( , ) * ) => {
2996- & [ $( $val) ,* ]
2997- } ;
2995+ ( @ $fields: expr, { $( , ) * $( ( $field: expr, $val: expr) ) ,* $( , ) * } $( , ) * ) => { {
2996+ use $crate:: __macro_support:: Callsite as _;
2997+ // create a dummy callsite to get a bogus field.
2998+ static __CALLSITE: $crate:: callsite:: DefaultCallsite = $crate:: callsite2! {
2999+ name: "__fake_tracing_callsite" ,
3000+ kind: $crate:: metadata:: Kind :: SPAN ,
3001+ target: module_path!( ) ,
3002+ level: $crate:: Level :: TRACE ,
3003+ fields: $crate:: fieldset!( "__fake_tracing_field" = "fake_tracing_value" ) ,
3004+ } ;
3005+
3006+ & [
3007+ $(
3008+ (
3009+ & $fields. field( $field) . unwrap_or_else( || __CALLSITE. metadata( ) . fields( ) . iter( ) . next( ) . unwrap( ) ) ,
3010+ $val,
3011+ ) ,
3012+ ) *
3013+ ]
3014+ } } ;
29983015
29993016 // === recursive case (more tts) ===
30003017
3001- // TODO(#1138): determine a new syntax for uninitialized span fields, and
3002- // re-enable this.
3003- // (@{ $(,)* $($out:expr),* }, $next:expr, $($k:ident).+ = _, $($rest:tt)*) => {
3004- // $crate::valueset!(@ { $($out),*, (&$next, None) }, $next, $($rest)*)
3005- // };
3006- ( @ { $( , ) * $( $out: expr) ,* } , $next: expr, $( $k: ident) .+ = ?$val: expr, $( $rest: tt) * ) => {
3018+ ( @ $fields: expr, { $( , ) * $( ( $field: expr, $out: expr) ) ,* } , $( $k: ident) .+ = ?$val: expr, $( $rest: tt) * ) => {
30073019 $crate:: valueset!(
3008- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
3009- $next,
3020+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
30103021 $( $rest) *
30113022 )
30123023 } ;
3013- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $( $k: ident) .+ = %$val: expr, $( $rest: tt) * ) => {
3024+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $( $k: ident) .+ = %$val: expr, $( $rest: tt) * ) => {
30143025 $crate:: valueset!(
3015- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
3016- $next,
3026+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
30173027 $( $rest) *
30183028 )
30193029 } ;
3020- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $( $k: ident) .+ = $val: expr, $( $rest: tt) * ) => {
3030+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $( $k: ident) .+ = $val: expr, $( $rest: tt) * ) => {
30213031 $crate:: valueset!(
3022- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
3023- $next,
3032+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
30243033 $( $rest) *
30253034 )
30263035 } ;
3027- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $( $k: ident) .+, $( $rest: tt) * ) => {
3036+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $( $k: ident) .+, $( $rest: tt) * ) => {
30283037 $crate:: valueset!(
3029- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $( $k) .+ as & dyn $crate:: field:: Value ) ) } ,
3030- $next,
3038+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $( $k) .+ as & dyn $crate:: field:: Value ) ) } ,
30313039 $( $rest) *
30323040 )
30333041 } ;
3034- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , ?$( $k: ident) .+, $( $rest: tt) * ) => {
3042+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , ?$( $k: ident) .+, $( $rest: tt) * ) => {
30353043 $crate:: valueset!(
3036- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $( $k) .+) as & dyn $crate:: field:: Value ) ) } ,
3037- $next,
3044+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $( $k) .+) as & dyn $crate:: field:: Value ) ) } ,
30383045 $( $rest) *
30393046 )
30403047 } ;
3041- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , %$( $k: ident) .+, $( $rest: tt) * ) => {
3048+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , %$( $k: ident) .+, $( $rest: tt) * ) => {
30423049 $crate:: valueset!(
3043- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $( $k) .+) as & dyn $crate:: field:: Value ) ) } ,
3044- $next,
3050+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $( $k) .+) as & dyn $crate:: field:: Value ) ) } ,
30453051 $( $rest) *
30463052 )
30473053 } ;
3048- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $( $k: ident) .+ = ?$val: expr) => {
3054+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $( $k: ident) .+ = ?$val: expr) => {
30493055 $crate:: valueset!(
3050- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
3051- $next,
3056+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
30523057 )
30533058 } ;
3054- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $( $k: ident) .+ = %$val: expr) => {
3059+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $( $k: ident) .+ = %$val: expr) => {
30553060 $crate:: valueset!(
3056- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
3057- $next,
3061+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
30583062 )
30593063 } ;
3060- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $( $k: ident) .+ = $val: expr) => {
3064+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $( $k: ident) .+ = $val: expr) => {
30613065 $crate:: valueset!(
3062- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
3063- $next,
3066+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
30643067 )
30653068 } ;
3066- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $( $k: ident) .+) => {
3069+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $( $k: ident) .+) => {
30673070 $crate:: valueset!(
3068- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $( $k) .+ as & dyn $crate:: field:: Value ) ) } ,
3069- $next,
3071+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $( $k) .+ as & dyn $crate:: field:: Value ) ) } ,
30703072 )
30713073 } ;
3072- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , ?$( $k: ident) .+) => {
3074+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , ?$( $k: ident) .+) => {
30733075 $crate:: valueset!(
3074- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $( $k) .+) as & dyn $crate:: field:: Value ) ) } ,
3075- $next,
3076+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $( $k) .+) as & dyn $crate:: field:: Value ) ) } ,
30763077 )
30773078 } ;
3078- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , %$( $k: ident) .+) => {
3079+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , %$( $k: ident) .+) => {
30793080 $crate:: valueset!(
3080- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $( $k) .+) as & dyn $crate:: field:: Value ) ) } ,
3081- $next,
3081+ @ $fields, { $( ( $field, $out) ) ,* , ( $crate:: __tracing_stringify!( $( $k) .+) , $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $( $k) .+) as & dyn $crate:: field:: Value ) ) } ,
30823082 )
30833083 } ;
30843084
30853085 // Handle literal names
3086- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $k: literal = ?$val: expr, $( $rest: tt) * ) => {
3086+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $k: literal = ?$val: expr, $( $rest: tt) * ) => {
30873087 $crate:: valueset!(
3088- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
3089- $next,
3088+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
30903089 $( $rest) *
30913090 )
30923091 } ;
3093- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $k: literal = %$val: expr, $( $rest: tt) * ) => {
3092+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $k: literal = %$val: expr, $( $rest: tt) * ) => {
30943093 $crate:: valueset!(
3095- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
3096- $next,
3094+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
30973095 $( $rest) *
30983096 )
30993097 } ;
3100- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $k: literal = $val: expr, $( $rest: tt) * ) => {
3098+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $k: literal = $val: expr, $( $rest: tt) * ) => {
31013099 $crate:: valueset!(
3102- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
3103- $next,
3100+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, $crate:: __macro_support:: Option :: Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
31043101 $( $rest) *
31053102 )
31063103 } ;
3107- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $k: literal = ?$val: expr) => {
3104+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $k: literal = ?$val: expr) => {
31083105 $crate:: valueset!(
3109- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
3110- $next,
3106+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
31113107 )
31123108 } ;
3113- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $k: literal = %$val: expr) => {
3109+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $k: literal = %$val: expr) => {
31143110 $crate:: valueset!(
3115- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
3116- $next,
3111+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, $crate:: __macro_support:: Option :: Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
31173112 )
31183113 } ;
3119- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , $k: literal = $val: expr) => {
3114+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , $k: literal = $val: expr) => {
31203115 $crate:: valueset!(
3121- @ { $( $out) ,* , ( & $next, $crate:: __macro_support:: Option :: Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
3122- $next,
3116+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, $crate:: __macro_support:: Option :: Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
31233117 )
31243118 } ;
31253119
31263120 // Handle constant names
3127- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , { $k: expr } = ?$val: expr, $( $rest: tt) * ) => {
3121+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , { $k: expr } = ?$val: expr, $( $rest: tt) * ) => {
31283122 $crate:: valueset!(
3129- @ { $( $out) ,* , ( & $next, Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
3130- $next,
3123+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
31313124 $( $rest) *
31323125 )
31333126 } ;
3134- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , { $k: expr } = %$val: expr, $( $rest: tt) * ) => {
3127+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , { $k: expr } = %$val: expr, $( $rest: tt) * ) => {
31353128 $crate:: valueset!(
3136- @ { $( $out) ,* , ( & $next, Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
3137- $next,
3129+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
31383130 $( $rest) *
31393131 )
31403132 } ;
3141- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , { $k: expr } = $val: expr, $( $rest: tt) * ) => {
3133+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , { $k: expr } = $val: expr, $( $rest: tt) * ) => {
31423134 $crate:: valueset!(
3143- @ { $( $out) ,* , ( & $next, Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
3144- $next,
3135+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
31453136 $( $rest) *
31463137 )
31473138 } ;
3148- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , { $k: expr } = ?$val: expr) => {
3139+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , { $k: expr } = ?$val: expr) => {
31493140 $crate:: valueset!(
3150- @ { $( $out) ,* , ( & $next, Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
3151- $next,
3141+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, Some ( & $crate:: field:: debug( & $val) as & dyn $crate:: field:: Value ) ) } ,
31523142 )
31533143 } ;
3154- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , { $k: expr } = %$val: expr) => {
3144+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , { $k: expr } = %$val: expr) => {
31553145 $crate:: valueset!(
3156- @ { $( $out) ,* , ( & $next, Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
3157- $next,
3146+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, Some ( & $crate:: field:: display( & $val) as & dyn $crate:: field:: Value ) ) } ,
31583147 )
31593148 } ;
3160- ( @ { $( , ) * $( $ out: expr) ,* } , $next : expr , { $k: expr } = $val: expr) => {
3149+ ( @ $fields : expr , { $( , ) * $( ( $field : expr , $ out: expr) ) ,* } , { $k: expr } = $val: expr) => {
31613150 $crate:: valueset!(
3162- @ { $( $out) ,* , ( & $next, Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
3163- $next,
3164- )
3165- } ;
3166-
3167- // Remainder is unparsable, but exists --- must be format args!
3168- ( @ { $( , ) * $( $out: expr) ,* } , $next: expr, $( $rest: tt) +) => {
3169- $crate:: valueset!(
3170- @ { ( & $next, $crate:: __macro_support:: Option :: Some ( & $crate:: __macro_support:: format_args!( $( $rest) +) as & dyn $crate:: field:: Value ) ) , $( $out) ,* } ,
3171- $next,
3151+ @ $fields, { $( ( $field, $out) ) ,* , ( $k, Some ( & $val as & dyn $crate:: field:: Value ) ) } ,
31723152 )
31733153 } ;
31743154
31753155 // === entry ===
31763156 ( $fields: expr, $( $kvs: tt) +) => {
31773157 {
3178- let mut iter = $fields. iter( ) ;
31793158 #[ allow( unused_imports) ]
31803159 // This import statement CANNOT be removed as it will break existing use cases.
31813160 // See #831, #2332, #3424 for the last times we tried.
31823161 use $crate:: field:: { debug, display, Value } ;
31833162 $fields. value_set( $crate:: valueset!(
3184- @ { } ,
3185- $crate:: __macro_support:: Iterator :: next( & mut iter) . expect( "FieldSet corrupted (this is a bug)" ) ,
3163+ @ $fields, { } ,
31863164 $( $kvs) +
31873165 ) )
31883166 }
0 commit comments