about summary refs log tree commit diff
path: root/src/librustc_driver
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2020-03-22 13:36:56 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2020-03-30 10:52:29 +0200
commit9bba047c2e425fce03b039bcb8ccd60ddcbc80a0 (patch)
tree955fb13c65c6a29f4ad8535485f91c2c77b7233b /src/librustc_driver
parent8926bb497d9b127eb318aea5aed0e745d8381591 (diff)
Use if let instead of match when only matching a single variant (clippy::single_match)
Makes code more compact and reduces nestig.
Diffstat (limited to 'src/librustc_driver')
-rw-r--r--src/librustc_driver/pretty.rs30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs
index 2319760204a..87777bd674b 100644
--- a/src/librustc_driver/pretty.rs
+++ b/src/librustc_driver/pretty.rs
@@ -177,9 +177,8 @@ impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> {
 
 impl<'hir> pprust::PpAnn for IdentifiedAnnotation<'hir> {
     fn pre(&self, s: &mut pprust::State<'_>, node: pprust::AnnNode<'_>) {
-        match node {
-            pprust::AnnNode::Expr(_) => s.popen(),
-            _ => {}
+        if let pprust::AnnNode::Expr(_) = node {
+            s.popen();
         }
     }
     fn post(&self, s: &mut pprust::State<'_>, node: pprust::AnnNode<'_>) {
@@ -232,9 +231,8 @@ impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> {
         }
     }
     fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
-        match node {
-            pprust_hir::AnnNode::Expr(_) => s.popen(),
-            _ => {}
+        if let pprust_hir::AnnNode::Expr(_) = node {
+            s.popen();
         }
     }
     fn post(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
@@ -339,21 +337,17 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
         self.tables.set(old_tables);
     }
     fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
-        match node {
-            pprust_hir::AnnNode::Expr(_) => s.popen(),
-            _ => {}
+        if let pprust_hir::AnnNode::Expr(_) = node {
+            s.popen();
         }
     }
     fn post(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
-        match node {
-            pprust_hir::AnnNode::Expr(expr) => {
-                s.s.space();
-                s.s.word("as");
-                s.s.space();
-                s.s.word(self.tables.get().expr_ty(expr).to_string());
-                s.pclose();
-            }
-            _ => {}
+        if let pprust_hir::AnnNode::Expr(expr) = node {
+            s.s.space();
+            s.s.word("as");
+            s.s.space();
+            s.s.word(self.tables.get().expr_ty(expr).to_string());
+            s.pclose();
         }
     }
 }