Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6748042

Browse files
committed
Handle raw string literal without any sharps
1 parent 309be47 commit 6748042

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

src/comment.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,10 @@ where
891891
char_kind = FullCodeCharKind::InString;
892892
match chr {
893893
'"' => {
894-
if is_raw_string_suffix(&mut self.base, sharps) {
894+
if sharps == 0 {
895+
char_kind = FullCodeCharKind::Normal;
896+
CharClassesStatus::Normal
897+
} else if is_raw_string_suffix(&mut self.base, sharps) {
895898
CharClassesStatus::RawStringSuffix(sharps)
896899
} else {
897900
CharClassesStatus::LitRawString(sharps)
@@ -944,14 +947,10 @@ where
944947
CharClassesStatus::LitCharEscape => CharClassesStatus::LitChar,
945948
CharClassesStatus::Normal => match chr {
946949
'r' => match self.base.peek().map(|c| c.get_char()) {
947-
Some('#') => {
950+
Some('#') | Some('"') => {
948951
char_kind = FullCodeCharKind::InString;
949952
CharClassesStatus::RawStringPrefix(0)
950953
}
951-
Some('"') => {
952-
char_kind = FullCodeCharKind::InString;
953-
CharClassesStatus::LitString
954-
}
955954
_ => CharClassesStatus::Normal,
956955
},
957956
'"' => {

tests/source/macro_rules.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,12 @@ macro_rules! template {
290290
"##, $name)
291291
}
292292
}
293+
294+
macro_rules! template {
295+
() => {
296+
format_args!(r"
297+
//
298+
299+
")
300+
}
301+
}

tests/target/macro_rules.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,14 @@ macro_rules! template {
347347
)
348348
};
349349
}
350+
351+
macro_rules! template {
352+
() => {
353+
format_args!(
354+
r"
355+
//
356+
357+
"
358+
)
359+
};
360+
}

0 commit comments

Comments
 (0)