@@ -2901,64 +2901,57 @@ impl Build {
29012901 let tool = match tool_opt {
29022902 Some ( t) => t,
29032903 None => {
2904- let compiler = if cfg ! ( windows) && target. os == "windows" {
2904+ let compiler: PathBuf = if cfg ! ( windows) && target. os == "windows" {
29052905 if target. env == "msvc" {
2906- msvc. to_string ( )
2906+ msvc. into ( )
29072907 } else {
29082908 let cc = if target. abi == "llvm" { clang } else { gnu } ;
2909- format ! ( "{cc}.exe" )
2909+ format ! ( "{cc}.exe" ) . into ( )
29102910 }
29112911 } else if target. os == "ios"
29122912 || target. os == "watchos"
29132913 || target. os == "tvos"
29142914 || target. os == "visionos"
29152915 {
2916- clang. to_string ( )
2916+ clang. into ( )
29172917 } else if target. os == "android" {
29182918 autodetect_android_compiler ( & raw_target, gnu, clang)
29192919 } else if target. os == "cloudabi" {
29202920 format ! (
29212921 "{}-{}-{}-{}" ,
29222922 target. full_arch, target. vendor, target. os, traditional
29232923 )
2924+ . into ( )
29242925 } else if target. os == "wasi" {
29252926 self . autodetect_wasi_compiler ( & raw_target, clang)
29262927 } else if target. arch == "wasm32" || target. arch == "wasm64" {
29272928 // Compiling WASM is not currently supported by GCC, so
29282929 // let's default to Clang.
2929- clang. to_string ( )
2930+ clang. into ( )
29302931 } else if target. os == "vxworks" {
2931- if self . cpp {
2932- "wr-c++" . to_string ( )
2933- } else {
2934- "wr-cc" . to_string ( )
2935- }
2932+ if self . cpp { "wr-c++" } else { "wr-cc" } . into ( )
29362933 } else if target. arch == "arm" && target. vendor == "kmc" {
2937- format ! ( "arm-kmc-eabi-{gnu}" )
2934+ format ! ( "arm-kmc-eabi-{gnu}" ) . into ( )
29382935 } else if target. arch == "aarch64" && target. vendor == "kmc" {
2939- format ! ( "aarch64-kmc-elf-{gnu}" )
2936+ format ! ( "aarch64-kmc-elf-{gnu}" ) . into ( )
29402937 } else if target. os == "nto" {
29412938 // See for details: https://github.com/rust-lang/cc-rs/pull/1319
2942- if self . cpp {
2943- "q++" . to_string ( )
2944- } else {
2945- "qcc" . to_string ( )
2946- }
2939+ if self . cpp { "q++" } else { "qcc" } . into ( )
29472940 } else if self . get_is_cross_compile ( ) ? {
29482941 let prefix = self . prefix_for_target ( & raw_target) ;
29492942 match prefix {
29502943 Some ( prefix) => {
29512944 let cc = if target. abi == "llvm" { clang } else { gnu } ;
2952- format ! ( "{prefix}-{cc}" )
2945+ format ! ( "{prefix}-{cc}" ) . into ( )
29532946 }
2954- None => default. to_string ( ) ,
2947+ None => default. into ( ) ,
29552948 }
29562949 } else {
2957- default. to_string ( )
2950+ default. into ( )
29582951 } ;
29592952
29602953 let mut t = Tool :: new (
2961- PathBuf :: from ( compiler) ,
2954+ compiler,
29622955 & self . build_cache . cached_compiler_family ,
29632956 & self . cargo_output ,
29642957 out_dir,
@@ -4178,19 +4171,17 @@ impl Build {
41784171 /// have support for compiling to wasm.
41794172 ///
41804173 /// [wasi-sdk]: https://github.com/WebAssembly/wasi-sdk
4181- fn autodetect_wasi_compiler ( & self , raw_target : & str , clang : & str ) -> String {
4174+ fn autodetect_wasi_compiler ( & self , raw_target : & str , clang : & str ) -> PathBuf {
41824175 if let Some ( path) = self . getenv ( "WASI_SDK_PATH" ) {
41834176 let target_clang = Path :: new ( & path)
41844177 . join ( "bin" )
41854178 . join ( format ! ( "{raw_target}-clang" ) ) ;
41864179 if let Some ( path) = self . which ( & target_clang, None ) {
4187- if let Some ( s) = path. to_str ( ) {
4188- return s. to_string ( ) ;
4189- }
4180+ return path;
41904181 }
41914182 }
41924183
4193- clang. to_string ( )
4184+ clang. into ( )
41944185 }
41954186}
41964187
@@ -4235,7 +4226,7 @@ fn android_clang_compiler_uses_target_arg_internally(clang_path: &Path) -> bool
42354226}
42364227
42374228// FIXME: Use parsed target.
4238- fn autodetect_android_compiler ( raw_target : & str , gnu : & str , clang : & str ) -> String {
4229+ fn autodetect_android_compiler ( raw_target : & str , gnu : & str , clang : & str ) -> PathBuf {
42394230 let new_clang_key = match raw_target {
42404231 "aarch64-linux-android" => Some ( "aarch64" ) ,
42414232 "armv7-linux-androideabi" => Some ( "armv7a" ) ,
@@ -4280,6 +4271,7 @@ fn autodetect_android_compiler(raw_target: &str, gnu: &str, clang: &str) -> Stri
42804271 } else {
42814272 clang_compiler
42824273 }
4274+ . into ( )
42834275}
42844276
42854277// Rust and clang/cc don't agree on how to name the target.
0 commit comments