diff options
| author | bors <bors@rust-lang.org> | 2023-05-18 11:55:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-05-18 11:55:38 +0000 |
| commit | 9ce95674e8d1d0dfb32f9a31f265ad081be4e46f (patch) | |
| tree | fb359ded4da0cd979170a3f64af09fd4a177f1f7 /crates/syntax/src/validation.rs | |
| parent | 034d7c853705215e90a0d035bd0305c281742ed9 (diff) | |
| parent | 3e528b85f9a3ed25b5dd709aa30dc679ccc5817f (diff) | |
Auto merge of #14837 - Veykril:rustc-lexer, r=Veykril
Support c string literals
Diffstat (limited to 'crates/syntax/src/validation.rs')
| -rw-r--r-- | crates/syntax/src/validation.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/syntax/src/validation.rs b/crates/syntax/src/validation.rs index 089ad74dadc..e0ec6a242ff 100644 --- a/crates/syntax/src/validation.rs +++ b/crates/syntax/src/validation.rs @@ -9,7 +9,7 @@ use rustc_lexer::unescape::{self, unescape_literal, Mode}; use crate::{ algo, - ast::{self, HasAttrs, HasVisibility}, + ast::{self, HasAttrs, HasVisibility, IsString}, match_ast, AstNode, SyntaxError, SyntaxKind::{CONST, FN, INT_NUMBER, TYPE_ALIAS}, SyntaxNode, SyntaxToken, TextSize, T, @@ -156,6 +156,17 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) { } } } + ast::LiteralKind::CString(s) => { + if !s.is_raw() { + if let Some(without_quotes) = unquote(text, 2, '"') { + unescape_literal(without_quotes, Mode::ByteStr, &mut |range, char| { + if let Err(err) = char { + push_err(1, range.start, err); + } + }); + } + } + } ast::LiteralKind::Char(_) => { if let Some(without_quotes) = unquote(text, 1, '\'') { unescape_literal(without_quotes, Mode::Char, &mut |range, char| { |
