File tree Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ fn fn_string(s: String) {
34
34
let _ = s;
35
35
}
36
36
37
+ #[ instrument( fields( keywords. impl . type . fn = _arg) , skip( _arg) ) ]
38
+ fn fn_keyword_ident_in_field ( _arg : & str ) { }
39
+
37
40
#[ derive( Debug ) ]
38
41
struct HasField {
39
42
my_field : & ' static str ,
@@ -146,6 +149,16 @@ fn string_field() {
146
149
} ) ;
147
150
}
148
151
152
+ #[ test]
153
+ fn keyword_ident_in_field_name ( ) {
154
+ let span = expect:: span ( ) . with_fields (
155
+ expect:: field ( "keywords.impl.type.fn" )
156
+ . with_value ( & "test" )
157
+ . only ( ) ,
158
+ ) ;
159
+ run_test ( span, || fn_keyword_ident_in_field ( "test" ) ) ;
160
+ }
161
+
149
162
fn run_test < F : FnOnce ( ) -> T , T > ( span : NewSpan , fun : F ) {
150
163
let ( collector, handle) = collector:: mock ( )
151
164
. new_span ( span)
Original file line number Diff line number Diff line change @@ -3069,8 +3069,8 @@ macro_rules! level_to_log {
3069
3069
#[ doc( hidden) ]
3070
3070
#[ macro_export]
3071
3071
macro_rules! __tracing_stringify {
3072
- ( $s : expr ) => {
3073
- stringify!( $s )
3072
+ ( $( $t : tt ) * ) => {
3073
+ stringify!( $( $t ) * )
3074
3074
} ;
3075
3075
}
3076
3076
Original file line number Diff line number Diff line change @@ -497,3 +497,15 @@ fn constant_field_name() {
497
497
498
498
handle. assert_finished ( ) ;
499
499
}
500
+
501
+ #[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test:: wasm_bindgen_test) ]
502
+ #[ test]
503
+ fn keyword_ident_in_field_name ( ) {
504
+ let ( collector, handle) = collector:: mock ( )
505
+ . event ( expect:: event ( ) . with_fields ( expect:: field ( "crate" ) . with_value ( & "tracing" ) ) )
506
+ . only ( )
507
+ . run_with_handle ( ) ;
508
+
509
+ with_default ( collector, || error ! ( crate = "tracing" , "message" ) ) ;
510
+ handle. assert_finished ( ) ;
511
+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ use std::thread;
7
7
8
8
use tracing:: {
9
9
collect:: with_default,
10
+ error_span,
10
11
field:: { debug, display} ,
11
12
Level , Span ,
12
13
} ;
@@ -866,3 +867,20 @@ fn constant_field_name() {
866
867
867
868
handle. assert_finished ( ) ;
868
869
}
870
+
871
+ #[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test:: wasm_bindgen_test) ]
872
+ #[ test]
873
+ fn keyword_ident_in_field_name_span_macro ( ) {
874
+ #[ derive( Debug ) ]
875
+ struct Foo ;
876
+
877
+ let ( collector, handle) = collector:: mock ( )
878
+ . new_span ( expect:: span ( ) . with_fields ( expect:: field ( "self" ) . with_value ( & debug ( Foo ) ) . only ( ) ) )
879
+ . only ( )
880
+ . run_with_handle ( ) ;
881
+
882
+ with_default ( collector, || {
883
+ error_span ! ( "span" , self = ?Foo ) ;
884
+ } ) ;
885
+ handle. assert_finished ( ) ;
886
+ }
You can’t perform that action at this time.
0 commit comments