Skip to content

Commit 4bf7eea

Browse files
Add long error explanation for E0561
1 parent 4ac4809 commit 4bf7eea

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/librustc_passes/error_codes.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,34 @@ fn main() {
286286
```
287287
"##,
288288

289+
E0561: r##"
290+
A non-ident or non-wildcard pattern has been used as a parameter of a function
291+
pointer type.
292+
293+
Erroneous code example:
294+
295+
```compile_fail,E0561
296+
type A1 = fn(mut param: u8); // error!
297+
type A2 = fn(&param: u32); // error!
298+
```
299+
300+
When using an alias over a function type, you cannot e.g. denote a parameter as
301+
being mutable.
302+
303+
To fix the issue, remove patterns (`_` is allowed though). Example:
304+
305+
```
306+
type A1 = fn(param: u8); // ok!
307+
type A2 = fn(_: u32); // ok!
308+
```
309+
310+
You can also omit the parameter name:
311+
312+
```
313+
type A3 = fn(i16); // ok!
314+
```
315+
"##,
316+
289317
E0571: r##"
290318
A `break` statement with an argument appeared in a non-`loop` loop.
291319
@@ -503,7 +531,6 @@ Switch to the Rust 2018 edition to use `async fn`.
503531
;
504532
E0226, // only a single explicit lifetime bound is permitted
505533
E0472, // asm! is unsupported on this target
506-
E0561, // patterns aren't allowed in function pointer types
507534
E0567, // auto traits can not have generic parameters
508535
E0568, // auto traits can not have super traits
509536
E0666, // nested `impl Trait` is illegal

0 commit comments

Comments
 (0)