Skip to content

enum variant doc comments are wrapped before comment_width #5801

@InsertCreativityHere

Description

@InsertCreativityHere

Using rustfmt 1.5.3-nightly (5ea66686 2023-06-27), with the following configuration options:

comment_width = 120
wrap_comments = true
unstable_features = true
max_width = 120

Sometimes comments are wrapped after 119 columns instead of the 120 columns I'd expect. It also seems context dependent.

For example, both of these lines are 120 columns, and neither get wrapped.

/// This function is 120 columns wide and is left alone. This comment is 120 columns wide and the formatter is also fine
fn my_super_cool_function_name(my_very_cool_argument_name: String, my_other_very_cool_argument_name: String) -> String {
    unimplemented!()
}

But this comment's line is 120 columns long, and does get wrapped:

pub enum Severity {
    /// But here, this comment is 120 columns wide and the formatter wants to split it up onto two separate lines still.
    Error,
}

I have a little repository demonstrating this: https://github.com/InsertCreativityHere/rustfmt-comment-width-weirdness

Metadata

Metadata

Assignees

Labels

A-commentsArea: commentsS-fixed-with-v2Status: resolved by setting `version = "Two"` in your projects rustfmt.toml

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions