Skip to content

Commit 73685ec

Browse files
authored
Rollup merge of rust-lang#65098 - GuillaumeGomez:long-err-explanation-E0561, r=Centril
Add long error explanation for E0561 Part of rust-lang#61137
2 parents a9777b3 + 8dd0008 commit 73685ec

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
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

src/test/ui/no-patterns-in-args-macro.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ LL | m!((bad, pat));
1818

1919
error: aborting due to 3 previous errors
2020

21-
Some errors have detailed explanations: E0130, E0642.
21+
Some errors have detailed explanations: E0130, E0561, E0642.
2222
For more information about an error, try `rustc --explain E0130`.

src/test/ui/no-patterns-in-args.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ LL | type A2 = fn(&arg: u8);
3030

3131
error: aborting due to 5 previous errors
3232

33-
For more information about this error, try `rustc --explain E0130`.
33+
Some errors have detailed explanations: E0130, E0561.
34+
For more information about an error, try `rustc --explain E0130`.

0 commit comments

Comments
 (0)