rustfmt is off by two for comment length in vertical list pre comments

Đang mở
#7,259 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
62/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
tooling

Hướng nghiên cứu

Reproduce with the supplied config.toml and foo.rs, confirming that the 99-column comment is wrapped even though comment_width = 100. Then trace where rustfmt applies wrap_comments and comment_width in its comment-formatting path, paying attention to indentation and the vertical-list pre-comment case. Done means the 99-column comment stays on one line and the formatter test suite still passes.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

C-bug UO-comment_width UO-wrap_comments

Here is a Rust file with no line longer than 99 bytes, and one line equal to 99 bytes:

enum E {
    // This comment line is 99 columns long, yet rustfmt wraps it onto a second line: aaaaaaaaaaaaa
    A,
}

The comment shouldn't be changed by rustfmt, but it does change it:

> cat config.toml
wrap_comments = true
comment_width = 100

> rustfmt +nightly --version
rustfmt 1.12.0-nightly (bdf712ee87 2026-11-21)

> rustfmt +nightly --emit=stdout --config-path config.toml foo.rs
enum E {
    // This comment line is 99 columns long, yet rustfmt wraps it onto a second line:
    // aaaaaaaaaaaaa
    A,
}

(This is similar to #7258, but I've filed it separately because I suspect it has a different root cause.)

Ngôn ngữ chính
Rust
Star
7.1k
Fork
1.2k
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
20

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rust-lang/rustfmt

Tất cả issue của rust-lang/rustfmt

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.