Skip to content

Rustfmt loses visibility on some trait items and impl items #4960

Closed
@dtolnay

Description

@dtolnay

As of current master, rustfmt applies the following incorrect diff to this valid Rust code.

 #[cfg(any())]
 trait Visible {
-    pub const C: i32;
+    const C: i32;
     pub type T;
-    pub fn f();
+    fn f();
-    pub fn g() {}
+    fn g() {}
 }

 #[cfg(any())]
 impl Visible for Bar {
     pub const C: i32;
     pub type T;
-    pub fn f();
+    fn f();
     pub fn g() {}
 }

To reproduce: cargo run --bin rustfmt repro.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    2x-port:pendingbugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions