Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove comments in extern #4528

Closed
giraffate opened this issue Nov 16, 2020 · 4 comments · Fixed by rust-lang/rust#79120
Closed

Remove comments in extern #4528

giraffate opened this issue Nov 16, 2020 · 4 comments · Fixed by rust-lang/rust#79120
Assignees
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@giraffate
Copy link

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);
 }
@giraffate giraffate added the bug Panic, non-idempotency, invalid code, etc. label Nov 16, 2020
@calebcartwright calebcartwright self-assigned this Nov 16, 2020
@calebcartwright
Copy link
Member

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

@faern
Copy link

faern commented Nov 17, 2020

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

m-ou-se added a commit to m-ou-se/rust that referenced this issue Nov 17, 2020
@berkus
Copy link

berkus commented Nov 17, 2020

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

Not true.
rustfmt_crazy

berkus added a commit to metta-systems/vesper that referenced this issue Nov 17, 2020
See rust-lang/rustfmt#4528
for the bug description, namely rustfmt removes
this comment completely if it's left in the
extern block.
@calebcartwright
Copy link
Member

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

giraffate added a commit to giraffate/rust-clippy that referenced this issue Nov 19, 2020
bors added a commit to rust-lang/rust-clippy that referenced this issue Nov 19, 2020
Revert "Add `rustfmt::skip` as a work around"

This reverts commit 0e80341.

Fixed by rustfmt v1.4.27 available in the latest nightly (2020-11-18). Refer to rust-lang/rustfmt#4528.

changelog: none
berkus added a commit to metta-systems/vesper that referenced this issue Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants