Recognize when a block comment has been ended inside a string literal (#4312)

This commit is contained in:
ChinYing-Li 2021-04-12 17:26:18 +08:00 committed by Caleb Cartwright
parent 58157bb4b7
commit dac2423f3f
3 changed files with 19 additions and 0 deletions

View File

@ -1311,6 +1311,9 @@ where
char_kind = FullCodeCharKind::InStringCommented;
if chr == '"' {
CharClassesStatus::BlockComment(deepness)
} else if chr == '*' && self.base.peek().map(RichChar::get_char) == Some('/') {
char_kind = FullCodeCharKind::InComment;
CharClassesStatus::BlockCommentClosing(deepness - 1)
} else {
CharClassesStatus::StringInBlockComment(deepness)
}

View File

@ -0,0 +1,8 @@
fn main() {
/* " */
println!("Hello, world!");
/* abc " */
println!("Hello, world!");
/* " abc */
println!("Hello, world!");
}

View File

@ -0,0 +1,8 @@
fn main() {
/* " */
println!("Hello, world!");
/* abc " */
println!("Hello, world!");
/* " abc */
println!("Hello, world!");
}