Skip to content

Commit 0561896

Browse files
Martina Kollarovaautozimu
authored andcommitted
Fix warning about unknown project type
Result.or() gets executed even when the value is Result::Ok, which causes the warning about "Unknown project type" to show even though the project directory was successfully found. It also unnecessarily traverses the directory tree in search for VCS files.
1 parent 23a8093 commit 0561896

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ pub fn get_rootPath<'a>(path: &'a Path, languageId: &str) -> Result<&'a Path> {
2727
"haskell" => traverse_up(path, |dir| dir.join("stack.yaml").exists())
2828
.or_else(|_| traverse_up(path, |dir| dir.join(".cabal").exists())),
2929
_ => Err(format_err!("Unknown languageId: {}", languageId)),
30-
}.or({
30+
}.or_else(|_| {
3131
traverse_up(path, |dir| {
3232
dir.join(".git").exists() || dir.join(".hg").exists() || dir.join(".svn").exists()
3333
})
3434
})
35-
.or({
35+
.or_else(|_| {
3636
let parent = path.parent()
3737
.ok_or_else(|| format_err!("Failed to get file dir"));
3838
warn!(

0 commit comments

Comments
 (0)