about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-06-06 10:24:24 +0000
committerbors <bors@rust-lang.org>2024-06-06 10:24:24 +0000
commit67caf52fbc4f10cdf427f04e6cbb35c8b9d96bb7 (patch)
treea524a1e89f10fb2084fe09d4e867f4bf31a4f3d2
parent2d28b6384e5e0a2c9d1500a1f65e35423453fbf6 (diff)
parentf7c51a2d2f67a118db7de5e810f5acb096659137 (diff)
downloadrust-67caf52fbc4f10cdf427f04e6cbb35c8b9d96bb7.tar.gz
rust-67caf52fbc4f10cdf427f04e6cbb35c8b9d96bb7.zip
Auto merge of #125406 - tbu-:pr_rm_path_with_extension, r=Nadrieril
Directly add extension instead of using `Path::with_extension`

`Path::with_extension` has a nice footgun when the original path doesn't contain an extension: Anything after the last dot gets removed.
-rw-r--r--compiler/rustc_codegen_llvm/src/back/archive.rs9
-rw-r--r--tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs4
2 files changed, 4 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs
index fa7e7e5377a..a354f3d3536 100644
--- a/compiler/rustc_codegen_llvm/src/back/archive.rs
+++ b/compiler/rustc_codegen_llvm/src/back/archive.rs
@@ -128,11 +128,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
         is_direct_dependency: bool,
     ) -> PathBuf {
         let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" };
-        let output_path = {
-            let mut output_path: PathBuf = tmpdir.to_path_buf();
-            output_path.push(format!("{lib_name}{name_suffix}"));
-            output_path.with_extension("lib")
-        };
+        let output_path = tmpdir.join(format!("{lib_name}{name_suffix}.lib"));
 
         let target = &sess.target;
         let mingw_gnu_toolchain = common::is_mingw_gnu_toolchain(target);
@@ -157,8 +153,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
             // that loaded but crashed with an AV upon calling one of the imported
             // functions. Therefore, use binutils to create the import library instead,
             // by writing a .DEF file to the temp dir and calling binutils's dlltool.
-            let def_file_path =
-                tmpdir.join(format!("{lib_name}{name_suffix}")).with_extension("def");
+            let def_file_path = tmpdir.join(format!("{lib_name}{name_suffix}.def"));
 
             let def_file_content = format!(
                 "EXPORTS\n{}",
diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs
index 402efaf5027..ea9d48e7859 100644
--- a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs
+++ b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs
@@ -3,8 +3,8 @@
 //@ needs-dlltool
 //@ compile-flags: --crate-type lib --emit link
 //@ normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL"
-//@ normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE"
-//@ normalize-stderr-test: "[^ ]*/foo.lib" -> "$$LIB_FILE"
+//@ normalize-stderr-test: "[^ ]*/foo.dll_imports.def" -> "$$DEF_FILE"
+//@ normalize-stderr-test: "[^ ]*/foo.dll_imports.lib" -> "$$LIB_FILE"
 //@ normalize-stderr-test: "-m [^ ]*" -> "$$TARGET_MACHINE"
 //@ normalize-stderr-test: "-f [^ ]*" -> "$$ASM_FLAGS"
 //@ normalize-stderr-test: "--temp-prefix [^ ]*/foo.dll" -> "$$TEMP_PREFIX"