Rust: Handle string literals with line breaks

This commit is contained in:
Simon Friis Vindum
2025-11-19 13:39:48 +01:00
parent 481f627ae0
commit 0e539dbca5
2 changed files with 3 additions and 1 deletions

View File

@@ -68,7 +68,7 @@ module Impl {
* [1]: https://doc.rust-lang.org/reference/tokens.html#string-literals
*/
class StringLiteralExpr extends LiteralExpr {
StringLiteralExpr() { this.getTextValue().regexpMatch("r?#*\".*\"#*") }
StringLiteralExpr() { this.getTextValue().charAt(0) = ["\"", "r"] }
override string getAPrimaryQlClass() { result = "StringLiteralExpr" }
}

View File

@@ -16,6 +16,8 @@ stringLiteral
| literal.rs:21:5:21:8 | r"R" |
| literal.rs:22:5:22:11 | "\\\\x52" |
| literal.rs:23:5:23:11 | r"\\x52" |
| literal.rs:25:5:29:5 | "\n A normal string literal\n... |
| literal.rs:31:5:34:6 | r#"\n A raw string literal\n ... |
integerLiteral
| literal.rs:39:5:39:7 | 123 | |
| literal.rs:40:5:40:10 | 123i32 | i32 |