From 1cb6a1ef259b244bc6c6c25d9627051290a44ba9 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Fri, 3 Feb 2023 21:58:30 +0100 Subject: [PATCH] util toml targets: infer file only if not a dir can either be regular file or a symbolic link previously any entry ending with .rs, including directories, were assumed to be files. --- src/cargo/util/toml/targets.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cargo/util/toml/targets.rs b/src/cargo/util/toml/targets.rs index a2f4153a8c4c..a7e30c61bcec 100644 --- a/src/cargo/util/toml/targets.rs +++ b/src/cargo/util/toml/targets.rs @@ -624,10 +624,10 @@ fn infer_from_directory(directory: &Path) -> Vec<(String, PathBuf)> { } fn infer_any(entry: &DirEntry) -> Option<(String, PathBuf)> { - if entry.path().extension().and_then(|p| p.to_str()) == Some("rs") { - infer_file(entry) - } else if entry.file_type().map(|t| t.is_dir()).ok() == Some(true) { + if entry.file_type().map_or(false, |t| t.is_dir()) { infer_subdirectory(entry) + } else if entry.path().extension().and_then(|p| p.to_str()) == Some("rs") { + infer_file(entry) } else { None }