make use of Result::map_or

This commit is contained in:
Lzu Tao 2019-11-25 13:22:55 +00:00
parent 8cae411ae3
commit 93438fd839
3 changed files with 3 additions and 3 deletions

View File

@ -505,7 +505,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
let left_bits = place_layout.size.bits();
let right_size = r.layout.size;
let r_bits = r.to_scalar().and_then(|r| r.to_bits(right_size));
if r_bits.ok().map_or(false, |b| b >= left_bits as u128) {
if r_bits.map_or(false, |b| b >= left_bits as u128) {
let lint_root = match &self.source_scopes[source_info.scope].local_data {
ClearCrossCrate::Set(data) => data.lint_root,
ClearCrossCrate::Clear => return None,

View File

@ -1460,7 +1460,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
pcx.method_name = Some(method_name);
pcx.assemble_inherent_candidates();
pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)
.ok().map_or(None, |_| {
.map_or(None, |_| {
pcx.pick_core()
.and_then(|pick| pick.ok())
.and_then(|pick| Some(pick.item))

View File

@ -74,7 +74,7 @@ impl TermInfo {
Err(..) => return Err(Error::TermUnset),
};
if term.is_err() && env::var("MSYSCON").ok().map_or(false, |s| "mintty.exe" == s) {
if term.is_err() && env::var("MSYSCON").map_or(false, |s| "mintty.exe" == s) {
// msys terminal
Ok(msys_terminfo())
} else {