Skip to content

Remove comments in extern #4528

@giraffate

Description

@giraffate

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);
 }

Metadata

Metadata

Labels

C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions