Skip to content

Commit

Permalink
Add rustfmt::skip as a work around
Browse files Browse the repository at this point in the history
because comments are checked and removed by rustfmt for some reason
  • Loading branch information
giraffate committed Nov 16, 2020
1 parent 27a1572 commit 0e80341
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions tests/ui/cast_ref_to_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#![allow(clippy::no_effect)]

extern "C" {
#[rustfmt::skip]
// TODO: This `rustfmt::skip` is a work around of #6336 because
// the following comments are checked by rustfmt for some reason.
//
// N.B., mutability can be easily incorrect in FFI calls -- as
// in C, the default is mutable pointers.
fn ffi(c: *mut u8);
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/cast_ref_to_mut.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
error: casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell`
--> $DIR/cast_ref_to_mut.rs:18:9
--> $DIR/cast_ref_to_mut.rs:22:9
|
LL | (*(a as *const _ as *mut String)).push_str(" world");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::cast-ref-to-mut` implied by `-D warnings`

error: casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell`
--> $DIR/cast_ref_to_mut.rs:19:9
--> $DIR/cast_ref_to_mut.rs:23:9
|
LL | *(a as *const _ as *mut _) = String::from("Replaced");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell`
--> $DIR/cast_ref_to_mut.rs:20:9
--> $DIR/cast_ref_to_mut.rs:24:9
|
LL | *(a as *const _ as *mut String) += " world";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit 0e80341

Please sign in to comment.