diff options
| author | Michael Howell <michael@notriddle.com> | 2022-04-04 17:37:59 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-04-04 17:39:35 -0700 |
| commit | bec8dbdb602688d6da4f49b7fdd74226f0f9f04c (patch) | |
| tree | 70177740bbd8b4b90213e8823648b61870e4a79e /library/core/src/ops/function.rs | |
| parent | 60e50fc1cfe0bb693a5f4f93eb83ef70854531e3 (diff) | |
| download | rust-bec8dbdb602688d6da4f49b7fdd74226f0f9f04c.tar.gz rust-bec8dbdb602688d6da4f49b7fdd74226f0f9f04c.zip | |
diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut
Fixes #90073
Diffstat (limited to 'library/core/src/ops/function.rs')
| -rw-r--r-- | library/core/src/ops/function.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs index e5c4798afcb..a7b28471bfe 100644 --- a/library/core/src/ops/function.rs +++ b/library/core/src/ops/function.rs @@ -59,6 +59,10 @@ Args = "()", note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`" ), + on( + _Self = "unsafe fn", + note = "unsafe functions must be wrapped in closures: `|| unsafe {{ /* code */ }}`" + ), message = "expected a `{Fn}<{Args}>` closure, found `{Self}`", label = "expected an `Fn<{Args}>` closure, found `{Self}`" )] @@ -139,6 +143,10 @@ pub trait Fn<Args>: FnMut<Args> { Args = "()", note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`" ), + on( + _Self = "unsafe fn", + note = "unsafe functions must be wrapped in closures: `|| unsafe {{ /* code */ }}`" + ), message = "expected a `{FnMut}<{Args}>` closure, found `{Self}`", label = "expected an `FnMut<{Args}>` closure, found `{Self}`" )] @@ -211,6 +219,10 @@ pub trait FnMut<Args>: FnOnce<Args> { Args = "()", note = "wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}`" ), + on( + _Self = "unsafe fn", + note = "unsafe functions must be wrapped in closures: `|| unsafe {{ /* code */ }}`" + ), message = "expected a `{FnOnce}<{Args}>` closure, found `{Self}`", label = "expected an `FnOnce<{Args}>` closure, found `{Self}`" )] |
