about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRussell Cohen <russell.r.cohen@gmail.com>2020-03-30 12:39:40 -0400
committerRussell Cohen <russell.r.cohen@gmail.com>2020-03-30 12:39:40 -0400
commit20e21902bb993487c1486f2dd33d3bd65101f00c (patch)
treef22a0ae75da69ebbfc4d466cf933b9f735722624
parentbceab25d6c206a7b92716e0c9e9a89b97d131e8e (diff)
Clean up redudant conditions and match exprs
-rw-r--r--src/librustc_lexer/src/lib.rs2
-rw-r--r--src/librustc_parse/parser/diagnostics.rs21
2 files changed, 11 insertions, 12 deletions
diff --git a/src/librustc_lexer/src/lib.rs b/src/librustc_lexer/src/lib.rs
index 132607031ce..fcb7475cc2e 100644
--- a/src/librustc_lexer/src/lib.rs
+++ b/src/librustc_lexer/src/lib.rs
@@ -731,7 +731,7 @@ impl Cursor<'_> {
                     n_end_hashes,
                     possible_terminator_offset: None,
                 };
-            } else if n_end_hashes > 0 && n_end_hashes > max_hashes {
+            } else if n_end_hashes > max_hashes {
                 // Keep track of possible terminators to give a hint about where there might be
                 // a missing terminator
                 possible_terminator_offset =
diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs
index e542588d8b5..12b9b682682 100644
--- a/src/librustc_parse/parser/diagnostics.rs
+++ b/src/librustc_parse/parser/diagnostics.rs
@@ -287,15 +287,14 @@ impl<'a> Parser<'a> {
     }
 
     fn check_too_many_raw_str_terminators(&mut self, err: &mut DiagnosticBuilder<'_>) -> bool {
-        let prev_token_raw_str = match self.prev_token.kind {
-            TokenKind::Literal(Lit {
-                kind: LitKind::StrRaw(n) | LitKind::ByteStrRaw(n), ..
-            }) => Some(n),
-            _ => None,
-        };
-
-        if let Some(n_hashes) = prev_token_raw_str {
-            if self.token.kind == TokenKind::Pound {
+        match (&self.prev_token.kind, &self.token.kind) {
+            (
+                TokenKind::Literal(Lit {
+                    kind: LitKind::StrRaw(n_hashes) | LitKind::ByteStrRaw(n_hashes),
+                    ..
+                }),
+                TokenKind::Pound,
+            ) => {
                 err.set_primary_message("too many `#` when terminating raw string");
                 err.span_suggestion(
                     self.token.span,
@@ -304,10 +303,10 @@ impl<'a> Parser<'a> {
                     Applicability::MachineApplicable,
                 );
                 err.note(&format!("the raw string started with {} `#`s", n_hashes));
-                return true;
+                true
             }
+            _ => false,
         }
-        false
     }
 
     pub fn maybe_annotate_with_ascription(