mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Support c string literals
This commit is contained in:
parent
099b5b3b15
commit
4b577e2bc8
21 changed files with 176 additions and 34 deletions
|
@ -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| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue