Skip to content

Commit cca3914

Browse files
committed
add long explanation for E0183
1 parent 0446743 commit cca3914

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ E0164: include_str!("./error_codes/E0164.md"),
9292
E0165: include_str!("./error_codes/E0165.md"),
9393
E0170: include_str!("./error_codes/E0170.md"),
9494
E0178: include_str!("./error_codes/E0178.md"),
95+
E0183: include_str!("./error_codes/E0183.md"),
9596
E0184: include_str!("./error_codes/E0184.md"),
9697
E0185: include_str!("./error_codes/E0185.md"),
9798
E0186: include_str!("./error_codes/E0186.md"),
@@ -512,7 +513,6 @@ E0785: include_str!("./error_codes/E0785.md"),
512513
// E0173, // manual implementations of unboxed closure traits are experimental
513514
// E0174,
514515
// E0182, // merged into E0229
515-
E0183,
516516
// E0187, // cannot infer the kind of the closure
517517
// E0188, // can not cast an immutable reference to a mutable pointer
518518
// E0189, // deprecated: can only cast a boxed pointer to a boxed object
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Manual implemetation of a `Fn*` trait.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0183
6+
struct MyClosure {
7+
foo: i32
8+
}
9+
10+
impl FnOnce<()> for MyClosure { // error
11+
type Output = ();
12+
extern "rust-call" fn call_once(self, args: ()) -> Self::Output {
13+
println!("{}", self.foo);
14+
}
15+
}
16+
```
17+
18+
Manually implementing `Fn`, `FnMut` or `FnOnce` is unstable
19+
and requires `#![feature(fn_traits, unboxed_closures)]`.
20+
21+
```
22+
#![feature(fn_traits, unboxed_closures)]
23+
24+
struct MyClosure {
25+
foo: i32
26+
}
27+
28+
impl FnOnce<()> for MyClosure { // ok!
29+
type Output = ();
30+
extern "rust-call" fn call_once(self, args: ()) -> Self::Output {
31+
println!("{}", self.foo);
32+
}
33+
}
34+
```
35+
36+
The argumements must be a tuple representing the argument list.
37+
For more info, see the [tracking issue][iss29625]:
38+
39+
[iss29625]: https://github.com/rust-lang/rust/issues/29625

src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ LL | impl FnOnce<()> for Baz {
101101

102102
error: aborting due to 12 previous errors
103103

104-
Some errors have detailed explanations: E0229, E0658.
105-
For more information about an error, try `rustc --explain E0229`.
104+
Some errors have detailed explanations: E0183, E0229, E0658.
105+
For more information about an error, try `rustc --explain E0183`.

src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ LL | impl FnOnce<(u32, u32)> for Test {
2626

2727
error: aborting due to 3 previous errors
2828

29-
For more information about this error, try `rustc --explain E0658`.
29+
Some errors have detailed explanations: E0183, E0658.
30+
For more information about an error, try `rustc --explain E0183`.

0 commit comments

Comments
 (0)