Skip to content

Doc comments on use declarations are limited to 5 characters less than max_width #5914

@taylordotfish

Description

@taylordotfish

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-commentsArea: commentsonly-with-optionRequires a non-default option value to reproduce

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions