Skip to content

Commit 70d39cd

Browse files
committed
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.
1 parent f0038a7 commit 70d39cd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

compiler/rustc_codegen_llvm/src/back/archive.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
129129
let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" };
130130
let output_path = {
131131
let mut output_path: PathBuf = tmpdir.to_path_buf();
132-
output_path.push(format!("{lib_name}{name_suffix}"));
133-
output_path.with_extension("lib")
132+
output_path.push(format!("{lib_name}{name_suffix}.lib"));
134133
};
135134

136135
let target = &sess.target;
@@ -157,7 +156,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
157156
// functions. Therefore, use binutils to create the import library instead,
158157
// by writing a .DEF file to the temp dir and calling binutils's dlltool.
159158
let def_file_path =
160-
tmpdir.join(format!("{lib_name}{name_suffix}")).with_extension("def");
159+
tmpdir.join(format!("{lib_name}{name_suffix}.def"));
161160

162161
let def_file_content = format!(
163162
"EXPORTS\n{}",

0 commit comments

Comments
 (0)