@@ -43,7 +43,8 @@ pub fn cli() -> App {
43
43
"edges" ,
44
44
"KINDS" ,
45
45
"The kinds of dependencies to display \
46
- (features, normal, build, dev, all, no-dev, no-build, no-normal)",
46
+ (features, normal, build, dev, all, \
47
+ no-normal, no-build, no-dev, no-proc-macro)",
47
48
)
48
49
. short ( "e" ) ,
49
50
)
@@ -147,7 +148,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
147
148
} ;
148
149
let target = tree:: Target :: from_cli ( targets) ;
149
150
150
- let edge_kinds = parse_edge_kinds ( config, args) ?;
151
+ let ( edge_kinds, no_proc_macro ) = parse_edge_kinds ( config, args) ?;
151
152
let graph_features = edge_kinds. contains ( & EdgeKind :: Feature ) ;
152
153
153
154
let packages = args. packages_from_flags ( ) ?;
@@ -201,25 +202,47 @@ subtree of the package given to -p.\n\
201
202
charset,
202
203
format : args. value_of ( "format" ) . unwrap ( ) . to_string ( ) ,
203
204
graph_features,
205
+ no_proc_macro,
204
206
} ;
205
207
206
208
tree:: build_and_print ( & ws, & opts) ?;
207
209
Ok ( ( ) )
208
210
}
209
211
210
- fn parse_edge_kinds ( config : & Config , args : & ArgMatches < ' _ > ) -> CargoResult < HashSet < EdgeKind > > {
211
- let mut kinds: Vec < & str > = args
212
- . values_of ( "edges" )
213
- . map_or_else ( || Vec :: new ( ) , |es| es. flat_map ( |e| e. split ( ',' ) ) . collect ( ) ) ;
214
- if args. is_present ( "no-dev-dependencies" ) {
215
- config
216
- . shell ( )
217
- . warn ( "the --no-dev-dependencies flag has changed to -e=no-dev" ) ?;
218
- kinds. push ( "no-dev" ) ;
219
- }
220
- if kinds. is_empty ( ) {
221
- kinds. extend ( & [ "normal" , "build" , "dev" ] ) ;
222
- }
212
+ /// Parses `--edges` option.
213
+ ///
214
+ /// Returns a tuple of `EdgeKind` map and `no_proc_marco` flag.
215
+ fn parse_edge_kinds (
216
+ config : & Config ,
217
+ args : & ArgMatches < ' _ > ,
218
+ ) -> CargoResult < ( HashSet < EdgeKind > , bool ) > {
219
+ let ( kinds, no_proc_macro) = {
220
+ let mut no_proc_macro = false ;
221
+ let mut kinds = args. values_of ( "edges" ) . map_or_else (
222
+ || Vec :: new ( ) ,
223
+ |es| {
224
+ es. flat_map ( |e| e. split ( ',' ) )
225
+ . filter ( |e| {
226
+ no_proc_macro = * e == "no-proc-macro" ;
227
+ !no_proc_macro
228
+ } )
229
+ . collect ( )
230
+ } ,
231
+ ) ;
232
+
233
+ if args. is_present ( "no-dev-dependencies" ) {
234
+ config
235
+ . shell ( )
236
+ . warn ( "the --no-dev-dependencies flag has changed to -e=no-dev" ) ?;
237
+ kinds. push ( "no-dev" ) ;
238
+ }
239
+
240
+ if kinds. is_empty ( ) {
241
+ kinds. extend ( & [ "normal" , "build" , "dev" ] ) ;
242
+ }
243
+
244
+ ( kinds, no_proc_macro)
245
+ } ;
223
246
224
247
let mut result = HashSet :: new ( ) ;
225
248
let insert_defaults = |result : & mut HashSet < EdgeKind > | {
@@ -231,7 +254,7 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult<HashS
231
254
bail ! (
232
255
"unknown edge kind `{}`, valid values are \
233
256
\" normal\" , \" build\" , \" dev\" , \
234
- \" no-normal\" , \" no-build\" , \" no-dev\" , \
257
+ \" no-normal\" , \" no-build\" , \" no-dev\" , \" no-proc-macro \" , \
235
258
\" features\" , or \" all\" ",
236
259
k
237
260
)
@@ -244,13 +267,18 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult<HashS
244
267
"no-build" => result. remove ( & EdgeKind :: Dep ( DepKind :: Build ) ) ,
245
268
"no-dev" => result. remove ( & EdgeKind :: Dep ( DepKind :: Development ) ) ,
246
269
"features" => result. insert ( EdgeKind :: Feature ) ,
247
- "normal" | "build" | "dev" | "all" => {
248
- bail ! ( "`no-` dependency kinds cannot be mixed with other dependency kinds" )
270
+ k @ "normal" | k @ "build" | k @ "dev" | k @ "all" => {
271
+ bail ! (
272
+ "`{}` dependency kind cannot be mixed with \
273
+ \" no-normal\" , \" no-build\" , or \" no-dev\" \
274
+ dependency kinds",
275
+ k
276
+ )
249
277
}
250
278
k => return unknown ( k) ,
251
279
} ;
252
280
}
253
- return Ok ( result) ;
281
+ return Ok ( ( result, no_proc_macro ) ) ;
254
282
}
255
283
for kind in & kinds {
256
284
match * kind {
@@ -276,5 +304,5 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult<HashS
276
304
if kinds. len ( ) == 1 && kinds[ 0 ] == "features" {
277
305
insert_defaults ( & mut result) ;
278
306
}
279
- Ok ( result)
307
+ Ok ( ( result, no_proc_macro ) )
280
308
}
0 commit comments