If wrap_comments is true, doc comments on use declarations are wrapped to 5 characters less than max_width (or comment_width, if it is less than max_width - 5). This makes it impossible to wrap such comments to the same value as max_width.
Example:
test.rs:
/// a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
/// aa a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
pub use u32;
/// a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
/// aa a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
pub struct X;
After running rustfmt --config wrap_comments=true,comment_width=79,max_width=79 test.rs:
/// a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
/// a a a a a a a a a a aa a a a a a a a a a a a a a a a a a a a a a a a a
/// a a a a a a a a a a a a a a a a a a a a
pub use u32;
/// a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
/// a a a a a a a aa a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
/// a a a a a a a a a a a a a a a
pub struct X;
The comment on the use declaration is wrapped to 74 characters, exactly 5 less than 79. This five-character difference persists across different values of comment_width and max_width, except if comment_width is more than 5 characters less than max_width, both doc comments will be limited to that value.
If
wrap_commentsis true, doc comments onusedeclarations are wrapped to 5 characters less thanmax_width(orcomment_width, if it is less thanmax_width- 5). This makes it impossible to wrap such comments to the same value asmax_width.Example:
test.rs:
After running
rustfmt --config wrap_comments=true,comment_width=79,max_width=79 test.rs:The comment on the
usedeclaration is wrapped to 74 characters, exactly 5 less than 79. This five-character difference persists across different values ofcomment_widthandmax_width, except ifcomment_widthis more than 5 characters less thanmax_width, both doc comments will be limited to that value.