Skip to content

Commit dee9f7b

Browse files
committed
Add comments why to avoid suggest converting doc comment to regular when missing a comma before doc in lists
Signed-off-by: xizheyin <[email protected]>
1 parent e9bbf23 commit dee9f7b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,13 @@ impl<'a> Parser<'a> {
686686
}
687687

688688
if let token::DocComment(kind, style, _) = self.token.kind {
689+
// This is to avoid suggesting converting a doc comment to a regular comment
690+
// when missing a comma before the doc comment in lists. (issue #142311)
691+
// For example:
692+
// `enum Foo{
693+
// A ///xxxxxxx
694+
// B,
695+
// }`
689696
if !expected.contains(&TokenType::Comma) {
690697
// We have something like `expr //!val` where the user likely meant `expr // !val`
691698
let pos = self.token.span.lo() + BytePos(2);

0 commit comments

Comments
 (0)