Skip to content

Commit 7bc7173

Browse files
Merge #4134
4134: Special case for empty comments in doc comment kind r=matklad a=edwin0cheng Part of #4103 Fix `ui/empty/empty-comment.rs macros` Co-authored-by: Edwin Cheng <[email protected]>
2 parents f654f49 + f0fece4 commit 7bc7173

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

crates/ra_mbe/src/tests.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,3 +1849,16 @@ fn test_expand_bad_literal() {
18491849
)
18501850
.assert_expand_err(r#"foo!(&k");"#, &ExpandError::BindingError("".into()));
18511851
}
1852+
1853+
#[test]
1854+
fn test_empty_comments() {
1855+
parse_macro(
1856+
r#"
1857+
macro_rules! one_arg_macro { ($fmt:expr) => (); }
1858+
"#,
1859+
)
1860+
.assert_expand_err(
1861+
r#"one_arg_macro!(/**/)"#,
1862+
&ExpandError::BindingError("expected Expr".into()),
1863+
);
1864+
}

crates/ra_syntax/src/ast/tokens.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ const COMMENT_PREFIX_TO_KIND: &[(&str, CommentKind)] = {
5858
};
5959

6060
fn kind_by_prefix(text: &str) -> CommentKind {
61+
if text == "/**/" {
62+
return CommentKind { shape: CommentShape::Block, doc: None };
63+
}
6164
for (prefix, kind) in COMMENT_PREFIX_TO_KIND.iter() {
6265
if text.starts_with(prefix) {
6366
return *kind;

0 commit comments

Comments
 (0)