diff options
| author | kennytm <kennytm@gmail.com> | 2018-08-21 01:20:12 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-21 01:20:12 +0800 |
| commit | ffde96c201431a36e843ce51fb97e4f003555918 (patch) | |
| tree | 787d444641aa06fcd999781752f66ae3b1b7a55e /src/libcore | |
| parent | fa3d56aca898897abe1d3154cacfa0a3a2619b64 (diff) | |
| parent | cea73d6341a136c6f915c45133748ecfbe36729b (diff) | |
| download | rust-ffde96c201431a36e843ce51fb97e4f003555918.tar.gz rust-ffde96c201431a36e843ce51fb97e4f003555918.zip | |
Rollup merge of #53296 - estebank:suggest-closure, r=KodrAus
When closure with no arguments was expected, suggest wrapping Fix #49694.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/ops/function.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libcore/ops/function.rs b/src/libcore/ops/function.rs index d10fcb86b24..3ebd10a9209 100644 --- a/src/libcore/ops/function.rs +++ b/src/libcore/ops/function.rs @@ -66,6 +66,11 @@ #[lang = "fn"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] +#[rustc_on_unimplemented( + on(Args="()", note="wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}"), + message="expected a `{Fn}<{Args}>` closure, found `{Self}`", + label="expected an `Fn<{Args}>` closure, found `{Self}`", +)] #[fundamental] // so that regex can rely that `&str: !FnMut` pub trait Fn<Args> : FnMut<Args> { /// Performs the call operation. @@ -139,6 +144,11 @@ pub trait Fn<Args> : FnMut<Args> { #[lang = "fn_mut"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] +#[rustc_on_unimplemented( + on(Args="()", note="wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}"), + message="expected a `{FnMut}<{Args}>` closure, found `{Self}`", + label="expected an `FnMut<{Args}>` closure, found `{Self}`", +)] #[fundamental] // so that regex can rely that `&str: !FnMut` pub trait FnMut<Args> : FnOnce<Args> { /// Performs the call operation. @@ -212,6 +222,11 @@ pub trait FnMut<Args> : FnOnce<Args> { #[lang = "fn_once"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_paren_sugar] +#[rustc_on_unimplemented( + on(Args="()", note="wrap the `{Self}` in a closure with no arguments: `|| {{ /* code */ }}"), + message="expected a `{FnOnce}<{Args}>` closure, found `{Self}`", + label="expected an `FnOnce<{Args}>` closure, found `{Self}`", +)] #[fundamental] // so that regex can rely that `&str: !FnMut` pub trait FnOnce<Args> { /// The returned type after the call operator is used. |
