Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Jun 19, 2022
1 parent 18c6fe5 commit 7643f82
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions compiler/rustc_codegen_llvm/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
/// Combine the provided files, rlibs, and native libraries into a single
/// `Archive`.
fn build(mut self) -> bool {
let kind = self.llvm_archive_kind().unwrap_or_else(|kind| {
self.sess.fatal(&format!("Don't know how to build archive of type: {}", kind))
});

match self.build_with_llvm(kind) {
match self.build_with_llvm() {
Ok(any_members) => any_members,
Err(e) => self.sess.fatal(&format!("failed to build archive: {}", e)),
}
Expand Down Expand Up @@ -249,12 +245,12 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
}

impl<'a> LlvmArchiveBuilder<'a> {
fn llvm_archive_kind(&self) -> Result<ArchiveKind, &str> {
fn build_with_llvm(&mut self) -> io::Result<bool> {
let kind = &*self.sess.target.archive_format;
kind.parse().map_err(|_| kind)
}
let kind = kind.parse::<ArchiveKind>().map_err(|_| kind).unwrap_or_else(|kind| {
self.sess.fatal(&format!("Don't know how to build archive of type: {}", kind))
});

fn build_with_llvm(&mut self, kind: ArchiveKind) -> io::Result<bool> {
let mut additions = mem::take(&mut self.additions);
let mut strings = Vec::new();
let mut members = Vec::new();
Expand Down

0 comments on commit 7643f82

Please sign in to comment.