@@ -3,7 +3,7 @@ mod cargo;
33use std:: any:: { Any , type_name} ;
44use std:: cell:: { Cell , RefCell } ;
55use std:: collections:: BTreeSet ;
6- use std:: fmt:: { Debug , Write } ;
6+ use std:: fmt:: { self , Debug , Write } ;
77use std:: hash:: Hash ;
88use std:: ops:: Deref ;
99use std:: path:: { Path , PathBuf } ;
@@ -271,12 +271,12 @@ impl PathSet {
271271 /// This is used for `StepDescription::krate`, which passes all matching crates at once to
272272 /// `Step::make_run`, rather than calling it many times with a single crate.
273273 /// See `tests.rs` for examples.
274- fn intersection_removing_matches ( & self , needles : & mut Vec < PathBuf > , module : Kind ) -> PathSet {
274+ fn intersection_removing_matches ( & self , needles : & mut [ CLIStepPath ] , module : Kind ) -> PathSet {
275275 let mut check = |p| {
276- for ( i , n ) in needles. iter ( ) . enumerate ( ) {
277- let matched = Self :: check ( p, n , module) ;
276+ for n in needles. iter_mut ( ) {
277+ let matched = Self :: check ( p, & n . path , module) ;
278278 if matched {
279- needles . remove ( i ) ;
279+ n . will_be_executed = true ;
280280 return true ;
281281 }
282282 }
@@ -361,6 +361,24 @@ fn remap_paths(paths: &mut Vec<PathBuf>) {
361361 paths. append ( & mut add) ;
362362}
363363
364+ #[ derive( Clone , PartialEq ) ]
365+ struct CLIStepPath {
366+ path : PathBuf ,
367+ will_be_executed : bool ,
368+ }
369+
370+ impl Debug for CLIStepPath {
371+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
372+ write ! ( f, "{}" , self . path. display( ) )
373+ }
374+ }
375+
376+ impl From < PathBuf > for CLIStepPath {
377+ fn from ( path : PathBuf ) -> Self {
378+ Self { path, will_be_executed : false }
379+ }
380+ }
381+
364382impl StepDescription {
365383 fn from < S : Step > ( kind : Kind ) -> StepDescription {
366384 StepDescription {
@@ -478,7 +496,8 @@ impl StepDescription {
478496 return ;
479497 }
480498
481- let mut path_lookup: Vec < ( PathBuf , bool ) > =
499+ let mut paths: Vec < CLIStepPath > = paths. into_iter ( ) . map ( |p| p. into ( ) ) . collect ( ) ;
500+ let mut path_lookup: Vec < ( CLIStepPath , bool ) > =
482501 paths. clone ( ) . into_iter ( ) . map ( |p| ( p, false ) ) . collect ( ) ;
483502
484503 // List of `(usize, &StepDescription, Vec<PathSet>)` where `usize` is the closest index of a path
@@ -518,8 +537,10 @@ impl StepDescription {
518537 }
519538 }
520539
540+ paths. retain ( |p| !p. will_be_executed ) ;
541+
521542 if !paths. is_empty ( ) {
522- eprintln ! ( "ERROR: no `{}` rules matched {:?}" , builder. kind. as_str( ) , paths, ) ;
543+ eprintln ! ( "ERROR: no `{}` rules matched {:?}" , builder. kind. as_str( ) , paths) ;
523544 eprintln ! (
524545 "HELP: run `x.py {} --help --verbose` to show a list of available paths" ,
525546 builder. kind. as_str( )
@@ -682,7 +703,7 @@ impl<'a> ShouldRun<'a> {
682703 /// (for now, just `all_krates` and `paths`, but we may want to add an `aliases` function in the future?)
683704 fn pathset_for_paths_removing_matches (
684705 & self ,
685- paths : & mut Vec < PathBuf > ,
706+ paths : & mut [ CLIStepPath ] ,
686707 kind : Kind ,
687708 ) -> Vec < PathSet > {
688709 let mut sets = vec ! [ ] ;
0 commit comments