-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
format_code_in_doc_comments makes multiline comments invalid #4421
Comments
confirming this is reproducible with Linking tracking issue for |
@rustbot claim |
Had some time to look into this today. It seems like the root cause is that the rewriting is pretty messy in terms of determining separation of comments when block comment are involved. This also includes issues with the enum Original {
/* foo */
/* bar */
}
enum DocComments {
/** foo */
/** bar */
Variant,
}
enum Mix {
// inline /* still inline */
/* block1 */ /* block2 */
Foo,
/* block */
// inline
/* block */
Bar,
} With enum Original {
/* foo */
* bar */
}
enum DocComments {
/** foo */
* bar */
Variant,
}
enum Mix {
// inline /* still inline */
/* block1 */ /* block2 */
Foo,
/* block */
* inline
* block */
Bar,
} With enum Original {
// foo */
// bar
}
enum DocComments {
/// foo */
/// bar
Variant,
}
enum Mix {
// inline /* still inline */
// block1 */ /* block2
Foo,
// block */
// inline
// block
Bar,
} It seems like the solution is properly handling parsing where comments start and end. That's all I have time for today though |
From poking around it looks like #5306 fixes all of the issues when using |
I can't reproduce the original issue anymore. I think #5536 was responsible for resolving it. |
Describe the bug
All this happens only with
format_code_in_doc_comments=true
.This is a follow up issue of #4420. When reformatting the output of that issue, another issue occurs. Two subsequent multiline comments (
/* */
), though in one line each, are transformed to invalid syntax as the opening indicator/*
of the second line gets transformed to an asterisk*
only.To Reproduce
I use the (wrong) output from #4420 as basis and make it even more minimal (it can also be reproduced with the full output of that issue). When running the code blow with
rustfmt --config format_code_in_doc_comments=true
The output is:
That is even invalid syntax.
Expected behavior
I would expect that the code is untouched by
rustfmt
.Meta
rustfmt
, but it also happens withcargo fmt
The text was updated successfully, but these errors were encountered: