diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-15 13:45:58 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-15 13:45:58 +0100 |
commit | ec7d2f64ade9ffa35a64e82ac53e65ad5cbe9efd (patch) | |
tree | b8693ce808a9ca2e7eaae5013644a1082fc7bb17 /crates/ra_mbe/src/subtree_source.rs | |
parent | 64ab5ab10d32e7e8ec085af818d3d94211aea39b (diff) | |
parent | 993abedd77cf23ce2281b6c8e60cab49ab4fa97e (diff) |
Merge #1278
1278: Apply T! macro where posible r=matklad a=pasa
apply T! macro implemented in #1248
Co-authored-by: Sergey Parilin <[email protected]>
Diffstat (limited to 'crates/ra_mbe/src/subtree_source.rs')
-rw-r--r-- | crates/ra_mbe/src/subtree_source.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index 3554dc110..c938acf64 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_parser::{TokenSource}; | 1 | use ra_parser::{TokenSource}; |
2 | use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*}; | 2 | use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T}; |
3 | use std::cell::{RefCell}; | 3 | use std::cell::{RefCell}; |
4 | 4 | ||
5 | // A Sequece of Token, | 5 | // A Sequece of Token, |
@@ -284,9 +284,9 @@ impl<'a> TokenSource for SubtreeTokenSource<'a> { | |||
284 | 284 | ||
285 | fn convert_delim(d: tt::Delimiter, closing: bool) -> TtToken { | 285 | fn convert_delim(d: tt::Delimiter, closing: bool) -> TtToken { |
286 | let (kinds, texts) = match d { | 286 | let (kinds, texts) = match d { |
287 | tt::Delimiter::Parenthesis => ([L_PAREN, R_PAREN], "()"), | 287 | tt::Delimiter::Parenthesis => ([T!['('], T![')']], "()"), |
288 | tt::Delimiter::Brace => ([L_CURLY, R_CURLY], "{}"), | 288 | tt::Delimiter::Brace => ([T!['{'], T!['}']], "{}"), |
289 | tt::Delimiter::Bracket => ([L_BRACK, R_BRACK], "[]"), | 289 | tt::Delimiter::Bracket => ([T!['['], T![']']], "[]"), |
290 | tt::Delimiter::None => ([L_DOLLAR, R_DOLLAR], ""), | 290 | tt::Delimiter::None => ([L_DOLLAR, R_DOLLAR], ""), |
291 | }; | 291 | }; |
292 | 292 | ||
@@ -299,8 +299,8 @@ fn convert_delim(d: tt::Delimiter, closing: bool) -> TtToken { | |||
299 | fn convert_literal(l: &tt::Literal) -> TtToken { | 299 | fn convert_literal(l: &tt::Literal) -> TtToken { |
300 | let kind = | 300 | let kind = |
301 | classify_literal(&l.text).map(|tkn| tkn.kind).unwrap_or_else(|| match l.text.as_ref() { | 301 | classify_literal(&l.text).map(|tkn| tkn.kind).unwrap_or_else(|| match l.text.as_ref() { |
302 | "true" => SyntaxKind::TRUE_KW, | 302 | "true" => T![true], |
303 | "false" => SyntaxKind::FALSE_KW, | 303 | "false" => T![false], |
304 | _ => panic!("Fail to convert given literal {:#?}", &l), | 304 | _ => panic!("Fail to convert given literal {:#?}", &l), |
305 | }); | 305 | }); |
306 | 306 | ||
@@ -320,11 +320,11 @@ fn convert_ident(ident: &tt::Ident) -> TtToken { | |||
320 | fn convert_punct(p: &tt::Punct) -> TtToken { | 320 | fn convert_punct(p: &tt::Punct) -> TtToken { |
321 | let kind = match p.char { | 321 | let kind = match p.char { |
322 | // lexer may produce compound tokens for these ones | 322 | // lexer may produce compound tokens for these ones |
323 | '.' => DOT, | 323 | '.' => T![.], |
324 | ':' => COLON, | 324 | ':' => T![:], |
325 | '=' => EQ, | 325 | '=' => T![=], |
326 | '!' => EXCL, | 326 | '!' => T![!], |
327 | '-' => MINUS, | 327 | '-' => T![-], |
328 | c => SyntaxKind::from_char(c).unwrap(), | 328 | c => SyntaxKind::from_char(c).unwrap(), |
329 | }; | 329 | }; |
330 | let text = { | 330 | let text = { |