diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut
Fixes #90073
This commit is contained in:
@@ -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}`"
|
||||
)]
|
||||
|
||||
Reference in New Issue
Block a user