add long explanation for E0183
This commit is contained in:
parent
044674337a
commit
cca39148f3
4 changed files with 44 additions and 4 deletions
|
@ -92,6 +92,7 @@ E0164: include_str!("./error_codes/E0164.md"),
|
|||
E0165: include_str!("./error_codes/E0165.md"),
|
||||
E0170: include_str!("./error_codes/E0170.md"),
|
||||
E0178: include_str!("./error_codes/E0178.md"),
|
||||
E0183: include_str!("./error_codes/E0183.md"),
|
||||
E0184: include_str!("./error_codes/E0184.md"),
|
||||
E0185: include_str!("./error_codes/E0185.md"),
|
||||
E0186: include_str!("./error_codes/E0186.md"),
|
||||
|
@ -512,7 +513,6 @@ E0785: include_str!("./error_codes/E0785.md"),
|
|||
// E0173, // manual implementations of unboxed closure traits are experimental
|
||||
// E0174,
|
||||
// E0182, // merged into E0229
|
||||
E0183,
|
||||
// E0187, // cannot 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
|
||||
|
|
39
compiler/rustc_error_codes/src/error_codes/E0183.md
Normal file
39
compiler/rustc_error_codes/src/error_codes/E0183.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
Manual implemetation of a `Fn*` trait.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0183
|
||||
struct MyClosure {
|
||||
foo: i32
|
||||
}
|
||||
|
||||
impl FnOnce<()> for MyClosure { // error
|
||||
type Output = ();
|
||||
extern "rust-call" fn call_once(self, args: ()) -> Self::Output {
|
||||
println!("{}", self.foo);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Manually implementing `Fn`, `FnMut` or `FnOnce` is unstable
|
||||
and requires `#![feature(fn_traits, unboxed_closures)]`.
|
||||
|
||||
```
|
||||
#![feature(fn_traits, unboxed_closures)]
|
||||
|
||||
struct MyClosure {
|
||||
foo: i32
|
||||
}
|
||||
|
||||
impl FnOnce<()> for MyClosure { // ok!
|
||||
type Output = ();
|
||||
extern "rust-call" fn call_once(self, args: ()) -> Self::Output {
|
||||
println!("{}", self.foo);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The argumements must be a tuple representing the argument list.
|
||||
For more info, see the [tracking issue][iss29625]:
|
||||
|
||||
[iss29625]: https://github.com/rust-lang/rust/issues/29625
|
|
@ -101,5 +101,5 @@ LL | impl FnOnce<()> for Baz {
|
|||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0229, E0658.
|
||||
For more information about an error, try `rustc --explain E0229`.
|
||||
Some errors have detailed explanations: E0183, E0229, E0658.
|
||||
For more information about an error, try `rustc --explain E0183`.
|
||||
|
|
|
@ -26,4 +26,5 @@ LL | impl FnOnce<(u32, u32)> for Test {
|
|||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
Some errors have detailed explanations: E0183, E0658.
|
||||
For more information about an error, try `rustc --explain E0183`.
|
||||
|
|
Loading…
Add table
Reference in a new issue