@@ -50,7 +50,7 @@ impl Attrs {
50
50
Attrs {
51
51
name : name,
52
52
methods : vec ! [ ] ,
53
- parser : ( Parser :: TryFromStr , quote ! ( :: std:: str :: FromStr :: from_str) ) ,
53
+ parser : ( Parser :: TryFromStr , my_quote ! ( :: std:: str :: FromStr :: from_str) ) ,
54
54
has_custom_parser : false ,
55
55
is_subcommand : false ,
56
56
}
@@ -67,7 +67,7 @@ impl Attrs {
67
67
( "name" , new_name) => self . name = new_name. into ( ) ,
68
68
( name, arg) => self . methods . push ( Method {
69
69
name : name. to_string ( ) ,
70
- args : quote ! ( #arg) ,
70
+ args : my_quote ! ( #arg) ,
71
71
} ) ,
72
72
}
73
73
}
@@ -79,21 +79,21 @@ impl Attrs {
79
79
let iter = attrs. iter ( )
80
80
. filter_map ( |attr| {
81
81
let path = & attr. path ;
82
- match quote ! ( #path) == quote ! ( structopt) {
82
+ match my_quote ! ( #path) == my_quote ! ( structopt) {
83
83
true => Some (
84
84
attr. interpret_meta ( )
85
- . expect ( & format ! ( "invalid structopt syntax: {}" , quote !( attr) ) )
85
+ . expect ( & format ! ( "invalid structopt syntax: {}" , my_quote !( attr) ) )
86
86
) ,
87
87
false => None ,
88
88
}
89
89
} ) .
90
90
flat_map ( |m| match m {
91
91
List ( l) => l. nested ,
92
- tokens => panic ! ( "unsupported syntax: {}" , quote !( #tokens) . to_string( ) ) ,
92
+ tokens => panic ! ( "unsupported syntax: {}" , my_quote !( #tokens) . to_string( ) ) ,
93
93
} )
94
94
. map ( |m| match m {
95
95
Meta ( m) => m,
96
- ref tokens => panic ! ( "unsupported syntax: {}" , quote !( #tokens) . to_string( ) ) ,
96
+ ref tokens => panic ! ( "unsupported syntax: {}" , my_quote !( #tokens) . to_string( ) ) ,
97
97
} ) ;
98
98
for attr in iter {
99
99
match attr {
@@ -102,7 +102,7 @@ impl Attrs {
102
102
NameValue ( MetaNameValue { ident, lit, .. } ) => {
103
103
self . methods . push ( Method {
104
104
name : ident. to_string ( ) ,
105
- args : quote ! ( #lit) ,
105
+ args : my_quote ! ( #lit) ,
106
106
} )
107
107
}
108
108
List ( MetaList { ident, ref nested, .. } ) if ident == "parse" => {
@@ -114,51 +114,51 @@ impl Attrs {
114
114
Meta ( NameValue ( MetaNameValue { ident, lit : Str ( ref v) , .. } ) ) => {
115
115
let function: syn:: Path = v. parse ( ) . expect ( "parser function path" ) ;
116
116
let parser = ident. as_ref ( ) . parse ( ) . unwrap ( ) ;
117
- ( parser, quote ! ( #function) )
117
+ ( parser, my_quote ! ( #function) )
118
118
}
119
119
Meta ( Word ( ref i) ) => {
120
120
use Parser :: * ;
121
121
let parser = i. as_ref ( ) . parse ( ) . unwrap ( ) ;
122
122
let function = match parser {
123
- FromStr => quote ! ( :: std:: convert:: From :: from) ,
124
- TryFromStr => quote ! ( :: std:: str :: FromStr :: from_str) ,
125
- FromOsStr => quote ! ( :: std:: convert:: From :: from) ,
123
+ FromStr => my_quote ! ( :: std:: convert:: From :: from) ,
124
+ TryFromStr => my_quote ! ( :: std:: str :: FromStr :: from_str) ,
125
+ FromOsStr => my_quote ! ( :: std:: convert:: From :: from) ,
126
126
TryFromOsStr => panic ! ( "cannot omit parser function name with `try_from_os_str`" ) ,
127
- FromOccurrences => quote ! ( { |v| v as _} ) ,
127
+ FromOccurrences => my_quote ! ( { |v| v as _} ) ,
128
128
} ;
129
129
( parser, function)
130
130
}
131
- ref l @ _ => panic ! ( "unknown value parser specification: {}" , quote !( #l) ) ,
131
+ ref l @ _ => panic ! ( "unknown value parser specification: {}" , my_quote !( #l) ) ,
132
132
} ;
133
133
}
134
134
List ( MetaList { ident, ref nested, .. } ) if ident == "raw" => {
135
135
for method in nested {
136
136
match * method {
137
137
Meta ( NameValue ( MetaNameValue { ident, lit : Str ( ref v) , .. } ) ) =>
138
138
self . push_raw_method ( ident. as_ref ( ) , v) ,
139
- ref mi @ _ => panic ! ( "unsupported raw entry: {}" , quote !( #mi) ) ,
139
+ ref mi @ _ => panic ! ( "unsupported raw entry: {}" , my_quote !( #mi) ) ,
140
140
}
141
141
}
142
142
}
143
143
Word ( ref w) if w == "subcommand" => self . is_subcommand = true ,
144
144
ref i @ List ( ..) | ref i @ Word ( ..) =>
145
- panic ! ( "unsupported option: {}" , quote !( #i) ) ,
145
+ panic ! ( "unsupported option: {}" , my_quote !( #i) ) ,
146
146
}
147
147
}
148
148
}
149
149
fn push_raw_method ( & mut self , name : & str , args : & LitStr ) {
150
150
let ts: :: proc_macro2:: TokenStream = args. value ( ) . parse ( )
151
- . expect ( & format ! ( "bad parameter {} = {}: the parameter must be valid rust code" , name, quote !( #args) ) ) ;
151
+ . expect ( & format ! ( "bad parameter {} = {}: the parameter must be valid rust code" , name, my_quote !( #args) ) ) ;
152
152
self . methods . push ( Method {
153
153
name : name. to_string ( ) ,
154
- args : quote ! ( #( #ts) * ) ,
154
+ args : my_quote ! ( #( #ts) * ) ,
155
155
} )
156
156
}
157
157
fn push_doc_comment ( & mut self , attrs : & [ Attribute ] , name : & str ) {
158
158
let doc_comments: Vec < _ > = attrs. iter ( )
159
159
. filter_map ( |attr| {
160
160
let path = & attr. path ;
161
- match quote ! ( #path) == quote ! ( doc) {
161
+ match my_quote ! ( #path) == my_quote ! ( doc) {
162
162
true => attr. interpret_meta ( ) ,
163
163
false => None ,
164
164
}
@@ -195,7 +195,7 @@ impl Attrs {
195
195
. join ( "\n " ) ;
196
196
self . methods . push ( Method {
197
197
name : name. to_string ( ) ,
198
- args : quote ! ( #arg) ,
198
+ args : my_quote ! ( #arg) ,
199
199
} ) ;
200
200
}
201
201
pub fn from_struct ( attrs : & [ Attribute ] , name : String ) -> Attrs {
@@ -243,9 +243,9 @@ impl Attrs {
243
243
pub fn methods ( & self ) -> Tokens {
244
244
let methods = self . methods . iter ( ) . map ( |& Method { ref name, ref args } | {
245
245
let name: :: syn:: Ident = name. as_str ( ) . into ( ) ;
246
- quote ! ( . #name( #args) )
246
+ my_quote ! ( . #name( #args) )
247
247
} ) ;
248
- quote ! ( #( #methods) * )
248
+ my_quote ! ( #( #methods) * )
249
249
}
250
250
pub fn name ( & self ) -> & str {
251
251
& self . name
0 commit comments