diff options
author | Edwin Cheng <[email protected]> | 2019-04-05 11:45:19 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-04-05 11:45:19 +0100 |
commit | 1ea0238e538dc332b23698d54c02d8bd037f58bb (patch) | |
tree | 824ba6536a7f6f5ba9d8211b81dcb8dbce5c6854 /crates/ra_mbe/src | |
parent | 1ab78d60561ed701b29d3065061cbc3175e20c4a (diff) |
Add classify_literal and undo expose next_token
Diffstat (limited to 'crates/ra_mbe/src')
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 4 |
2 files changed, 4 insertions, 6 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index 3b127526d..38f0049ed 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -343,16 +343,14 @@ SOURCE_FILE@[0; 40) | |||
343 | if let tt::TokenTree::Subtree(subtree) = tt { | 343 | if let tt::TokenTree::Subtree(subtree) = tt { |
344 | return &subtree; | 344 | return &subtree; |
345 | } | 345 | } |
346 | assert!(false, "It is not a subtree"); | 346 | unreachable!("It is not a subtree"); |
347 | unreachable!(); | ||
348 | } | 347 | } |
349 | 348 | ||
350 | fn to_literal(tt: &tt::TokenTree) -> &tt::Literal { | 349 | fn to_literal(tt: &tt::TokenTree) -> &tt::Literal { |
351 | if let tt::TokenTree::Leaf(tt::Leaf::Literal(lit)) = tt { | 350 | if let tt::TokenTree::Leaf(tt::Leaf::Literal(lit)) = tt { |
352 | return lit; | 351 | return lit; |
353 | } | 352 | } |
354 | assert!(false, "It is not a literal"); | 353 | unreachable!("It is not a literal"); |
355 | unreachable!(); | ||
356 | } | 354 | } |
357 | 355 | ||
358 | let rules = create_rules( | 356 | let rules = create_rules( |
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index fbf3d2e71..9664280b5 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use ra_parser::{TokenSource, TreeSink, ParseError}; | 1 | use ra_parser::{TokenSource, TreeSink, ParseError}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, SyntaxNode, TextRange, SyntaxKind, SmolStr, SyntaxTreeBuilder, TreeArc, SyntaxElement, | 3 | AstNode, SyntaxNode, TextRange, SyntaxKind, SmolStr, SyntaxTreeBuilder, TreeArc, SyntaxElement, |
4 | ast, SyntaxKind::*, TextUnit, next_token | 4 | ast, SyntaxKind::*, TextUnit, classify_literal |
5 | }; | 5 | }; |
6 | 6 | ||
7 | /// Maps `tt::TokenId` to the relative range of the original token. | 7 | /// Maps `tt::TokenId` to the relative range of the original token. |
@@ -189,7 +189,7 @@ impl TtTokenSource { | |||
189 | { | 189 | { |
190 | let tok = match token { | 190 | let tok = match token { |
191 | tt::Leaf::Literal(l) => TtToken { | 191 | tt::Leaf::Literal(l) => TtToken { |
192 | kind: next_token(&l.text).kind, | 192 | kind: classify_literal(&l.text).unwrap().kind, |
193 | is_joint_to_next: false, | 193 | is_joint_to_next: false, |
194 | text: l.text.clone(), | 194 | text: l.text.clone(), |
195 | }, | 195 | }, |