Skip to content

Commit

Permalink
Directly add extension instead of using Path::with_extension
Browse files Browse the repository at this point in the history
`Path::with_extension` has a nice footgun when the original path doesn't
contain an extension: Anything after the last dot gets removed.
  • Loading branch information
tbu- committed May 22, 2024
1 parent f0038a7 commit 70d39cd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compiler/rustc_codegen_llvm/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
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")
output_path.push(format!("{lib_name}{name_suffix}.lib"));
};

let target = &sess.target;
Expand All @@ -157,7 +156,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
// 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");
tmpdir.join(format!("{lib_name}{name_suffix}.def"));

let def_file_content = format!(
"EXPORTS\n{}",
Expand Down

0 comments on commit 70d39cd

Please sign in to comment.