diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-06-19 12:49:12 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-06-19 12:56:31 +0000 |
| commit | 7643f82e012c29603374fbdc4cd8c2ce3b600c82 (patch) | |
| tree | dc3ef580a670d50513c5dfd110a6f668ff795d33 /compiler/rustc_codegen_llvm/src | |
| parent | 18c6fe5798c70d532742cfda6c21d61daee257a4 (diff) | |
| download | rust-7643f82e012c29603374fbdc4cd8c2ce3b600c82.tar.gz rust-7643f82e012c29603374fbdc4cd8c2ce3b600c82.zip | |
Small refactoring
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/archive.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 58ad8af7472..da9d8b5fb33 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -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)), } @@ -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(); |
