Skip to content

Escape comment delimiters in doc comments written as C block comments - #1195

Open
Shriraj1901 wants to merge 1 commit into
mozilla:mainfrom
Shriraj1901:fix-doc-comment-delimiters
Open

Shriraj1901 wants to merge 1 commit into
mozilla:mainfrom
Shriraj1901:fix-doc-comment-delimiters

Conversation

@Shriraj1901

Copy link
Copy Markdown

Documentation is copied into the header line by line. With the c and doxy styles (doxy is what auto picks for C) the lines sit inside a /* ... */ block, so a doc comment that contains */ ends the comment early and the rest of the line lands in the header as code. A doc line such as "Matches src/*/mod.rs" is enough to make the header fail to compile. A /* inside the block is diagnosed by -Wcomment.

Rewrite */ as *\/ and /* as /\* for those two styles. The // and /// styles and the Cython output are unchanged.

Fixes #1033.

Documentation is copied into the header line by line. With the `c` and
`doxy` styles (doxy is what `auto` picks for C) the lines sit inside a
`/* ... */` block, so a doc comment that contains `*/` ends the comment
early and the rest of the line lands in the header as code. A doc line
such as "Matches `src/*/mod.rs`" is enough to make the header fail to
compile. A `/*` inside the block is diagnosed by -Wcomment.

Rewrite `*/` as `*\/` and `/*` as `/\*` for those two styles. The `//`
and `///` styles and the Cython output are unchanged.

Fixes mozilla#1033.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C style comments are produced unescaped

1 participant