From 6135b2dff5951605d6f3d1189b280532e629d595 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 13 Aug 2017 15:56:35 +0200 Subject: [PATCH] Fix tidy errors --- src/librustc_driver/driver.rs | 2 +- src/librustc_driver/lib.rs | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 82ced4d1bcd..84b1ade6d8b 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -95,7 +95,7 @@ pub fn compile_input(sess: &Session, if sess.opts.crate_types.iter().all(|&t|{ t != CrateType::CrateTypeRlib && t != CrateType::CrateTypeExecutable - }) { + }) && !sess.opts.crate_types.is_empty() { sess.err( "LLVM is not supported by this rustc, so non rlib libraries are not supported" ); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 4fc4b8dab2d..f8cd2280caf 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -157,28 +157,36 @@ pub use no_llvm_metadata_loader::NoLLvmMetadataLoader as MetadataLoader; pub use rustc_trans::LlvmMetadataLoader as MetadataLoader; #[cfg(not(feature="llvm"))] -mod no_llvm_metadata_loader{ +mod no_llvm_metadata_loader { extern crate ar; extern crate owning_ref; - + use rustc::middle::cstore::MetadataLoader as MetadataLoaderTrait; use rustc_back::target::Target; use std::io; use std::fs::File; use std::path::Path; - + use self::ar::Archive; use self::owning_ref::{OwningRef, ErasedBoxRef}; pub struct NoLLvmMetadataLoader; impl MetadataLoaderTrait for NoLLvmMetadataLoader { - fn get_rlib_metadata(&self, _: &Target, filename: &Path) -> Result, String> { - let file = File::open(filename).map_err(|e|format!("metadata file open err: {:?}", e))?; + fn get_rlib_metadata( + &self, + _: &Target, + filename: &Path + ) -> Result, String> { + let file = File::open(filename).map_err(|e| { + format!("metadata file open err: {:?}", e) + })?; let mut archive = Archive::new(file); while let Some(entry_result) = archive.next_entry() { - let mut entry = entry_result.map_err(|e|format!("metadata section read err: {:?}", e))?; + let mut entry = entry_result.map_err(|e| { + format!("metadata section read err: {:?}", e) + })?; if entry.header().identifier() == "rust.metadata.bin" { let mut buf = Vec::new(); io::copy(&mut entry, &mut buf).unwrap();