about summary refs log tree commit diff
path: root/library/core/src/ops/function.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-04-05 22:42:04 +0000
committerbors <bors@rust-lang.org>2022-04-05 22:42:04 +0000
commitbbe9d27b8ff36da56638aa43d6d0cdfdf89a4e57 (patch)
treeb7b097853f762eb4b67e3cd4e4a7df5cb68cdcc7 /library/core/src/ops/function.rs
parent306ba8357fb36212b7d30efb9eb9e41659ac1445 (diff)
parent728f2636ac882f8f31130d156278037e941349d7 (diff)
downloadrust-bbe9d27b8ff36da56638aa43d6d0cdfdf89a4e57.tar.gz
rust-bbe9d27b8ff36da56638aa43d6d0cdfdf89a4e57.zip
Auto merge of #95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #88025 (ScmCredentials netbsd implementation.)
 - #95473 (track individual proc-macro expansions in the self-profiler)
 - #95547 (caution against ptr-to-int transmutes)
 - #95585 (Explain why `&T` is cloned when `T` is not `Clone`)
 - #95591 (Use revisions to track NLL test output (part 1))
 - #95663 (diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut)
 - #95673 (:arrow_up: rust-analyzer)
 - #95681 (resolve: Fix resolution of empty paths passed from rustdoc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/core/src/ops/function.rs')
-rw-r--r--library/core/src/ops/function.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs
index 8383f926435..c5a194b7d0a 100644
--- a/library/core/src/ops/function.rs
+++ b/library/core/src/ops/function.rs
@@ -60,6 +60,12 @@
         Args = "()",
         note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
     ),
+    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
+        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}`"
 )]
@@ -141,6 +147,12 @@ pub trait Fn<Args>: FnMut<Args> {
         Args = "()",
         note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
     ),
+    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
+        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}`"
 )]
@@ -214,6 +226,12 @@ pub trait FnMut<Args>: FnOnce<Args> {
         Args = "()",
         note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`"
     ),
+    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
+        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}`"
 )]