From 0e803417f997ba35c0045704dd347e64c2a1786c Mon Sep 17 00:00:00 2001 From: Takayuki Nakata Date: Mon, 16 Nov 2020 12:14:10 +0900 Subject: [PATCH] Add `rustfmt::skip` as a work around because comments are checked and removed by rustfmt for some reason --- tests/ui/cast_ref_to_mut.rs | 4 ++++ tests/ui/cast_ref_to_mut.stderr | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/ui/cast_ref_to_mut.rs b/tests/ui/cast_ref_to_mut.rs index 089e5cfabe4b..0ede958d1706 100644 --- a/tests/ui/cast_ref_to_mut.rs +++ b/tests/ui/cast_ref_to_mut.rs @@ -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); diff --git a/tests/ui/cast_ref_to_mut.stderr b/tests/ui/cast_ref_to_mut.stderr index aacd99437d9f..d36aa0e00eec 100644 --- a/tests/ui/cast_ref_to_mut.stderr +++ b/tests/ui/cast_ref_to_mut.stderr @@ -1,5 +1,5 @@ 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"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,13 +7,13 @@ 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"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^