From 69db41244340f67aafadb9b43be661e084a6ef9e Mon Sep 17 00:00:00 2001 From: Eddie Kovsky Date: Sun, 26 May 2019 22:26:02 -0600 Subject: [PATCH 1/4] Add missing error code explanation for E0183 This is part of the ongoing work for #61137 --- src/librustc_typeck/error_codes.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index 6dd3c0113cdcd..94c0ec328c71d 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -1588,6 +1588,20 @@ fn bar(foo: Foo) -> u32 { ``` "##, +E0183: r##" +Fn* traits (`unboxed closures`) are experimental. + +Functions must have exactly one (non self) argument, a tuple representing +the argument list [1]. This feature can be enabled with: + +``` +#![feature(unboxed_closures)] +``` + +[1]: https://doc.rust-lang.org/unstable-book/language-features/unboxed-closures.html +[iss29625]: https://github.com/rust-lang/rust/issues/26925 +"##, + E0184: r##" Explicitly implementing both Drop and Copy for a type is currently disallowed. This feature can make some sense in theory, but the current implementation is @@ -4671,7 +4685,6 @@ register_diagnostics! { // E0173, // manual implementations of unboxed closure traits are experimental // E0174, // E0182, // merged into E0229 - E0183, // E0187, // can't infer the kind of the closure // E0188, // can not cast an immutable reference to a mutable pointer // E0189, // deprecated: can only cast a boxed pointer to a boxed object From 08b8b7d4924d0902eadc5a03f289c922157fb0bc Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Fri, 26 Jul 2019 21:41:00 +0200 Subject: [PATCH 2/4] Completed E0183 as per review --- src/librustc_typeck/error_codes.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index 94c0ec328c71d..e3e0c9f62d34d 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -1589,17 +1589,35 @@ fn bar(foo: Foo) -> u32 { "##, E0183: r##" -Fn* traits (`unboxed closures`) are experimental. +Fn* traits (`unboxed closures`) are experimental. +See [tracking issue #29625][iss29625] for the status of the feature. Functions must have exactly one (non self) argument, a tuple representing -the argument list [1]. This feature can be enabled with: +the argument list [1]. +Here's an example of this error: +```compile_fail,E0183 +extern "rust-call" fn echo(arg: (u32,)) -> (u32,) { + arg +} +``` + +This feature can be enabled with: +``` +#![feature(unboxed_closures)] +``` + +Here's the above example fixed: ``` #![feature(unboxed_closures)] + +extern "rust-call" fn echo(arg: (u32,)) -> (u32,) { + arg +} ``` [1]: https://doc.rust-lang.org/unstable-book/language-features/unboxed-closures.html -[iss29625]: https://github.com/rust-lang/rust/issues/26925 +[iss29625]: https://github.com/rust-lang/rust/issues/29625 "##, E0184: r##" From 3615cc28d0664191d680a963267515f7abb83c20 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Fri, 26 Jul 2019 22:10:39 +0200 Subject: [PATCH 3/4] Changed as per review --- src/librustc_typeck/error_codes.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index e3e0c9f62d34d..df627a477594b 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -1595,7 +1595,8 @@ See [tracking issue #29625][iss29625] for the status of the feature. Functions must have exactly one (non self) argument, a tuple representing the argument list [1]. -Here's an example of this error: +Erroneous code example: + ```compile_fail,E0183 extern "rust-call" fn echo(arg: (u32,)) -> (u32,) { arg @@ -1603,11 +1604,13 @@ extern "rust-call" fn echo(arg: (u32,)) -> (u32,) { ``` This feature can be enabled with: + ``` #![feature(unboxed_closures)] ``` Here's the above example fixed: + ``` #![feature(unboxed_closures)] From 00bde392f8a55ba01cfa4b15e8c1bee3ebe0c523 Mon Sep 17 00:00:00 2001 From: Francesco Dainese Date: Sat, 27 Jul 2019 19:38:26 +0200 Subject: [PATCH 4/4] Error now suggests to add `fn_traits` previous guidelines followed regarding formatting --- src/librustc_typeck/error_codes.rs | 31 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index df627a477594b..0d28e6184ae09 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -1589,37 +1589,44 @@ fn bar(foo: Foo) -> u32 { "##, E0183: r##" -Fn* traits (`unboxed closures`) are experimental. +Manually implementing `Fn*` traits is experimental. See [tracking issue #29625][iss29625] for the status of the feature. -Functions must have exactly one (non self) argument, a tuple representing -the argument list [1]. - Erroneous code example: ```compile_fail,E0183 -extern "rust-call" fn echo(arg: (u32,)) -> (u32,) { - arg +#![feature(unboxed_closures)] +struct Echo {} + +impl FnOnce<(A,)> for Echo { + type Output = A; + extern "rust-call" fn call_once(self, args: (A,)) -> Self::Output { + args.0 + } } ``` -This feature can be enabled with: +To fix this error the feature `fn_traits` must be enabled with: ``` -#![feature(unboxed_closures)] +#![feature(fn_traits)] ``` Here's the above example fixed: ``` -#![feature(unboxed_closures)] +#![feature(unboxed_closures, fn_traits)] +struct Echo {} -extern "rust-call" fn echo(arg: (u32,)) -> (u32,) { - arg +impl FnOnce<(A,)> for Echo { + type Output = A; + extern "rust-call" fn call_once(self, args: (A,)) -> Self::Output { + args.0 + } } ``` -[1]: https://doc.rust-lang.org/unstable-book/language-features/unboxed-closures.html +[1]: https://doc.rust-lang.org/unstable-book/library-features/fn-traits.html [iss29625]: https://github.com/rust-lang/rust/issues/29625 "##,