Closed
Description
Describe the bug
All this happens only with format_code_in_doc_comments=true
.
A comment gets reformatted, during this reformatting the leading parts are removed.
This is triggered within enums and structs (perhaps other things, I haven't tried). The part that is removed has to follow the comment without a whitespace and start with a square opening bracket [
. Everything attached to the bracket (without a whitespace) is removed.
To Reproduce
When running this minimal example with rustfmt --config format_code_in_doc_comments=true
enum Minimal {
Example,
//[thisisremoved thatsleft
// canbeanything
}
The output is:
enum Minimal {
Example,
/* thatsleft */
/* canbeanything */
}
Instead of an enum, the top two lines could also be replaced with a struct, leading to the same buggy behavior:
struct Minimal {
example: Example,
Expected behavior
I would expect that the code is untouched by rustfmt
.
Meta
- rustfmt version: rustfmt 1.4.18-nightly (c1e9b7b 2020-06-13)
- From where did you install rustfmt?: rustup
- How do you run rustfmt:
rustfmt
, but it also happens withcargo fmt