Closed
Description
Describe the bug
rustfmt removes comments in extern. This seems to be introduced since v1.4.26. I found this in clippy CI https://github.com/rust-lang/rust-clippy/pull/6336/checks?check_run_id=1404315427 in PR rust-lang/rust-clippy#6336.
To Reproduce
$ cd rust-clippy
$ path/to/rustfmt/target/debug/rustfmt/target/debug/rustfmt tests/ui/cast_ref_to_mut.rs --check
Diff in /Users/tnakata/workspace/rust-clippy/tests/ui/cast_ref_to_mut.rs at line 2:
#![allow(clippy::no_effect)]
extern "C" {
- // N.B., mutability can be easily incorrect in FFI calls -- as
- // in C, the default is mutable pointers.
fn ffi(c: *mut u8);
fn int_ffi(c: *mut i32);
}
Expected behavior
not to remove comments
Meta
- rustfmt version:
$ target/debug/rustfmt -V
rustfmt 1.4.26-nightly (293d7d01 2020-11-14)
- From where did you install rustfmt?:
$ cd rustfmt
$ git checkout refs/tags/v1.4.26
$ CFG_RELEASE=1.45.0-nightly CFG_RELEASE_CHANNEL=nightly cargo build
$ target/debug/rustfmt -V
rustfmt 1.4.26-nightly (293d7d01 2020-11-14)
- How do you run rustfmt:
$ cd rust-clippy
$ path/to/rustfmt/target/debug/rustfmt/target/debug/rustfmt tests/ui/cast_ref_to_mut.rs --check
Diff in /Users/tnakata/workspace/rust-clippy/tests/ui/cast_ref_to_mut.rs at line 2:
#![allow(clippy::no_effect)]
extern "C" {
- // N.B., mutability can be easily incorrect in FFI calls -- as
- // in C, the default is mutable pointers.
fn ffi(c: *mut u8);
fn int_ffi(c: *mut i32);
}