diff options
| author | bors <bors@rust-lang.org> | 2021-10-15 05:59:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-15 05:59:49 +0000 |
| commit | 72d66064e77281536588189a916af28a1819b313 (patch) | |
| tree | 026c1f5253155149bd789a688b6eace31ca9ba11 /compiler/rustc_error_codes | |
| parent | 313e71a2535196466b0bbdcfa3387bd6373e0f28 (diff) | |
| parent | e45c22279344dcb6bf4761f737e1d62c7958eec0 (diff) | |
| download | rust-72d66064e77281536588189a916af28a1819b313.tar.gz rust-72d66064e77281536588189a916af28a1819b313.zip | |
Auto merge of #89903 - matthiaskrgr:rollup-s0c69xl, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #86011 (move implicit `Sized` predicate to end of list) - #89821 (Add a strange test for `unsafe_code` lint.) - #89859 (add dedicated error variant for writing the discriminant of an uninhabited enum variant) - #89870 (Suggest Box::pin when Pin::new is used instead) - #89880 (Use non-checking TLS relocation in aarch64 asm! sym test.) - #89885 (add long explanation for E0183) - #89894 (Remove unused dependencies from rustc_const_eval) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_error_codes')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0183.md | 39 |
2 files changed, 40 insertions, 1 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 27b2bfbaf47..724e3f7fed3 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -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"), @@ -513,7 +514,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 diff --git a/compiler/rustc_error_codes/src/error_codes/E0183.md b/compiler/rustc_error_codes/src/error_codes/E0183.md new file mode 100644 index 00000000000..7e1d08daae1 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0183.md @@ -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 |
