diff options
| author | Fabian Wolff <fabian.wolff@alumni.ethz.ch> | 2021-06-26 22:26:26 +0200 |
|---|---|---|
| committer | Fabian Wolff <fabian.wolff@alumni.ethz.ch> | 2021-06-26 22:26:26 +0200 |
| commit | a8b57723d41d5f8b58bc4796ecb4bde0ed00e639 (patch) | |
| tree | 7d6d585ca8687942ea601d0fce86a25f518d130b | |
| parent | 7682e87c6d29520dfdea6a2a772c31150dbfa7d4 (diff) | |
| download | rust-a8b57723d41d5f8b58bc4796ecb4bde0ed00e639.tar.gz rust-a8b57723d41d5f8b58bc4796ecb4bde0ed00e639.zip | |
Use `Option::map()` instead of `if let`
| -rw-r--r-- | compiler/rustc_driver/src/pretty.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/compiler/rustc_driver/src/pretty.rs b/compiler/rustc_driver/src/pretty.rs index 2a11d62ac15..bf131914b97 100644 --- a/compiler/rustc_driver/src/pretty.rs +++ b/compiler/rustc_driver/src/pretty.rs @@ -324,16 +324,12 @@ impl<'tcx> pprust_hir::PpAnn for TypedAnnotation<'tcx> { } fn post(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) { if let pprust_hir::AnnNode::Expr(expr) = node { - let typeck_results = - self.maybe_typeck_results.get().or_else(|| { - if let Some(body_id) = self.tcx.hir().maybe_body_owned_by( - self.tcx.hir().local_def_id_to_hir_id(expr.hir_id.owner), - ) { - Some(self.tcx.typeck_body(body_id)) - } else { - None - } - }); + let typeck_results = self.maybe_typeck_results.get().or_else(|| { + self.tcx + .hir() + .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)) + }); if let Some(typeck_results) = typeck_results { s.s.space(); |
