Open
Description
% rustfmt --version
rustfmt 1.7.0-nightly (8679004 2024-05-23)
Content of src/lib.rs
:
/*
0 1 2 3 4 5 6 7 8 9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
*/
// This line has 100 characters ...................................................................9
pub struct Foo {
// This line has 100 characters ...............................................................9
pub foo: u8,
}
pub mod foo {
// This line has 100 characters ...............................................................9
pub fn foo() {}
}
Content of rustfmt.toml
:
comment_width = 100
wrap_comments = true
Expected formatting is that nothing changes. The file is already correctly formatted.
Actual formatting is the following (the line on the foo
field of the Foo
struct is wrapped):
/*
0 1 2 3 4 5 6 7 8 9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
*/
// This line has 100 characters ...................................................................9
pub struct Foo {
// This line has 100 characters
// ...............................................................9
pub foo: u8,
}
pub mod foo {
// This line has 100 characters ...............................................................9
pub fn foo() {}
}
This is probably a minimum reproduction example of #4929, indicating that this is an old issue, and probably not a regression but an off-by-one since the introduction of this feature.
Also I observed that comment_width
seems to be capped by max_width
although this doesn't seem to be documented. Using comment_width = 200
produces the same off-by-one behavior.