Skip to content

Commit

Permalink
Rollup merge of #79337 - LingMan:map, r=jyn514
Browse files Browse the repository at this point in the history
Use Option::map instead of open coding it

r?  `@jonas-schievink` since you're frequently sniping these minor cleanups anyway.
`@rustbot` modify labels +C-cleanup  +T-compiler
  • Loading branch information
jonas-schievink committed Nov 23, 2020
2 parents a0cf162 + cd89732 commit 064c3c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
5 changes: 1 addition & 4 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,10 +1152,7 @@ impl<'ll> MemberDescription<'ll> {
self.size.bits(),
self.align.bits() as u32,
self.offset.bits(),
match self.discriminant {
None => None,
Some(value) => Some(cx.const_u64(value)),
},
self.discriminant.map(|v| cx.const_u64(v)),
self.flags,
self.type_metadata,
)
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,10 +1106,7 @@ impl<T> Binder<T> {

impl<T> Binder<Option<T>> {
pub fn transpose(self) -> Option<Binder<T>> {
match self.0 {
Some(v) => Some(Binder(v)),
None => None,
}
self.0.map(Binder)
}
}

Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_typeck/src/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// can be given the suggestion "u32::from(x) > y" rather than
// "x > y.try_into().unwrap()".
let lhs_expr_and_src = expected_ty_expr.and_then(|expr| {
match self.tcx.sess.source_map().span_to_snippet(expr.span).ok() {
Some(src) => Some((expr, src)),
None => None,
}
self.tcx
.sess
.source_map()
.span_to_snippet(expr.span)
.ok()
.map(|src| (expr, src))
});
let (span, msg, suggestion) = if let (Some((lhs_expr, lhs_src)), false) =
(lhs_expr_and_src, exp_to_found_is_fallible)
Expand Down

0 comments on commit 064c3c1

Please sign in to comment.