mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
dedupe literal parsers
This commit is contained in:
parent
dbf03b674e
commit
73ded3c63c
10 changed files with 220 additions and 374 deletions
|
@ -17,15 +17,15 @@ pub(crate) fn validate_byte_string_node(node: ast::ByteString, errors: &mut Vec<
|
|||
let range = component.range + literal_range.start();
|
||||
|
||||
match component.kind {
|
||||
StringComponentKind::Char(kind) => {
|
||||
StringComponentKind::IgnoreNewline => { /* always valid */ }
|
||||
_ => {
|
||||
// Chars must escape \t, \n and \r codepoints, but strings don't
|
||||
let text = &literal_text[component.range];
|
||||
match text {
|
||||
"\t" | "\n" | "\r" => { /* always valid */ }
|
||||
_ => byte::validate_byte_component(text, kind, range, errors),
|
||||
_ => byte::validate_byte_component(text, component.kind, range, errors),
|
||||
}
|
||||
}
|
||||
StringComponentKind::IgnoreNewline => { /* always valid */ }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue