@@ -43,7 +43,8 @@ pub fn cli() -> App {
4343 "edges" ,
4444 "KINDS" ,
4545 "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)",
4748 )
4849 . short ( "e" ) ,
4950 )
@@ -148,7 +149,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
148149 } ;
149150 let target = tree:: Target :: from_cli ( targets) ;
150151
151- let edge_kinds = parse_edge_kinds ( config, args) ?;
152+ let ( edge_kinds, no_proc_macro ) = parse_edge_kinds ( config, args) ?;
152153 let graph_features = edge_kinds. contains ( & EdgeKind :: Feature ) ;
153154
154155 let packages = args. packages_from_flags ( ) ?;
@@ -203,25 +204,51 @@ subtree of the package given to -p.\n\
203204 format : args. value_of ( "format" ) . unwrap ( ) . to_string ( ) ,
204205 graph_features,
205206 max_display_depth : args. value_of_u32 ( "depth" ) ?. unwrap_or ( u32:: MAX ) ,
207+ no_proc_macro,
206208 } ;
207209
210+ if opts. graph_features && opts. duplicates {
211+ return Err ( format_err ! ( "the `-e features` flag does not support `--duplicates`" ) . into ( ) ) ;
212+ }
213+
208214 tree:: build_and_print ( & ws, & opts) ?;
209215 Ok ( ( ) )
210216}
211217
212- fn parse_edge_kinds ( config : & Config , args : & ArgMatches < ' _ > ) -> CargoResult < HashSet < EdgeKind > > {
213- let mut kinds: Vec < & str > = args
214- . values_of ( "edges" )
215- . map_or_else ( || Vec :: new ( ) , |es| es. flat_map ( |e| e. split ( ',' ) ) . collect ( ) ) ;
216- if args. is_present ( "no-dev-dependencies" ) {
217- config
218- . shell ( )
219- . warn ( "the --no-dev-dependencies flag has changed to -e=no-dev" ) ?;
220- kinds. push ( "no-dev" ) ;
221- }
222- if kinds. is_empty ( ) {
223- kinds. extend ( & [ "normal" , "build" , "dev" ] ) ;
224- }
218+ /// Parses `--edges` option.
219+ ///
220+ /// Returns a tuple of `EdgeKind` map and `no_proc_marco` flag.
221+ fn parse_edge_kinds (
222+ config : & Config ,
223+ args : & ArgMatches < ' _ > ,
224+ ) -> CargoResult < ( HashSet < EdgeKind > , bool ) > {
225+ let ( kinds, no_proc_macro) = {
226+ let mut no_proc_macro = false ;
227+ let mut kinds = args. values_of ( "edges" ) . map_or_else (
228+ || Vec :: new ( ) ,
229+ |es| {
230+ es. flat_map ( |e| e. split ( ',' ) )
231+ . filter ( |e| {
232+ no_proc_macro = * e == "no-proc-macro" ;
233+ !no_proc_macro
234+ } )
235+ . collect ( )
236+ } ,
237+ ) ;
238+
239+ if args. is_present ( "no-dev-dependencies" ) {
240+ config
241+ . shell ( )
242+ . warn ( "the --no-dev-dependencies flag has changed to -e=no-dev" ) ?;
243+ kinds. push ( "no-dev" ) ;
244+ }
245+
246+ if kinds. is_empty ( ) {
247+ kinds. extend ( & [ "normal" , "build" , "dev" ] ) ;
248+ }
249+
250+ ( kinds, no_proc_macro)
251+ } ;
225252
226253 let mut result = HashSet :: new ( ) ;
227254 let insert_defaults = |result : & mut HashSet < EdgeKind > | {
@@ -233,7 +260,7 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult<HashS
233260 bail ! (
234261 "unknown edge kind `{}`, valid values are \
235262 \" normal\" , \" build\" , \" dev\" , \
236- \" no-normal\" , \" no-build\" , \" no-dev\" , \
263+ \" no-normal\" , \" no-build\" , \" no-dev\" , \" no-proc-macro \" , \
237264 \" features\" , or \" all\" ",
238265 k
239266 )
@@ -247,12 +274,17 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult<HashS
247274 "no-dev" => result. remove ( & EdgeKind :: Dep ( DepKind :: Development ) ) ,
248275 "features" => result. insert ( EdgeKind :: Feature ) ,
249276 "normal" | "build" | "dev" | "all" => {
250- bail ! ( "`no-` dependency kinds cannot be mixed with other dependency kinds" )
277+ bail ! (
278+ "`{}` dependency kind cannot be mixed with \
279+ \" no-normal\" , \" no-build\" , or \" no-dev\" \
280+ dependency kinds",
281+ kind
282+ )
251283 }
252284 k => return unknown ( k) ,
253285 } ;
254286 }
255- return Ok ( result) ;
287+ return Ok ( ( result, no_proc_macro ) ) ;
256288 }
257289 for kind in & kinds {
258290 match * kind {
@@ -278,5 +310,5 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult<HashS
278310 if kinds. len ( ) == 1 && kinds[ 0 ] == "features" {
279311 insert_defaults ( & mut result) ;
280312 }
281- Ok ( result)
313+ Ok ( ( result, no_proc_macro ) )
282314}
0 commit comments