1
Fork 0

Use Option::map() instead of if let

This commit is contained in:
Fabian Wolff 2021-06-26 22:26:26 +02:00
parent 7682e87c6d
commit a8b57723d4

View file

@ -324,16 +324,12 @@ impl<'tcx> pprust_hir::PpAnn for TypedAnnotation<'tcx> {
} }
fn post(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) { fn post(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
if let pprust_hir::AnnNode::Expr(expr) = node { if let pprust_hir::AnnNode::Expr(expr) = node {
let typeck_results = let typeck_results = self.maybe_typeck_results.get().or_else(|| {
self.maybe_typeck_results.get().or_else(|| { self.tcx
if let Some(body_id) = self.tcx.hir().maybe_body_owned_by( .hir()
self.tcx.hir().local_def_id_to_hir_id(expr.hir_id.owner), .maybe_body_owned_by(self.tcx.hir().local_def_id_to_hir_id(expr.hir_id.owner))
) { .map(|body_id| self.tcx.typeck_body(body_id))
Some(self.tcx.typeck_body(body_id)) });
} else {
None
}
});
if let Some(typeck_results) = typeck_results { if let Some(typeck_results) = typeck_results {
s.s.space(); s.s.space();