@@ -43,14 +43,14 @@ macro_rules! match_fields {
43
43
// nested cfg_attr prevents older compilers from parsing the new doc = EXPR syntax
44
44
#[ cfg_attr( docsrs, cfg_attr( docsrs,
45
45
doc = "" , // newline
46
- doc = concat!( "This is a more ergonomic wrapper over [`" , stringify! ( $target) , "`]" )
46
+ doc = concat!( "This is a more ergonomic wrapper over [`" , match_fields! ( @stringify_path $target) , "`]" )
47
47
) ) ]
48
48
#[ cfg_attr( not( docsrs) , allow( missing_docs) ) ]
49
49
pub struct $struct_name $( <$struct_generics>) ? {
50
50
$(
51
51
#[ cfg_attr( docsrs, cfg_attr( docsrs, doc = concat!(
52
52
"See [`" , stringify!( $field_name) , "`]" ,
53
- "(" , stringify! ( $target) , "::" , stringify! ( $field_name) , ")"
53
+ "(" , match_fields! ( @stringify_path $target:: $field_name) , ")"
54
54
) ) ) ]
55
55
$( #[ $field_attr] ) *
56
56
pub $field_name : $field_type,
@@ -72,7 +72,14 @@ macro_rules! match_fields {
72
72
} ;
73
73
} ;
74
74
}
75
- }
75
+ } ;
76
+
77
+ // directly calling `stringify!` on a path will put spaces inbetween the :: separators, which
78
+ // then breaks doc linking.
79
+ // For whatever reason (expansion order maybe?), a macro indirection makes the path space-less
80
+ ( @stringify_path $p: path) => {
81
+ stringify!( $p)
82
+ } ;
76
83
}
77
84
78
85
mod consumer;
0 commit comments