@@ -8,7 +8,7 @@ use std::fs::{self, File};
8
8
use std:: hash:: Hash ;
9
9
use std:: io:: { BufRead , BufReader } ;
10
10
use std:: ops:: Deref ;
11
- use std:: path:: { Component , Path , PathBuf } ;
11
+ use std:: path:: { Path , PathBuf } ;
12
12
use std:: process:: Command ;
13
13
use std:: time:: { Duration , Instant } ;
14
14
@@ -150,29 +150,6 @@ pub struct TaskPath {
150
150
pub kind : Option < Kind > ,
151
151
}
152
152
153
- impl TaskPath {
154
- pub fn parse ( path : impl Into < PathBuf > ) -> TaskPath {
155
- let mut kind = None ;
156
- let mut path = path. into ( ) ;
157
-
158
- let mut components = path. components ( ) ;
159
- if let Some ( Component :: Normal ( os_str) ) = components. next ( ) {
160
- if let Some ( str) = os_str. to_str ( ) {
161
- if let Some ( ( found_kind, found_prefix) ) = str. split_once ( "::" ) {
162
- if found_kind. is_empty ( ) {
163
- panic ! ( "empty kind in task path {}" , path. display( ) ) ;
164
- }
165
- kind = Kind :: parse ( found_kind) ;
166
- assert ! ( kind. is_some( ) ) ;
167
- path = Path :: new ( found_prefix) . join ( components. as_path ( ) ) ;
168
- }
169
- }
170
- }
171
-
172
- TaskPath { path, kind }
173
- }
174
- }
175
-
176
153
impl Debug for TaskPath {
177
154
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
178
155
if let Some ( kind) = & self . kind {
@@ -216,17 +193,17 @@ impl PathSet {
216
193
PathSet :: Set ( set)
217
194
}
218
195
219
- fn has ( & self , needle : & Path , module : Option < Kind > ) -> bool {
196
+ fn has ( & self , needle : & Path , module : Kind ) -> bool {
220
197
match self {
221
198
PathSet :: Set ( set) => set. iter ( ) . any ( |p| Self :: check ( p, needle, module) ) ,
222
199
PathSet :: Suite ( suite) => Self :: check ( suite, needle, module) ,
223
200
}
224
201
}
225
202
226
203
// internal use only
227
- fn check ( p : & TaskPath , needle : & Path , module : Option < Kind > ) -> bool {
228
- if let ( Some ( p_kind) , Some ( kind ) ) = ( & p. kind , module ) {
229
- p. path . ends_with ( needle) && * p_kind == kind
204
+ fn check ( p : & TaskPath , needle : & Path , module : Kind ) -> bool {
205
+ if let Some ( p_kind) = & p. kind {
206
+ p. path . ends_with ( needle) && * p_kind == module
230
207
} else {
231
208
p. path . ends_with ( needle)
232
209
}
@@ -238,11 +215,7 @@ impl PathSet {
238
215
/// This is used for `StepDescription::krate`, which passes all matching crates at once to
239
216
/// `Step::make_run`, rather than calling it many times with a single crate.
240
217
/// See `tests.rs` for examples.
241
- fn intersection_removing_matches (
242
- & self ,
243
- needles : & mut Vec < & Path > ,
244
- module : Option < Kind > ,
245
- ) -> PathSet {
218
+ fn intersection_removing_matches ( & self , needles : & mut Vec < & Path > , module : Kind ) -> PathSet {
246
219
let mut check = |p| {
247
220
for ( i, n) in needles. iter ( ) . enumerate ( ) {
248
221
let matched = Self :: check ( p, n, module) ;
@@ -307,7 +280,7 @@ impl StepDescription {
307
280
}
308
281
309
282
fn is_excluded ( & self , builder : & Builder < ' _ > , pathset : & PathSet ) -> bool {
310
- if builder. config . exclude . iter ( ) . any ( |e| pathset. has ( & e. path , Some ( builder. kind ) ) ) {
283
+ if builder. config . exclude . iter ( ) . any ( |e| pathset. has ( & e, builder. kind ) ) {
311
284
println ! ( "Skipping {:?} because it is excluded" , pathset) ;
312
285
return true ;
313
286
}
@@ -562,7 +535,7 @@ impl<'a> ShouldRun<'a> {
562
535
) -> Vec < PathSet > {
563
536
let mut sets = vec ! [ ] ;
564
537
for pathset in & self . paths {
565
- let subset = pathset. intersection_removing_matches ( paths, Some ( kind) ) ;
538
+ let subset = pathset. intersection_removing_matches ( paths, kind) ;
566
539
if subset != PathSet :: empty ( ) {
567
540
sets. push ( subset) ;
568
541
}
@@ -2130,7 +2103,7 @@ impl<'a> Builder<'a> {
2130
2103
let should_run = ( desc. should_run ) ( ShouldRun :: new ( self , desc. kind ) ) ;
2131
2104
2132
2105
for path in & self . paths {
2133
- if should_run. paths . iter ( ) . any ( |s| s. has ( path, Some ( desc. kind ) ) )
2106
+ if should_run. paths . iter ( ) . any ( |s| s. has ( path, desc. kind ) )
2134
2107
&& !desc. is_excluded (
2135
2108
self ,
2136
2109
& PathSet :: Suite ( TaskPath { path : path. clone ( ) , kind : Some ( desc. kind ) } ) ,
0 commit comments