Skip to content

Remove comments in extern #4528

Closed
rust-lang/rust
#79120
@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);
 }

Activity

added
bugPanic, non-idempotency, invalid code, etc.
on Nov 16, 2020
calebcartwright

calebcartwright commented on Nov 16, 2020

@calebcartwright
Member

Thanks for the report @giraffate, see the problem and will try to get the fix out to nightly ASAP

faern

faern commented on Nov 17, 2020

@faern

It only remove multi line comments. Single line comments are preserved.

added a commit that references this issue on Nov 17, 2020

Rollup merge of rust-lang#79120 - calebcartwright:update-rustfmt, r=M…

53ddb73
berkus

berkus commented on Nov 17, 2020

@berkus

It only remove multi line comments. Single line comments are preserved.

Not true.
rustfmt_crazy

added a commit that references this issue on Nov 17, 2020
calebcartwright

calebcartwright commented on Nov 18, 2020

@calebcartwright
Member

Closing as this is resolved in v1.4.27 available in the latest nightly (2020-11-18)

added a commit that references this issue on Nov 19, 2020

Auto merge of #6345 - giraffate:follow_up_of_rustup, r=flip1995

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugPanic, non-idempotency, invalid code, etc.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @berkus@faern@calebcartwright@giraffate

    Issue actions

      Remove comments in extern · Issue #4528 · rust-lang/rustfmt