]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Lower raw string literals
authorOwen Avery <powerboat9.gamer@gmail.com>
Tue, 25 Mar 2025 22:50:56 +0000 (18:50 -0400)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Wed, 26 Mar 2025 11:46:24 +0000 (11:46 +0000)
gcc/rust/ChangeLog:

* hir/rust-ast-lower-base.cc
(ASTLoweringBase::lower_literal): Lower raw string literals into
normal string literals.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3549.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/hir/rust-ast-lower-base.cc
gcc/testsuite/rust/compile/issue-3549.rs [new file with mode: 0644]

index 52781da1eaf5f2ee9c1c9f855fc487fdd6bcfc9d..749fe09f3baae87f02f8224e691f7a301221d38f 100644 (file)
@@ -933,8 +933,8 @@ ASTLoweringBase::lower_literal (const AST::Literal &literal)
     case AST::Literal::LitType::BYTE_STRING:
       type = HIR::Literal::LitType::BYTE_STRING;
       break;
-    case AST::Literal::LitType::RAW_STRING: // TODO: Lower raw string literals.
-      rust_unreachable ();
+    case AST::Literal::LitType::RAW_STRING:
+      type = HIR::Literal::LitType::STRING;
       break;
     case AST::Literal::LitType::INT:
       type = HIR::Literal::LitType::INT;
diff --git a/gcc/testsuite/rust/compile/issue-3549.rs b/gcc/testsuite/rust/compile/issue-3549.rs
new file mode 100644 (file)
index 0000000..cedbb5a
--- /dev/null
@@ -0,0 +1,3 @@
+fn main() {
+    r#""#;
+}