Comment in empty generic arg in macro context is unexpectedly removed

Đang mở
#7,182 0 bình luận 1 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.

  • #7234 của @compiler-segfault — đã đóng, không merge

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/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
devtools

Hướng nghiên cứu

Start by running the reproduction in the issue body: rustfmt on a file containing m!(Foo</*c*/>); inside a macro_rules! context should keep the comment, but it is dropped. Check the related fix in #7181, since this issue is a follow-up to it, and trace how rustfmt handles empty generic arguments inside macro invocations. Done means the comment survives formatting in this case and the existing formatter tests still pass.

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

Mô tả

A-comments A-generics A-macros C-bug I-unexpectedly-removes-code

Summary

Follow-up to #7181.

I tried to format this code:

macro_rules! m { ($f:ident </*c*/>) => {} }
fn main() {
    m!(Foo</*c*/>);
}
Expected behavior

I expected to see this happen: keep the comment in the empty generic arg.

Actual behavior

Instead, this happened: comment is removed.

Diff in /Users/joe.xu/Documents/repos/repro/foo.rs:2:
     ($f:ident </*c*/>) => {};
 }
 fn main() {
-    m!(Foo</*c*/>);
+    m!(Foo<>);
 }

Configuration

rustfmt after #7181 applied.

Reproduction Steps

Just run on the file.

Meta

rustfmt after #7181 applied.

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.