44use std:: {
55 env:: current_dir,
66 fmt:: { self , Display } ,
7- fs,
87 path:: { Path , PathBuf } ,
9- process:: Command ,
108 sync:: { Arc , Mutex } ,
119} ;
1210
@@ -15,7 +13,7 @@ use anyhow::{anyhow, Context, Result};
1513use git2:: { DiffOptions , Patch } ;
1614use regex:: Regex ;
1715use semver:: Version ;
18- use tokio:: task:: JoinSet ;
16+ use tokio:: { fs , process :: Command , task:: JoinSet } ;
1917use which:: { which, which_in} ;
2018
2119// project-specific modules/crates
@@ -115,8 +113,8 @@ impl ClangTool {
115113 }
116114
117115 /// Run `clang-tool --version`, then extract and return the version number.
118- fn capture_version ( clang_tool : & PathBuf ) -> Result < String > {
119- let output = Command :: new ( clang_tool) . arg ( "--version" ) . output ( ) ?;
116+ async fn capture_version ( clang_tool : & PathBuf ) -> Result < String > {
117+ let output = Command :: new ( clang_tool) . arg ( "--version" ) . output ( ) . await ?;
120118 let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
121119 let version_pattern = Regex :: new ( r"(?i)version[^\d]*([\d.]+)" ) . unwrap ( ) ;
122120 let captures = version_pattern. captures ( & stdout) . ok_or ( anyhow ! (
@@ -212,7 +210,7 @@ pub async fn capture_clang_tools_output(
212210 // info as debugging output.
213211 if clang_params. tidy_checks != "-*" {
214212 let exe_path = ClangTool :: ClangTidy . get_exe_path ( version) ?;
215- let version_found = ClangTool :: capture_version ( & exe_path) ?;
213+ let version_found = ClangTool :: capture_version ( & exe_path) . await ?;
216214 log:: debug!(
217215 "{} --version: v{version_found}" ,
218216 & exe_path. to_string_lossy( )
@@ -222,7 +220,7 @@ pub async fn capture_clang_tools_output(
222220 }
223221 if !clang_params. style . is_empty ( ) {
224222 let exe_path = ClangTool :: ClangFormat . get_exe_path ( version) ?;
225- let version_found = ClangTool :: capture_version ( & exe_path) ?;
223+ let version_found = ClangTool :: capture_version ( & exe_path) . await ?;
226224 log:: debug!(
227225 "{} --version: v{version_found}" ,
228226 & exe_path. to_string_lossy( )
@@ -233,7 +231,7 @@ pub async fn capture_clang_tools_output(
233231
234232 // parse database (if provided) to match filenames when parsing clang-tidy's stdout
235233 if let Some ( db_path) = & clang_params. database {
236- if let Ok ( db_str) = fs:: read ( db_path. join ( "compile_commands.json" ) ) {
234+ if let Ok ( db_str) = fs:: read ( db_path. join ( "compile_commands.json" ) ) . await {
237235 clang_params. database_json = Some (
238236 // A compilation database should be UTF-8 encoded, but file paths are not; use lossy conversion.
239237 serde_json:: from_str :: < Vec < CompilationUnit > > ( & String :: from_utf8_lossy ( & db_str) )
0 commit comments