Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiser
Use `as_deref` in compiler (but only where it makes sense) This simplifies some code :3 (there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")
This commit is contained in:
@@ -922,8 +922,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
// v v
|
||||
// ( succ )
|
||||
//
|
||||
let else_ln =
|
||||
self.propagate_through_opt_expr(else_opt.as_ref().map(|e| &**e), succ);
|
||||
let else_ln = self.propagate_through_opt_expr(else_opt.as_deref(), succ);
|
||||
let then_ln = self.propagate_through_expr(&then, succ);
|
||||
let ln = self.live_node(expr.hir_id, expr.span);
|
||||
self.init_from_succ(ln, else_ln);
|
||||
@@ -966,7 +965,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
|
||||
hir::ExprKind::Ret(ref o_e) => {
|
||||
// Ignore succ and subst exit_ln.
|
||||
self.propagate_through_opt_expr(o_e.as_ref().map(|e| &**e), self.exit_ln)
|
||||
self.propagate_through_opt_expr(o_e.as_deref(), self.exit_ln)
|
||||
}
|
||||
|
||||
hir::ExprKind::Break(label, ref opt_expr) => {
|
||||
@@ -981,7 +980,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
// look it up in the break loop nodes table
|
||||
|
||||
match target {
|
||||
Some(b) => self.propagate_through_opt_expr(opt_expr.as_ref().map(|e| &**e), b),
|
||||
Some(b) => self.propagate_through_opt_expr(opt_expr.as_deref(), b),
|
||||
None => span_bug!(expr.span, "`break` to unknown label"),
|
||||
}
|
||||
}
|
||||
@@ -1026,7 +1025,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
hir::ExprKind::Array(ref exprs) => self.propagate_through_exprs(exprs, succ),
|
||||
|
||||
hir::ExprKind::Struct(_, ref fields, ref with_expr) => {
|
||||
let succ = self.propagate_through_opt_expr(with_expr.as_ref().map(|e| &**e), succ);
|
||||
let succ = self.propagate_through_opt_expr(with_expr.as_deref(), succ);
|
||||
fields
|
||||
.iter()
|
||||
.rev()
|
||||
|
||||
Reference in New Issue
Block a user