about summary refs log tree commit diff
path: root/library/core/src/ops/function.rs
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-04-05 11:13:48 -0700
committerMichael Howell <michael@notriddle.com>2022-04-05 11:13:48 -0700
commit6d18fbbc3f1fee9e717ae5f55bd2970d96e2b5cb (patch)
tree4278d8e877dfe48cdbdcd1b5e465c5d729c7da3b /library/core/src/ops/function.rs
parentdcf7ce8356ce9182d65b0719216ec08db877d5cc (diff)
downloadrust-6d18fbbc3f1fee9e717ae5f55bd2970d96e2b5cb.tar.gz
rust-6d18fbbc3f1fee9e717ae5f55bd2970d96e2b5cb.zip
diagnostics: tweak error message to give more rationale to unsafe Fn
Diffstat (limited to 'library/core/src/ops/function.rs')
-rw-r--r--library/core/src/ops/function.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs
index 19918e0dcea..ae879078739 100644
--- a/library/core/src/ops/function.rs
+++ b/library/core/src/ops/function.rs
@@ -61,8 +61,9 @@
     ),
     on(
         _Self = "unsafe fn",
+        note = "unsafe function cannot be called generically without an unsafe block",
         // SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
-        note = "unsafe functions must be wrapped in closures: `|| unsafe {{ /* code */ }}`"
+        label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
     ),
     message = "expected a `{Fn}<{Args}>` closure, found `{Self}`",
     label = "expected an `Fn<{Args}>` closure, found `{Self}`"
@@ -146,8 +147,9 @@ pub trait Fn<Args>: FnMut<Args> {
     ),
     on(
         _Self = "unsafe fn",
+        note = "unsafe function cannot be called generically without an unsafe block",
         // SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
-        note = "unsafe functions must be wrapped in closures: `|| unsafe {{ /* code */ }}`"
+        label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
     ),
     message = "expected a `{FnMut}<{Args}>` closure, found `{Self}`",
     label = "expected an `FnMut<{Args}>` closure, found `{Self}`"
@@ -223,8 +225,9 @@ pub trait FnMut<Args>: FnOnce<Args> {
     ),
     on(
         _Self = "unsafe fn",
+        note = "unsafe function cannot be called generically without an unsafe block",
         // SAFETY: tidy is not smart enough to tell that the below unsafe block is a string
-        note = "unsafe functions must be wrapped in closures: `|| unsafe {{ /* code */ }}`"
+        label = "call the function in a closure: `|| unsafe {{ /* code */ }}`"
     ),
     message = "expected a `{FnOnce}<{Args}>` closure, found `{Self}`",
     label = "expected an `FnOnce<{Args}>` closure, found `{Self}`"