@@ -102,6 +102,7 @@ impl ItemLocation {
102102 }
103103}
104104
105+ /// Checks if the given path is a test/script file.
105106fn is_test_or_script < L > ( path : & Path , paths : & ProjectPathsConfig < L > ) -> bool {
106107 let test_dir = paths. tests . strip_prefix ( & paths. root ) . unwrap_or ( & paths. root ) ;
107108 let script_dir = paths. scripts . strip_prefix ( & paths. root ) . unwrap_or ( & paths. root ) ;
@@ -318,14 +319,6 @@ impl BytecodeDependencyOptimizer<'_> {
318319 BytecodeDependencyOptimizer { asts, paths, sources }
319320 }
320321
321- /// Returns true if the file is not a test or script file.
322- fn is_src_file ( & self , file : & Path ) -> bool {
323- let tests = self . paths . tests . strip_prefix ( & self . paths . root ) . unwrap_or ( & self . paths . root ) ;
324- let scripts = self . paths . scripts . strip_prefix ( & self . paths . root ) . unwrap_or ( & self . paths . root ) ;
325-
326- !file. starts_with ( tests) && !file. starts_with ( scripts)
327- }
328-
329322 fn process ( self ) -> Result < ( ) > {
330323 let mut updates = Updates :: default ( ) ;
331324
@@ -348,7 +341,7 @@ impl BytecodeDependencyOptimizer<'_> {
348341 for ( path, ast) in & self . asts {
349342 let src = self . sources . get ( path) . unwrap ( ) . content . as_str ( ) ;
350343
351- if ! self . is_src_file ( path) {
344+ if is_test_or_script ( path, & self . paths ) {
352345 continue ;
353346 }
354347
@@ -412,7 +405,7 @@ impl BytecodeDependencyOptimizer<'_> {
412405 updates : & mut Updates ,
413406 ) -> Result < ( ) > {
414407 for ( path, ast) in & self . asts {
415- if self . is_src_file ( path) {
408+ if ! is_test_or_script ( path, & self . paths ) {
416409 continue ;
417410 }
418411 let src = self . sources . get ( path) . unwrap ( ) . content . as_str ( ) ;
0 commit comments