about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/types.rs10
-rw-r--r--tests/ui/cast_ref_to_mut.stderr11
2 files changed, 7 insertions, 14 deletions
diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs
index 097ff1fecc0..a9fb595e708 100644
--- a/clippy_lints/src/types.rs
+++ b/clippy_lints/src/types.rs
@@ -16,8 +16,8 @@ use crate::utils::paths;
 use crate::utils::{
     clip, comparisons, differing_macro_contexts, higher, in_constant, in_macro, int_bits, last_path_segment,
     match_def_path, match_path, multispan_sugg, opt_def_id, same_tys, sext, snippet, snippet_opt,
-    snippet_with_applicability, span_help_and_lint, span_lint, span_lint_and_sugg, span_lint_and_then,
-    span_note_and_lint, unsext, AbsolutePathBuffer,
+    snippet_with_applicability, span_help_and_lint, span_lint, span_lint_and_sugg, span_lint_and_then, unsext,
+    AbsolutePathBuffer,
 };
 use if_chain::if_chain;
 use rustc::hir;
@@ -2291,13 +2291,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RefToMut {
             if let TyKind::Ptr(MutTy { mutbl: Mutability::MutImmutable, .. }) = t.node;
             if let Ref(..) = cx.tables.node_id_to_type(e.hir_id).sty;
             then {
-                span_note_and_lint(
+                span_lint(
                     cx,
                     CAST_REF_TO_MUT,
                     expr.span,
-                    "casting immutable reference to a mutable reference",
-                    expr.span,
-                    "consider implementing `UnsafeCell` instead",
+                    "casting &T to &mut T may cause undefined behaviour, consider instead using an UnsafeCell",
                 );
             }
         }
diff --git a/tests/ui/cast_ref_to_mut.stderr b/tests/ui/cast_ref_to_mut.stderr
index 23f03f0113d..448a66cfcce 100644
--- a/tests/ui/cast_ref_to_mut.stderr
+++ b/tests/ui/cast_ref_to_mut.stderr
@@ -1,27 +1,22 @@
-error: casting immutable reference to a mutable reference
+error: casting &T to &mut T may cause undefined behaviour, consider instead using an UnsafeCell
   --> $DIR/cast_ref_to_mut.rs:18:9
    |
 LL |         (*(a as *const _ as *mut String)).push_str(" world");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::cast-ref-to-mut` implied by `-D warnings`
-   = note: consider implementing `UnsafeCell` instead
 
-error: casting immutable reference to a mutable reference
+error: casting &T to &mut T may cause undefined behaviour, consider instead using an UnsafeCell
   --> $DIR/cast_ref_to_mut.rs:19:9
    |
 LL |         *(a as *const _ as *mut _) = String::from("Replaced");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: consider implementing `UnsafeCell` instead
 
-error: casting immutable reference to a mutable reference
+error: casting &T to &mut T may cause undefined behaviour, consider instead using an UnsafeCell
   --> $DIR/cast_ref_to_mut.rs:20:9
    |
 LL |         *(a as *const _ as *mut String) += " world";
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: consider implementing `UnsafeCell` instead
 
 error: aborting due to 3 previous errors