@@ -8,7 +8,7 @@ use std::fs::{self, File};
88use std:: hash:: Hash ;
99use std:: io:: { BufRead , BufReader } ;
1010use std:: ops:: Deref ;
11- use std:: path:: { Component , Path , PathBuf } ;
11+ use std:: path:: { Path , PathBuf } ;
1212use std:: process:: Command ;
1313use std:: time:: { Duration , Instant } ;
1414
@@ -150,29 +150,6 @@ pub struct TaskPath {
150150 pub kind : Option < Kind > ,
151151}
152152
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-
176153impl Debug for TaskPath {
177154 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
178155 if let Some ( kind) = & self . kind {
@@ -216,17 +193,17 @@ impl PathSet {
216193 PathSet :: Set ( set)
217194 }
218195
219- fn has ( & self , needle : & Path , module : Option < Kind > ) -> bool {
196+ fn has ( & self , needle : & Path , module : Kind ) -> bool {
220197 match self {
221198 PathSet :: Set ( set) => set. iter ( ) . any ( |p| Self :: check ( p, needle, module) ) ,
222199 PathSet :: Suite ( suite) => Self :: check ( suite, needle, module) ,
223200 }
224201 }
225202
226203 // 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
230207 } else {
231208 p. path . ends_with ( needle)
232209 }
@@ -238,11 +215,7 @@ impl PathSet {
238215 /// This is used for `StepDescription::krate`, which passes all matching crates at once to
239216 /// `Step::make_run`, rather than calling it many times with a single crate.
240217 /// 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 {
246219 let mut check = |p| {
247220 for ( i, n) in needles. iter ( ) . enumerate ( ) {
248221 let matched = Self :: check ( p, n, module) ;
@@ -307,7 +280,7 @@ impl StepDescription {
307280 }
308281
309282 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 ) ) {
311284 println ! ( "Skipping {:?} because it is excluded" , pathset) ;
312285 return true ;
313286 }
@@ -562,7 +535,7 @@ impl<'a> ShouldRun<'a> {
562535 ) -> Vec < PathSet > {
563536 let mut sets = vec ! [ ] ;
564537 for pathset in & self . paths {
565- let subset = pathset. intersection_removing_matches ( paths, Some ( kind) ) ;
538+ let subset = pathset. intersection_removing_matches ( paths, kind) ;
566539 if subset != PathSet :: empty ( ) {
567540 sets. push ( subset) ;
568541 }
@@ -2130,7 +2103,7 @@ impl<'a> Builder<'a> {
21302103 let should_run = ( desc. should_run ) ( ShouldRun :: new ( self , desc. kind ) ) ;
21312104
21322105 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 ) )
21342107 && !desc. is_excluded (
21352108 self ,
21362109 & PathSet :: Suite ( TaskPath { path : path. clone ( ) , kind : Some ( desc. kind ) } ) ,
0 commit comments