From 83588a1c452dff3ca6cd9e84cbe70a3b549fc851 Mon Sep 17 00:00:00 2001
From: David Lattimore <dml@google.com>
Date: Thu, 2 Jul 2020 09:19:58 +1000
Subject: SSR: Use T! instead of SyntaxKind::* where possible

---
 crates/ra_ssr/src/parsing.rs | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

(limited to 'crates/ra_ssr/src')

diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ra_ssr/src/parsing.rs
index 0f4f88b7c..5ea125616 100644
--- a/crates/ra_ssr/src/parsing.rs
+++ b/crates/ra_ssr/src/parsing.rs
@@ -6,7 +6,7 @@
 //! e.g. expressions, type references etc.
 
 use crate::{SsrError, SsrPattern, SsrRule};
-use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind};
+use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind, T};
 use rustc_hash::{FxHashMap, FxHashSet};
 use std::str::FromStr;
 
@@ -161,7 +161,7 @@ fn parse_pattern(pattern_str: &str) -> Result<Vec<PatternElement>, SsrError> {
     let mut placeholder_names = FxHashSet::default();
     let mut tokens = tokenize(pattern_str)?.into_iter();
     while let Some(token) = tokens.next() {
-        if token.kind == SyntaxKind::DOLLAR {
+        if token.kind == T![$] {
             let placeholder = parse_placeholder(&mut tokens)?;
             if !placeholder_names.insert(placeholder.ident.clone()) {
                 bail!("Name `{}` repeats more than once", placeholder.ident);
@@ -226,7 +226,7 @@ fn parse_placeholder(tokens: &mut std::vec::IntoIter<Token>) -> Result<Placehold
             SyntaxKind::IDENT => {
                 name = Some(token.text);
             }
-            SyntaxKind::L_CURLY => {
+            T!['{'] => {
                 let token =
                     tokens.next().ok_or_else(|| SsrError::new("Unexpected end of placeholder"))?;
                 if token.kind == SyntaxKind::IDENT {
@@ -237,10 +237,10 @@ fn parse_placeholder(tokens: &mut std::vec::IntoIter<Token>) -> Result<Placehold
                         .next()
                         .ok_or_else(|| SsrError::new("Placeholder is missing closing brace '}'"))?;
                     match token.kind {
-                        SyntaxKind::COLON => {
+                        T![:] => {
                             constraints.push(parse_constraint(tokens)?);
                         }
-                        SyntaxKind::R_CURLY => break,
+                        T!['}'] => break,
                         _ => bail!("Unexpected token while parsing placeholder: '{}'", token.text),
                     }
                 }
@@ -330,24 +330,24 @@ mod tests {
             result.pattern.raw.tokens,
             vec![
                 token(SyntaxKind::IDENT, "foo"),
-                token(SyntaxKind::L_PAREN, "("),
+                token(T!['('], "("),
                 placeholder("a"),
-                token(SyntaxKind::COMMA, ","),
+                token(T![,], ","),
                 token(SyntaxKind::WHITESPACE, " "),
                 placeholder("b"),
-                token(SyntaxKind::R_PAREN, ")"),
+                token(T![')'], ")"),
             ]
         );
         assert_eq!(
             result.template.tokens,
             vec![
                 token(SyntaxKind::IDENT, "bar"),
-                token(SyntaxKind::L_PAREN, "("),
+                token(T!['('], "("),
                 placeholder("b"),
-                token(SyntaxKind::COMMA, ","),
+                token(T![,], ","),
                 token(SyntaxKind::WHITESPACE, " "),
                 placeholder("a"),
-                token(SyntaxKind::R_PAREN, ")"),
+                token(T![')'], ")"),
             ]
         );
     }
-- 
cgit v1.2.3