@@ -3,7 +3,7 @@ mod cargo;
3
3
use std:: any:: { Any , type_name} ;
4
4
use std:: cell:: { Cell , RefCell } ;
5
5
use std:: collections:: BTreeSet ;
6
- use std:: fmt:: { Debug , Write } ;
6
+ use std:: fmt:: { self , Debug , Write } ;
7
7
use std:: hash:: Hash ;
8
8
use std:: ops:: Deref ;
9
9
use std:: path:: { Path , PathBuf } ;
@@ -271,12 +271,12 @@ impl PathSet {
271
271
/// This is used for `StepDescription::krate`, which passes all matching crates at once to
272
272
/// `Step::make_run`, rather than calling it many times with a single crate.
273
273
/// 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 {
275
275
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) ;
278
278
if matched {
279
- needles . remove ( i ) ;
279
+ n . will_be_executed = true ;
280
280
return true ;
281
281
}
282
282
}
@@ -361,6 +361,24 @@ fn remap_paths(paths: &mut Vec<PathBuf>) {
361
361
paths. append ( & mut add) ;
362
362
}
363
363
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
+
364
382
impl StepDescription {
365
383
fn from < S : Step > ( kind : Kind ) -> StepDescription {
366
384
StepDescription {
@@ -478,7 +496,8 @@ impl StepDescription {
478
496
return ;
479
497
}
480
498
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 ) > =
482
501
paths. clone ( ) . into_iter ( ) . map ( |p| ( p, false ) ) . collect ( ) ;
483
502
484
503
// List of `(usize, &StepDescription, Vec<PathSet>)` where `usize` is the closest index of a path
@@ -518,8 +537,10 @@ impl StepDescription {
518
537
}
519
538
}
520
539
540
+ paths. retain ( |p| !p. will_be_executed ) ;
541
+
521
542
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) ;
523
544
eprintln ! (
524
545
"HELP: run `x.py {} --help --verbose` to show a list of available paths" ,
525
546
builder. kind. as_str( )
@@ -682,7 +703,7 @@ impl<'a> ShouldRun<'a> {
682
703
/// (for now, just `all_krates` and `paths`, but we may want to add an `aliases` function in the future?)
683
704
fn pathset_for_paths_removing_matches (
684
705
& self ,
685
- paths : & mut Vec < PathBuf > ,
706
+ paths : & mut [ CLIStepPath ] ,
686
707
kind : Kind ,
687
708
) -> Vec < PathSet > {
688
709
let mut sets = vec ! [ ] ;
0 commit comments