@@ -107,6 +107,18 @@ struct StepDescription {
107
107
name : & ' static str ,
108
108
}
109
109
110
+ #[ derive( Debug , Clone , PartialOrd , Ord , PartialEq , Eq ) ]
111
+ pub struct TaskPath {
112
+ pub path : PathBuf ,
113
+ pub module : Option < String > ,
114
+ }
115
+
116
+ impl TaskPath {
117
+ pub fn parse ( path : impl Into < PathBuf > ) -> TaskPath {
118
+ TaskPath { path : path. into ( ) , module : None }
119
+ }
120
+ }
121
+
110
122
/// Collection of paths used to match a task rule.
111
123
#[ derive( Debug , Clone , PartialOrd , Ord , PartialEq , Eq ) ]
112
124
pub enum PathSet {
@@ -115,14 +127,14 @@ pub enum PathSet {
115
127
/// These are generally matched as a path suffix. For example, a
116
128
/// command-line value of `libstd` will match if `src/libstd` is in the
117
129
/// set.
118
- Set ( BTreeSet < PathBuf > ) ,
130
+ Set ( BTreeSet < TaskPath > ) ,
119
131
/// A "suite" of paths.
120
132
///
121
133
/// These can match as a path suffix (like `Set`), or as a prefix. For
122
134
/// example, a command-line value of `src/test/ui/abi/variadic-ffi.rs`
123
135
/// will match `src/test/ui`. A command-line value of `ui` would also
124
136
/// match `src/test/ui`.
125
- Suite ( PathBuf ) ,
137
+ Suite ( TaskPath ) ,
126
138
}
127
139
128
140
impl PathSet {
@@ -132,21 +144,23 @@ impl PathSet {
132
144
133
145
fn one < P : Into < PathBuf > > ( path : P ) -> PathSet {
134
146
let mut set = BTreeSet :: new ( ) ;
135
- set. insert ( path . into ( ) ) ;
147
+ set. insert ( TaskPath :: parse ( path ) ) ;
136
148
PathSet :: Set ( set)
137
149
}
138
150
139
151
fn has ( & self , needle : & Path ) -> bool {
140
152
match self {
141
- PathSet :: Set ( set) => set. iter ( ) . any ( |p| p. ends_with ( needle) ) ,
142
- PathSet :: Suite ( suite) => suite. ends_with ( needle) ,
153
+ PathSet :: Set ( set) => set. iter ( ) . any ( |p| p. path . ends_with ( needle) ) ,
154
+ PathSet :: Suite ( suite) => suite. path . ends_with ( needle) ,
143
155
}
144
156
}
145
157
146
158
fn path ( & self , builder : & Builder < ' _ > ) -> PathBuf {
147
159
match self {
148
- PathSet :: Set ( set) => set. iter ( ) . next ( ) . unwrap_or ( & builder. build . src ) . to_path_buf ( ) ,
149
- PathSet :: Suite ( path) => PathBuf :: from ( path) ,
160
+ PathSet :: Set ( set) => {
161
+ set. iter ( ) . next ( ) . map ( |p| & p. path ) . unwrap_or ( & builder. build . src ) . clone ( )
162
+ }
163
+ PathSet :: Suite ( path) => path. path . clone ( ) ,
150
164
}
151
165
}
152
166
}
@@ -293,7 +307,7 @@ impl<'a> ShouldRun<'a> {
293
307
let mut set = BTreeSet :: new ( ) ;
294
308
for krate in self . builder . in_tree_crates ( name, None ) {
295
309
let path = krate. local_path ( self . builder ) ;
296
- set. insert ( path) ;
310
+ set. insert ( TaskPath :: parse ( path) ) ;
297
311
}
298
312
self . paths . insert ( PathSet :: Set ( set) ) ;
299
313
self
@@ -318,19 +332,19 @@ impl<'a> ShouldRun<'a> {
318
332
319
333
// multiple aliases for the same job
320
334
pub fn paths ( mut self , paths : & [ & str ] ) -> Self {
321
- self . paths . insert ( PathSet :: Set ( paths. iter ( ) . map ( PathBuf :: from ) . collect ( ) ) ) ;
335
+ self . paths . insert ( PathSet :: Set ( paths. iter ( ) . map ( |p| TaskPath :: parse ( p ) ) . collect ( ) ) ) ;
322
336
self
323
337
}
324
338
325
339
pub fn is_suite_path ( & self , path : & Path ) -> Option < & PathSet > {
326
340
self . paths . iter ( ) . find ( |pathset| match pathset {
327
- PathSet :: Suite ( p) => path. starts_with ( p ) ,
341
+ PathSet :: Suite ( p) => path. starts_with ( & p . path ) ,
328
342
PathSet :: Set ( _) => false ,
329
343
} )
330
344
}
331
345
332
346
pub fn suite_path ( mut self , suite : & str ) -> Self {
333
- self . paths . insert ( PathSet :: Suite ( PathBuf :: from ( suite) ) ) ;
347
+ self . paths . insert ( PathSet :: Suite ( TaskPath :: parse ( suite) ) ) ;
334
348
self
335
349
}
336
350
@@ -552,11 +566,11 @@ impl<'a> Builder<'a> {
552
566
match pathset {
553
567
PathSet :: Set ( set) => {
554
568
for path in set {
555
- add_path ( & path) ;
569
+ add_path ( & path. path ) ;
556
570
}
557
571
}
558
572
PathSet :: Suite ( path) => {
559
- add_path ( & path. join ( "..." ) ) ;
573
+ add_path ( & path. path . join ( "..." ) ) ;
560
574
}
561
575
}
562
576
}
@@ -1648,7 +1662,7 @@ impl<'a> Builder<'a> {
1648
1662
1649
1663
for path in & self . paths {
1650
1664
if should_run. paths . iter ( ) . any ( |s| s. has ( path) )
1651
- && !desc. is_excluded ( self , & PathSet :: Suite ( path . clone ( ) ) )
1665
+ && !desc. is_excluded ( self , & PathSet :: Suite ( TaskPath :: parse ( path ) ) )
1652
1666
{
1653
1667
return true ;
1654
1668
}
0 commit comments