You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered a problem with documentation comments in Rust code that cause cargo expand to have unformatted blobs of code in its output.
In the picture above you can clearly see the entirely unformatted section of code next to some properly fomatted sections of code.
The whole things got fixed by manually converting some /// doc comments into normal comments // basically removing them.
I don't yet know whether this also happens with other attributes, however, note that the code does contain other attributes should as #[inline] or certain derives which got expanded properly.
Also note that cargo expand in fact seems to use rustfmt since cargo expand --ugly produces very different output that does not contain these entirely unformatted sections of code. However, code with cargo expand --ugly tends to look more ... ugly in general so it is also not a serious work around for me for now.
I would be shocked if this were a cargo-expand issue. Could you report to rustfmt instead, with a minimized repro? Cargo-expand does not control what parts of the file rustfmt would run on.
What do you think this could be the reason for this? I opened an issue for the rustfmt tool and the problem is that this code snippet really only works for reproducability with cargo-expand but not rustfmt.
I encountered a problem with documentation comments in Rust code that cause

cargo expand
to have unformatted blobs of code in its output.In the picture above you can clearly see the entirely unformatted section of code next to some properly fomatted sections of code.
The whole things got fixed by manually converting some
///
doc comments into normal comments//
basically removing them.I don't yet know whether this also happens with other attributes, however, note that the code does contain other attributes should as
#[inline]
or certain derives which got expanded properly.Also note that
cargo expand
in fact seems to userustfmt
sincecargo expand --ugly
produces very different output that does not contain these entirely unformatted sections of code. However, code withcargo expand --ugly
tends to look more ... ugly in general so it is also not a serious work around for me for now.You can reproduce the problem with:
This issue seems to be similar to #71.
The text was updated successfully, but these errors were encountered: