diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1fafe834e..c5ed61457 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -150,6 +150,18 @@ jobs: - run: cargo check --lib - run: cargo check --lib --all-features + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Rust + run: | + rustup toolchain install stable --no-self-update --profile minimal --component rustfmt + rustup default stable + shell: bash + - run: cargo clippy + rustfmt: name: Rustfmt runs-on: ubuntu-latest diff --git a/cc-test/build.rs b/cc-test/build.rs index 695c75473..4097fbbd0 100644 --- a/cc-test/build.rs +++ b/cc-test/build.rs @@ -22,7 +22,7 @@ fn main() { .compile("bar"); let target = std::env::var("TARGET").unwrap(); - let file = target.split("-").next().unwrap(); + let file = target.split('-').next().unwrap(); let file = format!( "src/{}.{}", file, diff --git a/src/com.rs b/src/com.rs index cd2284427..6eea58ee2 100644 --- a/src/com.rs +++ b/src/com.rs @@ -64,7 +64,7 @@ where fn as_unknown(&self) -> &IUnknown { unsafe { &*(self.0 as *mut IUnknown) } } - /// Performs QueryInterface fun. + /// Performs `QueryInterface` fun. pub fn cast(&self) -> Result, i32> where U: Interface, diff --git a/src/lib.rs b/src/lib.rs index 42278a794..24329e9dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -290,7 +290,7 @@ struct Object { impl Object { /// Create a new source file -> object file pair. fn new(src: PathBuf, dst: PathBuf) -> Object { - Object { src: src, dst: dst } + Object { src, dst } } } @@ -694,7 +694,7 @@ impl Build { /// `true`. /// /// The name of the C++ standard library to link is decided by: - /// 1. If [cpp_link_stdlib](Build::cpp_link_stdlib) is set, use its value. + /// 1. If [`cpp_link_stdlib`](Build::cpp_link_stdlib) is set, use its value. /// 2. Else if the `CXXSTDLIB` environment variable is set, use its value. /// 3. Else the default is `libc++` for OS X and BSDs, `libc++_shared` for Android, /// `None` for MSVC and `libstdc++` for anything else. @@ -709,7 +709,7 @@ impl Build { /// the most common compiler flags, e.g. `-std=c++17`, some project-specific /// flags might have to be prefixed with "-Xcompiler" flag, for example as /// `.flag("-Xcompiler").flag("-fpermissive")`. See the documentation for - /// `nvcc`, the CUDA compiler driver, at https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/ + /// `nvcc`, the CUDA compiler driver, at /// for more information. /// /// If enabled, this also implicitly enables C++ support. @@ -1045,7 +1045,7 @@ impl Build { /// Adds a native library modifier that will be added to the /// `rustc-link-lib=static:MODIFIERS=LIBRARY_NAME` metadata line /// emitted for cargo if `cargo_metadata` is enabled. - /// See https://doc.rust-lang.org/rustc/command-line-arguments.html#-l-link-the-generated-crate-to-a-native-library + /// See /// for the list of modifiers accepted by rustc. pub fn link_lib_modifier(&mut self, link_lib_modifier: &str) -> &mut Build { self.link_lib_modifiers.push(link_lib_modifier.into()); @@ -1125,7 +1125,7 @@ impl Build { } else { let mut gnu = String::with_capacity(5 + output.len()); gnu.push_str("lib"); - gnu.push_str(&output); + gnu.push_str(output); gnu.push_str(".a"); (output, gnu) }; @@ -1183,8 +1183,8 @@ impl Build { let atlmfc_lib = compiler .env() .iter() - .find(|&&(ref var, _)| var.as_os_str() == OsStr::new("LIB")) - .and_then(|&(_, ref lib_paths)| { + .find(|&(var, _)| var.as_os_str() == OsStr::new("LIB")) + .and_then(|(_, lib_paths)| { env::split_paths(lib_paths).find(|path| { let sub = Path::new("atlmfc/lib"); path.ends_with(sub) || path.parent().map_or(false, |p| p.ends_with(sub)) @@ -1486,7 +1486,7 @@ impl Build { self.msvc_macro_assembler()? } else { let mut cmd = compiler.to_command(); - for &(ref a, ref b) in self.env.iter() { + for (a, b) in self.env.iter() { cmd.env(a, b); } ( @@ -1532,7 +1532,7 @@ impl Build { pub fn try_expand(&self) -> Result, Error> { let compiler = self.try_get_compiler()?; let mut cmd = compiler.to_command(); - for &(ref a, ref b) in self.env.iter() { + for (a, b) in self.env.iter() { cmd.env(a, b); } cmd.arg("-E"); @@ -1600,7 +1600,8 @@ impl Build { /// Get the compiler that's in use for this configuration. /// - /// This will return a result instead of panicing; see get_compiler() for the complete description. + /// This will return a result instead of panicing; see + /// [`get_compiler()`](Self::get_compiler) for the complete description. pub fn try_get_compiler(&self) -> Result { let opt_level = self.get_opt_level()?; let target = self.get_target()?; @@ -1640,18 +1641,12 @@ impl Build { // CFLAGS/CXXFLAGS, since those variables presumably already contain // the desired set of warnings flags. - if self - .warnings - .unwrap_or(if self.has_flags() { false } else { true }) - { + if self.warnings.unwrap_or(!self.has_flags()) { let wflags = cmd.family.warnings_flags().into(); cmd.push_cc_arg(wflags); } - if self - .extra_warnings - .unwrap_or(if self.has_flags() { false } else { true }) - { + if self.extra_warnings.unwrap_or(!self.has_flags()) { if let Some(wflags) = cmd.family.extra_warnings_flags() { cmd.push_cc_arg(wflags.into()); } @@ -1667,7 +1662,7 @@ impl Build { } } - for &(ref key, ref value) in self.definitions.iter() { + for (key, value) in self.definitions.iter() { if let Some(ref value) = *value { cmd.args.push(format!("-D{}={}", key, value).into()); } else { @@ -2109,29 +2104,29 @@ impl Build { let mut parts = target.split('-'); if let Some(arch) = parts.next() { let arch = &arch[5..]; - if target.contains("linux") && arch.starts_with("64") { - cmd.args.push(("-march=rv64gc").into()); - cmd.args.push("-mabi=lp64d".into()); - } else if target.contains("freebsd") && arch.starts_with("64") { - cmd.args.push(("-march=rv64gc").into()); - cmd.args.push("-mabi=lp64d".into()); - } else if target.contains("netbsd") && arch.starts_with("64") { - cmd.args.push(("-march=rv64gc").into()); - cmd.args.push("-mabi=lp64d".into()); - } else if target.contains("openbsd") && arch.starts_with("64") { - cmd.args.push(("-march=rv64gc").into()); - cmd.args.push("-mabi=lp64d".into()); - } else if target.contains("linux") && arch.starts_with("32") { - cmd.args.push(("-march=rv32gc").into()); - cmd.args.push("-mabi=ilp32d".into()); - } else if arch.starts_with("64") { - cmd.args.push(("-march=rv".to_owned() + arch).into()); - cmd.args.push("-mabi=lp64".into()); + if arch.starts_with("64") { + if target.contains("linux") + | target.contains("freebsd") + | target.contains("netbsd") + | target.contains("linux") + { + cmd.args.push(("-march=rv64gc").into()); + cmd.args.push("-mabi=lp64d".into()); + } else { + cmd.args.push(("-march=rv".to_owned() + arch).into()); + cmd.args.push("-mabi=lp64".into()); + } + } else if arch.starts_with("32") { + if target.contains("linux") { + cmd.args.push(("-march=rv32gc").into()); + cmd.args.push("-mabi=ilp32d".into()); + } else { + cmd.args.push(("-march=rv".to_owned() + arch).into()); + cmd.args.push("-mabi=ilp32".into()); + } } else { - cmd.args.push(("-march=rv".to_owned() + arch).into()); - cmd.args.push("-mabi=ilp32".into()); + cmd.args.push("-mcmodel=medany".into()); } - cmd.args.push("-mcmodel=medany".into()); } } } @@ -2198,7 +2193,7 @@ impl Build { cmd.arg("-g"); } - for &(ref key, ref value) in self.definitions.iter() { + for (key, value) in self.definitions.iter() { cmd.arg("-PreDefine"); if let Some(ref value) = *value { if let Ok(i) = value.parse::() { @@ -2217,7 +2212,7 @@ impl Build { cmd.arg("-Zi"); } - for &(ref key, ref value) in self.definitions.iter() { + for (key, value) in self.definitions.iter() { if let Some(ref value) = *value { cmd.arg(&format!("-D{}={}", key, value)); } else { @@ -2276,9 +2271,9 @@ impl Build { let lib_dst = dst.with_file_name(format!("{}.lib", lib_name)); let _ = fs::remove_file(&lib_dst); - match fs::hard_link(&dst, &lib_dst).or_else(|_| { + match fs::hard_link(dst, &lib_dst).or_else(|_| { // if hard-link fails, just copy (ignoring the number of bytes written) - fs::copy(&dst, &lib_dst).map(|_| ()) + fs::copy(dst, &lib_dst).map(|_| ()) }) { Ok(_) => (), Err(_) => { @@ -2512,7 +2507,7 @@ impl Build { fn cmd>(&self, prog: P) -> Command { let mut cmd = Command::new(prog); - for &(ref a, ref b) in self.env.iter() { + for (a, b) in self.env.iter() { cmd.env(a, b); } cmd @@ -2541,7 +2536,7 @@ impl Build { traditional }; - let cl_exe = windows_registry::find_tool(&target, "cl.exe"); + let cl_exe = windows_registry::find_tool(target, "cl.exe"); let tool_opt: Option = self .env_tool(env) @@ -2593,14 +2588,13 @@ impl Build { let cc = if target.contains("llvm") { clang } else { gnu }; format!("{}.exe", cc) } - } else if target.contains("apple-ios") { - clang.to_string() - } else if target.contains("apple-watchos") { - clang.to_string() - } else if target.contains("apple-tvos") { + } else if target.contains("apple-ios") + | target.contains("apple-watchos") + | target.contains("apple-tvos") + { clang.to_string() } else if target.contains("android") { - autodetect_android_compiler(&target, &host, gnu, clang) + autodetect_android_compiler(target, &host, gnu, clang) } else if target.contains("cloudabi") { format!("{}-{}", target, traditional) } else if target == "wasm32-wasi" @@ -2619,7 +2613,7 @@ impl Build { } else if target.starts_with("aarch64-kmc-solid_") { format!("aarch64-kmc-elf-{}", gnu) } else if &*self.get_host()? != target { - let prefix = self.prefix_for_target(&target); + let prefix = self.prefix_for_target(target); match prefix { Some(prefix) => { let cc = if target.contains("llvm") { clang } else { gnu }; @@ -2673,17 +2667,17 @@ impl Build { { if let Some(path) = tool.path.file_name() { let file_name = path.to_str().unwrap().to_owned(); - let (target, clang) = file_name.split_at(file_name.rfind("-").unwrap()); + let (target, clang) = file_name.split_at(file_name.rfind('-').unwrap()); tool.has_internal_target_arg = true; - tool.path.set_file_name(clang.trim_start_matches("-")); + tool.path.set_file_name(clang.trim_start_matches('-')); tool.path.set_extension("exe"); tool.args.push(format!("--target={}", target).into()); // Additionally, shell scripts for target i686-linux-android versions 16 to 24 // pass the `mstackrealign` option so we do that here as well. if target.contains("i686-linux-android") { - let (_, version) = target.split_at(target.rfind("d").unwrap() + 1); + let (_, version) = target.split_at(target.rfind('d').unwrap() + 1); if let Ok(version) = version.parse::() { if version > 15 && version < 25 { tool.args.push("-mstackrealign".into()); @@ -2708,7 +2702,7 @@ impl Build { && tool.env.len() == 0 && target.contains("msvc") { - for &(ref k, ref v) in cl_exe.env.iter() { + for (k, v) in cl_exe.env.iter() { tool.env.push((k.to_owned(), v.to_owned())); } } @@ -2804,7 +2798,7 @@ impl Build { } /// Returns the C++ standard library: - /// 1. If [cpp_link_stdlib](cc::Build::cpp_link_stdlib) is set, uses its value. + /// 1. If [`cpp_link_stdlib`](cc::Build::cpp_link_stdlib) is set, uses its value. /// 2. Else if the `CXXSTDLIB` environment variable is set, uses its value. /// 3. Else the default is `libc++` for OS X and BSDs, `libc++_shared` for Android, /// `None` for MSVC and `libstdc++` for anything else. @@ -2822,13 +2816,11 @@ impl Build { let target = self.get_target()?; if target.contains("msvc") { Ok(None) - } else if target.contains("apple") { - Ok(Some("c++".to_string())) - } else if target.contains("freebsd") { - Ok(Some("c++".to_string())) - } else if target.contains("openbsd") { - Ok(Some("c++".to_string())) - } else if target.contains("aix") { + } else if target.contains("apple") + | target.contains("freebsd") + | target.contains("openbsd") + | target.contains("aix") + { Ok(Some("c++".to_string())) } else if target.contains("android") { Ok(Some("c++_shared".to_string())) @@ -2968,7 +2960,7 @@ impl Build { if compiler.family == ToolFamily::Clang { name = format!("llvm-{}", tool); search_programs(&mut self.cmd(&compiler.path), &name) - .map(|name| self.cmd(&name)) + .map(|name| self.cmd(name)) } else { None } @@ -3329,7 +3321,7 @@ impl Build { let target = self.get_target()?; let host = self.get_host()?; let kind = if host == target { "HOST" } else { "TARGET" }; - let target_u = target.replace("-", "_"); + let target_u = target.replace('-', "_"); let res = self .getenv(&format!("{}_{}", var_base, target)) .or_else(|| self.getenv(&format!("{}_{}", var_base, target_u))) @@ -3548,12 +3540,12 @@ impl Tool { /// Explicitly set the `ToolFamily`, skipping name-based detection. fn with_family(path: PathBuf, family: ToolFamily) -> Self { Self { - path: path, + path, cc_wrapper_path: None, cc_wrapper_args: Vec::new(), args: Vec::new(), env: Vec::new(), - family: family, + family, cuda: false, removed_args: Vec::new(), has_internal_target_arg: false, @@ -3609,13 +3601,13 @@ impl Tool { }; Tool { - path: path, + path, cc_wrapper_path: None, cc_wrapper_args: Vec::new(), args: Vec::new(), env: Vec::new(), - family: family, - cuda: cuda, + family, + cuda, removed_args: Vec::new(), has_internal_target_arg: false, } @@ -3630,7 +3622,7 @@ impl Tool { /// /// Nvidia compiler accepts only the most common compiler flags like `-D`, /// `-I`, `-c`, etc. Options meant specifically for the underlying - /// host C++ compiler have to be prefixed with '-Xcompiler`. + /// host C++ compiler have to be prefixed with `-Xcompiler`. /// [Another possible future application for this function is passing /// clang-specific flags to clang-cl, which otherwise accepts only /// MSVC-specific options.] @@ -3664,11 +3656,11 @@ impl Tool { return self .args() .iter() - .any(|ref a| a.to_str().unwrap_or("").chars().nth(1) == Some('O')); + .any(|a| a.to_str().unwrap_or("").chars().nth(1) == Some('O')); } // TODO Check for existing -m..., -m...=..., /arch:... flags - return false; + false } /// Don't push optimization arg if it conflicts with existing args. @@ -3688,7 +3680,7 @@ impl Tool { pub fn to_command(&self) -> Command { let mut cmd = match self.cc_wrapper_path { Some(ref cc_wrapper_path) => { - let mut cmd = Command::new(&cc_wrapper_path); + let mut cmd = Command::new(cc_wrapper_path); cmd.arg(&self.path); cmd } @@ -3703,7 +3695,7 @@ impl Tool { .collect::>(); cmd.args(&value); - for &(ref k, ref v) in self.env.iter() { + for (k, v) in self.env.iter() { cmd.env(k, v); } cmd @@ -3943,10 +3935,10 @@ fn command_add_output_file( ) { if msvc && !clang && !gnu && !cuda && !(is_asm && is_arm) { let mut s = OsString::from("-Fo"); - s.push(&dst); + s.push(dst); cmd.arg(s); } else { - cmd.arg("-o").arg(&dst); + cmd.arg("-o").arg(dst); } } @@ -3989,7 +3981,7 @@ static NEW_STANDALONE_ANDROID_COMPILERS: [&str; 4] = [ fn android_clang_compiler_uses_target_arg_internally(clang_path: &Path) -> bool { if let Some(filename) = clang_path.file_name() { if let Some(filename_str) = filename.to_str() { - if let Some(idx) = filename_str.rfind("-") { + if let Some(idx) = filename_str.rfind('-') { return filename_str.split_at(idx).0.contains("android"); } } @@ -4102,7 +4094,11 @@ fn which(tool: &Path, path_entries: Option) -> Option { let path_entries = path_entries.or(env::var_os("PATH"))?; env::split_paths(&path_entries).find_map(|path_entry| { let mut exe = path_entry.join(tool); - return if check_exe(&mut exe) { Some(exe) } else { None }; + if check_exe(&mut exe) { + Some(exe) + } else { + None + } }) } diff --git a/src/os_pipe.rs b/src/os_pipe.rs index 218c9bc9f..827a53c35 100644 --- a/src/os_pipe.rs +++ b/src/os_pipe.rs @@ -1,8 +1,8 @@ //! Adapted from: -//! - https://doc.rust-lang.org/src/std/sys/unix/pipe.rs.html -//! - https://doc.rust-lang.org/src/std/sys/unix/fd.rs.html#385 -//! - https://github.com/rust-lang/rust/blob/master/library/std/src/sys/mod.rs#L57 -//! - https://github.com/oconnor663/os_pipe.rs +//! - +//! - +//! - +//! - use std::fs::File; /// Open a new pipe and return a pair of [`File`] objects for the reader and writer. diff --git a/src/os_pipe/windows.rs b/src/os_pipe/windows.rs index 212632e43..8a6a3fbec 100644 --- a/src/os_pipe/windows.rs +++ b/src/os_pipe/windows.rs @@ -4,7 +4,7 @@ use std::{fs::File, io, os::windows::prelude::*, ptr}; /// NOTE: These pipes do not support IOCP. /// /// If IOCP is needed, then you might want to emulate -/// anonymous pipes with CreateNamedPipe, as Rust's stdlib does. +/// anonymous pipes with `CreateNamedPipe`, as Rust's stdlib does. pub(super) fn pipe() -> io::Result<(File, File)> { let mut read_pipe = INVALID_HANDLE_VALUE; let mut write_pipe = INVALID_HANDLE_VALUE; diff --git a/src/registry.rs b/src/registry.rs index 7c1c2dd79..dbfb2c39d 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -23,6 +23,7 @@ use std::{ /// Must never be `HKEY_PERFORMANCE_DATA`. pub(crate) struct RegistryKey(Repr); +#[allow(clippy::upper_case_acronyms)] type DWORD = u32; struct OwnedKey(HKEY); @@ -147,7 +148,7 @@ impl RegistryKey { if !v.is_empty() && v[v.len() - 1] == 0 { v.pop(); } - return Ok(OsString::from_wide(&v)); + Ok(OsString::from_wide(&v)) } } } diff --git a/src/winapi.rs b/src/winapi.rs index 223599f62..52790a585 100644 --- a/src/winapi.rs +++ b/src/winapi.rs @@ -5,13 +5,13 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. -#![allow(bad_style)] +#![allow(bad_style, clippy::upper_case_acronyms)] use std::os::raw; pub type wchar_t = u16; -pub use crate::windows_sys::{FILETIME, GUID, HRESULT, SAFEARRAY, SAFEARRAYBOUND}; +pub use crate::windows_sys::{FILETIME, GUID, HRESULT, SAFEARRAY}; pub type REFIID = *const IID; pub type IID = GUID; diff --git a/src/windows_registry.rs b/src/windows_registry.rs index 00040289c..76fb3fafc 100644 --- a/src/windows_registry.rs +++ b/src/windows_registry.rs @@ -11,6 +11,8 @@ //! A helper module to probe the Windows Registry when looking for //! windows-specific tools. +#![allow(clippy::upper_case_acronyms)] + use std::process::Command; use crate::Tool; @@ -71,11 +73,11 @@ pub fn find_tool(target: &str, tool: &str) -> Option { // environment variables like `LIB`, `INCLUDE`, and `PATH` to ensure that // the tool is actually usable. - return impl_::find_msvc_environment(tool, target) + impl_::find_msvc_environment(tool, target) .or_else(|| impl_::find_msvc_15plus(tool, target)) .or_else(|| impl_::find_msvc_14(tool, target)) .or_else(|| impl_::find_msvc_12(tool, target)) - .or_else(|| impl_::find_msvc_11(tool, target)); + .or_else(|| impl_::find_msvc_11(tool, target)) } /// A version of Visual Studio @@ -182,7 +184,7 @@ mod impl_ { impl MsvcTool { fn new(tool: PathBuf) -> MsvcTool { MsvcTool { - tool: tool, + tool, libs: Vec::new(), path: Vec::new(), include: Vec::new(), @@ -196,7 +198,7 @@ mod impl_ { path, include, } = self; - let mut tool = Tool::with_family(tool.into(), MSVC_FAMILY); + let mut tool = Tool::with_family(tool, MSVC_FAMILY); add_env(&mut tool, "LIB", libs); add_env(&mut tool, "PATH", path); add_env(&mut tool, "INCLUDE", include); @@ -210,7 +212,7 @@ mod impl_ { fn is_vscmd_target(target: &str) -> Option { let vscmd_arch = env::var("VSCMD_ARG_TGT_ARCH").ok()?; // Convert the Rust target arch to its VS arch equivalent. - let arch = match target.split("-").next() { + let arch = match target.split('-').next() { Some("x86_64") => "x64", Some("aarch64") => "arm64", Some("i686") | Some("i586") => "x86", @@ -242,7 +244,7 @@ mod impl_ { .map(|p| p.join(tool)) .find(|p| p.exists()) }) - .map(|path| Tool::with_family(path.into(), MSVC_FAMILY)) + .map(|path| Tool::with_family(path, MSVC_FAMILY)) } } @@ -394,7 +396,7 @@ mod impl_ { .into_iter() .filter_map(|instance| instance.installation_path()) .map(|path| path.join(tool)) - .find(|ref path| path.is_file()), + .find(|path| path.is_file()), None => None, }; @@ -467,18 +469,15 @@ mod impl_ { let path = instance_path.join(r"VC\Tools\MSVC").join(version); // This is the path to the toolchain for a particular target, running // on a given host - let bin_path = path - .join("bin") - .join(&format!("Host{}", host)) - .join(&target); + let bin_path = path.join("bin").join(format!("Host{}", host)).join(target); // But! we also need PATH to contain the target directory for the host // architecture, because it contains dlls like mspdb140.dll compiled for // the host architecture. let host_dylib_path = path .join("bin") - .join(&format!("Host{}", host)) - .join(&host.to_lowercase()); - let lib_path = path.join("lib").join(&target); + .join(format!("Host{}", host)) + .join(host.to_lowercase()); + let lib_path = path.join("lib").join(target); let include_path = path.join("include"); Some((path, bin_path, host_dylib_path, lib_path, include_path)) } @@ -632,7 +631,7 @@ mod impl_ { path.join("bin").join(host), ) }) - .filter(|&(ref path, _)| path.is_file()) + .filter(|(path, _)| path.is_file()) .map(|(path, host)| { let mut tool = MsvcTool::new(path); tool.path.push(host); @@ -840,7 +839,7 @@ mod impl_ { for subkey in key.iter().filter_map(|k| k.ok()) { let val = subkey .to_str() - .and_then(|s| s.trim_left_matches("v").replace(".", "").parse().ok()); + .and_then(|s| s.trim_left_matches("v").replace('.', "").parse().ok()); let val = match val { Some(s) => s, None => continue, @@ -883,7 +882,7 @@ mod impl_ { } pub fn find_devenv(target: &str) -> Option { - find_devenv_vs15(&target) + find_devenv_vs15(target) } fn find_devenv_vs15(target: &str) -> Option { @@ -894,7 +893,7 @@ mod impl_ { pub fn find_msbuild(target: &str) -> Option { // VS 15 (2017) changed how to locate msbuild if let Some(r) = find_msbuild_vs17(target) { - return Some(r); + Some(r) } else if let Some(r) = find_msbuild_vs16(target) { return Some(r); } else if let Some(r) = find_msbuild_vs15(target) { diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 94b51f653..f907b08fc 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -34,7 +34,7 @@ impl Test { // lesser of the two evils. env::remove_var("RUSTC_WRAPPER"); - let mut gcc = PathBuf::from(env::current_exe().unwrap()); + let mut gcc = env::current_exe().unwrap(); gcc.pop(); if gcc.ends_with("deps") { gcc.pop(); @@ -42,8 +42,8 @@ impl Test { let td = Builder::new().prefix("gcc-test").tempdir_in(&gcc).unwrap(); gcc.push(format!("gcc-shim{}", env::consts::EXE_SUFFIX)); Test { - td: td, - gcc: gcc, + td, + gcc, msvc: false, } } diff --git a/tests/test.rs b/tests/test.rs index 220d2f2f7..36cdd8410 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -259,8 +259,8 @@ fn gnu_x86_64_no_plt() { test.gcc() .pic(true) .use_plt(false) - .target(&target) - .host(&target) + .target(target) + .host(target) .file("foo.c") .compile("foo"); test.cmd(0).must_have("-fno-plt");