Use to_option in various places

This commit is contained in:
varkor 2019-10-08 01:14:42 +01:00
parent 51901eea8c
commit e3a8ea4e18
51 changed files with 81 additions and 236 deletions

View file

@ -119,11 +119,7 @@ fn path_relative_from(path: &Path, base: &Path) -> Option<PathBuf> {
use std::path::Component;
if path.is_absolute() != base.is_absolute() {
if path.is_absolute() {
Some(PathBuf::from(path))
} else {
None
}
path.is_absolute().to_option(PathBuf::from(path))
} else {
let mut ita = path.components();
let mut itb = base.components();

View file

@ -85,11 +85,7 @@ fn reachable_non_generics_provider(
match tcx.hir().get(hir_id) {
Node::ForeignItem(..) => {
let def_id = tcx.hir().local_def_id(hir_id);
if tcx.is_statically_included_foreign_item(def_id) {
Some(def_id)
} else {
None
}
tcx.is_statically_included_foreign_item(def_id).to_option(def_id)
}
// Only consider nodes that actually have exported symbols.

View file

@ -1,5 +1,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(core_intrinsics)]
@ -68,22 +69,11 @@ impl<M> ModuleCodegen<M> {
emit_bc: bool,
emit_bc_compressed: bool,
outputs: &OutputFilenames) -> CompiledModule {
let object = if emit_obj {
Some(outputs.temp_path(OutputType::Object, Some(&self.name)))
} else {
None
};
let bytecode = if emit_bc {
Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name)))
} else {
None
};
let bytecode_compressed = if emit_bc_compressed {
Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name))
.with_extension(RLIB_BYTECODE_EXTENSION))
} else {
None
};
let object = emit_obj.to_option(outputs.temp_path(OutputType::Object, Some(&self.name)));
let bytecode = emit_bc.to_option(outputs.temp_path(OutputType::Bitcode, Some(&self.name)));
let bytecode_compressed = emit_bc_compressed.to_option(
outputs.temp_path(OutputType::Bitcode, Some(&self.name))
.with_extension(RLIB_BYTECODE_EXTENSION));
CompiledModule {
name: self.name.clone(),