about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--xtask/tests/tidy.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index 4ac5d929fc6..62626064ee5 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -180,13 +180,11 @@ impl TidyDocs {
 }
 
 fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool {
-    let mut cur_path = p;
-    while let Some(path) = cur_path.parent() {
-        if dirs_to_exclude.iter().any(|dir| path.ends_with(dir)) {
-            return true;
-        }
-        cur_path = path;
-    }
-
-    false
+    p.strip_prefix(project_root())
+        .unwrap()
+        .components()
+        .rev()
+        .skip(1)
+        .filter_map(|it| it.as_os_str().to_str())
+        .any(|it| dirs_to_exclude.contains(&it))
 }