@@ -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,16 +271,17 @@ 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
+ let mut result = false ;
277
+ for n in needles. iter_mut ( ) {
278
+ let matched = Self :: check ( p, & n. path , module) ;
278
279
if matched {
279
- needles . remove ( i ) ;
280
- return true ;
280
+ n . will_be_executed = true ;
281
+ result = true ;
281
282
}
282
283
}
283
- false
284
+ result
284
285
} ;
285
286
match self {
286
287
PathSet :: Set ( set) => PathSet :: Set ( set. iter ( ) . filter ( |& p| check ( p) ) . cloned ( ) . collect ( ) ) ,
@@ -361,6 +362,32 @@ fn remap_paths(paths: &mut Vec<PathBuf>) {
361
362
paths. append ( & mut add) ;
362
363
}
363
364
365
+ #[ derive( Clone , PartialEq ) ]
366
+ struct CLIStepPath {
367
+ path : PathBuf ,
368
+ will_be_executed : bool ,
369
+ }
370
+
371
+ #[ cfg( test) ]
372
+ impl CLIStepPath {
373
+ fn will_be_executed ( mut self , will_be_executed : bool ) -> Self {
374
+ self . will_be_executed = will_be_executed;
375
+ self
376
+ }
377
+ }
378
+
379
+ impl Debug for CLIStepPath {
380
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
381
+ write ! ( f, "{}" , self . path. display( ) )
382
+ }
383
+ }
384
+
385
+ impl From < PathBuf > for CLIStepPath {
386
+ fn from ( path : PathBuf ) -> Self {
387
+ Self { path, will_be_executed : false }
388
+ }
389
+ }
390
+
364
391
impl StepDescription {
365
392
fn from < S : Step > ( kind : Kind ) -> StepDescription {
366
393
StepDescription {
@@ -478,7 +505,8 @@ impl StepDescription {
478
505
return ;
479
506
}
480
507
481
- let mut path_lookup: Vec < ( PathBuf , bool ) > =
508
+ let mut paths: Vec < CLIStepPath > = paths. into_iter ( ) . map ( |p| p. into ( ) ) . collect ( ) ;
509
+ let mut path_lookup: Vec < ( CLIStepPath , bool ) > =
482
510
paths. clone ( ) . into_iter ( ) . map ( |p| ( p, false ) ) . collect ( ) ;
483
511
484
512
// List of `(usize, &StepDescription, Vec<PathSet>)` where `usize` is the closest index of a path
@@ -518,8 +546,10 @@ impl StepDescription {
518
546
}
519
547
}
520
548
549
+ paths. retain ( |p| !p. will_be_executed ) ;
550
+
521
551
if !paths. is_empty ( ) {
522
- eprintln ! ( "ERROR: no `{}` rules matched {:?}" , builder. kind. as_str( ) , paths, ) ;
552
+ eprintln ! ( "ERROR: no `{}` rules matched {:?}" , builder. kind. as_str( ) , paths) ;
523
553
eprintln ! (
524
554
"HELP: run `x.py {} --help --verbose` to show a list of available paths" ,
525
555
builder. kind. as_str( )
@@ -682,7 +712,7 @@ impl<'a> ShouldRun<'a> {
682
712
/// (for now, just `all_krates` and `paths`, but we may want to add an `aliases` function in the future?)
683
713
fn pathset_for_paths_removing_matches (
684
714
& self ,
685
- paths : & mut Vec < PathBuf > ,
715
+ paths : & mut [ CLIStepPath ] ,
686
716
kind : Kind ,
687
717
) -> Vec < PathSet > {
688
718
let mut sets = vec ! [ ] ;
@@ -825,12 +855,8 @@ impl<'a> Builder<'a> {
825
855
match kind {
826
856
Kind :: Build => describe ! (
827
857
compile:: Std ,
828
- // FIXME(#135022): `compile::Assemble` **must** come before `compile::Rustc` after
829
- // `PathSet` also permits prefix-matching, because `compile::Rustc` can consume the
830
- // `"compiler"` path filter first, causing `compile::Assemble` to no longer run when
831
- // the user writes `./x build compiler --stage 0`.
832
- compile:: Assemble ,
833
858
compile:: Rustc ,
859
+ compile:: Assemble ,
834
860
compile:: CodegenBackend ,
835
861
compile:: StartupObjects ,
836
862
tool:: BuildManifest ,
@@ -929,14 +955,10 @@ impl<'a> Builder<'a> {
929
955
test:: Rustdoc ,
930
956
test:: CoverageRunRustdoc ,
931
957
test:: Pretty ,
932
- test:: Crate ,
933
- test:: CrateLibrustc ,
934
- // The cranelift and gcc tests need to be listed after the
935
- // compiler unit tests (CrateLibrustc) so that they don't
936
- // hijack the whole `compiler` directory during path matching.
937
- // <https://github.com/rust-lang/rust/pull/134919>
938
958
test:: CodegenCranelift ,
939
959
test:: CodegenGCC ,
960
+ test:: Crate ,
961
+ test:: CrateLibrustc ,
940
962
test:: CrateRustdoc ,
941
963
test:: CrateRustdocJsonTypes ,
942
964
test:: CrateBootstrap ,
0 commit comments