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);
}
Activity
calebcartwright commentedon Nov 16, 2020
Thanks for the report @giraffate, see the problem and will try to get the fix out to nightly ASAP
faern commentedon Nov 17, 2020
It only remove multi line comments. Single line comments are preserved.
Rollup merge of rust-lang#79120 - calebcartwright:update-rustfmt, r=M…
extern
block are deleted #4533berkus commentedon Nov 17, 2020
Not true.

Adjust for nightly rustfmt bug
calebcartwright commentedon Nov 18, 2020
Closing as this is resolved in v1.4.27 available in the latest nightly (2020-11-18)
Revert "Add `rustfmt::skip` as a work around"
rustfmt::skip
as a work around" rust-lang/rust-clippy#6345Auto merge of #6345 - giraffate:follow_up_of_rustup, r=flip1995
Revert “Adjust for nightly rustfmt bug”