Use as_deref
in compiler (but only where it makes sense)
This commit is contained in:
parent
e702534763
commit
94470f4efd
27 changed files with 45 additions and 63 deletions
|
@ -487,7 +487,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
substs,
|
||||
user_ty,
|
||||
fields: self.field_refs(fields),
|
||||
base: base.as_ref().map(|base| FruInfo {
|
||||
base: base.map(|base| FruInfo {
|
||||
base: self.mirror_expr(base),
|
||||
field_types: self.typeck_results().fru_field_types()[expr.hir_id]
|
||||
.iter()
|
||||
|
@ -590,7 +590,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
InlineAsmOperand::Out {
|
||||
reg,
|
||||
late,
|
||||
expr: expr.as_ref().map(|expr| self.mirror_expr(expr)),
|
||||
expr: expr.map(|expr| self.mirror_expr(expr)),
|
||||
}
|
||||
}
|
||||
hir::InlineAsmOperand::InOut { reg, late, ref expr } => {
|
||||
|
@ -605,7 +605,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
reg,
|
||||
late,
|
||||
in_expr: self.mirror_expr(in_expr),
|
||||
out_expr: out_expr.as_ref().map(|expr| self.mirror_expr(expr)),
|
||||
out_expr: out_expr.map(|expr| self.mirror_expr(expr)),
|
||||
},
|
||||
hir::InlineAsmOperand::Const { ref anon_const } => {
|
||||
let anon_const_def_id = tcx.hir().local_def_id(anon_const.hir_id);
|
||||
|
@ -659,13 +659,11 @@ impl<'tcx> Cx<'tcx> {
|
|||
|
||||
ExprKind::Repeat { value: self.mirror_expr(v), count: *count }
|
||||
}
|
||||
hir::ExprKind::Ret(ref v) => {
|
||||
ExprKind::Return { value: v.as_ref().map(|v| self.mirror_expr(v)) }
|
||||
}
|
||||
hir::ExprKind::Ret(ref v) => ExprKind::Return { value: v.map(|v| self.mirror_expr(v)) },
|
||||
hir::ExprKind::Break(dest, ref value) => match dest.target_id {
|
||||
Ok(target_id) => ExprKind::Break {
|
||||
label: region::Scope { id: target_id.local_id, data: region::ScopeData::Node },
|
||||
value: value.as_ref().map(|value| self.mirror_expr(value)),
|
||||
value: value.map(|value| self.mirror_expr(value)),
|
||||
},
|
||||
Err(err) => bug!("invalid loop id for break: {}", err),
|
||||
},
|
||||
|
|
|
@ -216,7 +216,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
let lo = lo_expr.map(|e| self.lower_range_expr(e));
|
||||
let hi = hi_expr.map(|e| self.lower_range_expr(e));
|
||||
|
||||
let (lp, hp) = (lo.as_ref().map(|x| &x.0), hi.as_ref().map(|x| &x.0));
|
||||
let (lp, hp) = (lo.as_ref().map(|(x, _)| x), hi.as_ref().map(|(x, _)| x));
|
||||
let mut kind = match self.normalize_range_pattern_ends(ty, lp, hp) {
|
||||
Some((lc, hc)) => self.lower_pattern_range(ty, lc, hc, end, lo_span),
|
||||
None => {
|
||||
|
@ -358,7 +358,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
&mut self,
|
||||
pat: &'tcx Option<&'tcx hir::Pat<'tcx>>,
|
||||
) -> Option<Box<Pat<'tcx>>> {
|
||||
pat.as_ref().map(|p| self.lower_pattern(p))
|
||||
pat.map(|p| self.lower_pattern(p))
|
||||
}
|
||||
|
||||
fn slice_or_array_pattern(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue