diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-06 21:39:02 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-06 21:39:02 +0000 |
commit | 7f12a1f225c7d3397f27964ce039b55d680772d3 (patch) | |
tree | 26043b20588eae4510e28249f11a094aacaf190d /crates/syntax/src/ast/expr_ext.rs | |
parent | cdddcaee851be1cff1eeb23599f5a58f1b30a927 (diff) | |
parent | 6158304f8b64ef7cdf58b14bc675baf33a27a853 (diff) |
Merge #6485
6485: Remove RAW literals r=matklad a=matklad
bors r+
🤖
closes https://github.com/rust-analyzer/rust-analyzer/issues/6308
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/syntax/src/ast/expr_ext.rs')
-rw-r--r-- | crates/syntax/src/ast/expr_ext.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/syntax/src/ast/expr_ext.rs b/crates/syntax/src/ast/expr_ext.rs index 3d33cd1cf..eb44bb2ab 100644 --- a/crates/syntax/src/ast/expr_ext.rs +++ b/crates/syntax/src/ast/expr_ext.rs | |||
@@ -320,6 +320,13 @@ impl ast::Literal { | |||
320 | ast::IntNumber::cast(self.token()) | 320 | ast::IntNumber::cast(self.token()) |
321 | } | 321 | } |
322 | 322 | ||
323 | pub fn as_string(&self) -> Option<ast::String> { | ||
324 | ast::String::cast(self.token()) | ||
325 | } | ||
326 | pub fn as_byte_string(&self) -> Option<ast::ByteString> { | ||
327 | ast::ByteString::cast(self.token()) | ||
328 | } | ||
329 | |||
323 | fn find_suffix(text: &str, possible_suffixes: &[&str]) -> Option<SmolStr> { | 330 | fn find_suffix(text: &str, possible_suffixes: &[&str]) -> Option<SmolStr> { |
324 | possible_suffixes | 331 | possible_suffixes |
325 | .iter() | 332 | .iter() |
@@ -351,10 +358,10 @@ impl ast::Literal { | |||
351 | suffix: Self::find_suffix(&text, &ast::FloatNumber::SUFFIXES), | 358 | suffix: Self::find_suffix(&text, &ast::FloatNumber::SUFFIXES), |
352 | } | 359 | } |
353 | } | 360 | } |
354 | STRING | RAW_STRING => LiteralKind::String, | 361 | STRING => LiteralKind::String, |
355 | T![true] => LiteralKind::Bool(true), | 362 | T![true] => LiteralKind::Bool(true), |
356 | T![false] => LiteralKind::Bool(false), | 363 | T![false] => LiteralKind::Bool(false), |
357 | BYTE_STRING | RAW_BYTE_STRING => LiteralKind::ByteString, | 364 | BYTE_STRING => LiteralKind::ByteString, |
358 | CHAR => LiteralKind::Char, | 365 | CHAR => LiteralKind::Char, |
359 | BYTE => LiteralKind::Byte, | 366 | BYTE => LiteralKind::Byte, |
360 | _ => unreachable!(), | 367 | _ => unreachable!(), |