`imports_granularity` adds extra import due to empty `{}` import

Đang mở
#7,140 4 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.

  • #7141 của @tayfuryldz — đã đó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
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả 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

Start by reproducing the issue with cargo fmt using imports_granularity = "Module" and the shown nested empty import. Trace the imports_granularity handling in rustfmt, then verify that formatting produces only use std::sync::Arc; and add or update a regression test if the relevant test location is identified.

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

Mô tả

A-imports C-bug I-changes-semantics only-with-option UO-imports_granularity

Summary

I tried to format this code:

use std::sync::{Arc, atomic::{}};
Expected behavior
use std::sync::Arc;
Actual behavior
use std::sync;
use std::sync::Arc;

Configuration

rustfmt configuration file (e.g. rustfmt.toml, if applicable):

style_edition = "2024"
imports_granularity = "Module"

Reproduction Steps

cargo fmt

Meta

rustfmt --version:

rustfmt 1.10.0-nightly (bba531001d 2026-09-20)
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.