Skip to content

Commit 076c019

Browse files
authored
Rollup merge of rust-lang#81084 - LingMan:map, r=oli-obk
Use Option::map instead of open-coding it r? ``@oli-obk`` ``@rustbot`` modify labels +C-cleanup +T-compiler
2 parents fde7956 + 76003f3 commit 076c019

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,6 @@ pub fn handle_native_features(sess: &Session) -> Vec<String> {
254254
}
255255

256256
pub fn tune_cpu(sess: &Session) -> Option<&str> {
257-
match sess.opts.debugging_opts.tune_cpu {
258-
Some(ref s) => Some(handle_native(&**s)),
259-
None => None,
260-
}
257+
let name = sess.opts.debugging_opts.tune_cpu.as_ref()?;
258+
Some(handle_native(name))
261259
}

compiler/rustc_mir/src/borrow_check/type_check/input_output.rs

+12-16
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
3939
user_provided_sig = None;
4040
} else {
4141
let typeck_results = self.tcx().typeck(mir_def_id);
42-
user_provided_sig = match typeck_results.user_provided_sigs.get(&mir_def_id.to_def_id())
43-
{
44-
None => None,
45-
Some(user_provided_poly_sig) => {
42+
user_provided_sig = typeck_results.user_provided_sigs.get(&mir_def_id.to_def_id()).map(
43+
|user_provided_poly_sig| {
4644
// Instantiate the canonicalized variables from
4745
// user-provided signature (e.g., the `_` in the code
4846
// above) with fresh variables.
@@ -54,18 +52,16 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
5452
// Replace the bound items in the fn sig with fresh
5553
// variables, so that they represent the view from
5654
// "inside" the closure.
57-
Some(
58-
self.infcx
59-
.replace_bound_vars_with_fresh_vars(
60-
body.span,
61-
LateBoundRegionConversionTime::FnCall,
62-
poly_sig,
63-
)
64-
.0,
65-
)
66-
}
67-
}
68-
};
55+
self.infcx
56+
.replace_bound_vars_with_fresh_vars(
57+
body.span,
58+
LateBoundRegionConversionTime::FnCall,
59+
poly_sig,
60+
)
61+
.0
62+
},
63+
);
64+
}
6965

7066
debug!(
7167
"equate_inputs_and_outputs: normalized_input_tys = {:?}, local_decls = {:?}",

compiler/rustc_typeck/src/check/compare_method.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,10 @@ fn check_region_bounds_on_impl_item<'tcx>(
365365
let item_kind = assoc_item_kind_str(impl_m);
366366
let def_span = tcx.sess.source_map().guess_head_span(span);
367367
let span = tcx.hir().get_generics(impl_m.def_id).map_or(def_span, |g| g.span);
368-
let generics_span = if let Some(sp) = tcx.hir().span_if_local(trait_m.def_id) {
368+
let generics_span = tcx.hir().span_if_local(trait_m.def_id).map(|sp| {
369369
let def_sp = tcx.sess.source_map().guess_head_span(sp);
370-
Some(tcx.hir().get_generics(trait_m.def_id).map_or(def_sp, |g| g.span))
371-
} else {
372-
None
373-
};
370+
tcx.hir().get_generics(trait_m.def_id).map_or(def_sp, |g| g.span)
371+
});
374372

375373
tcx.sess.emit_err(LifetimesOrBoundsMismatchOnTrait {
376374
span,

0 commit comments

Comments
 (0)