Skip to content

Commit 7643f82

Browse files
committed
Small refactoring
1 parent 18c6fe5 commit 7643f82

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

compiler/rustc_codegen_llvm/src/back/archive.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
9090
/// Combine the provided files, rlibs, and native libraries into a single
9191
/// `Archive`.
9292
fn build(mut self) -> bool {
93-
let kind = self.llvm_archive_kind().unwrap_or_else(|kind| {
94-
self.sess.fatal(&format!("Don't know how to build archive of type: {}", kind))
95-
});
96-
97-
match self.build_with_llvm(kind) {
93+
match self.build_with_llvm() {
9894
Ok(any_members) => any_members,
9995
Err(e) => self.sess.fatal(&format!("failed to build archive: {}", e)),
10096
}
@@ -249,12 +245,12 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
249245
}
250246

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

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

0 commit comments

Comments
 (0)