Change:
<ins> error: function pointer types may not have generic parameters --> $DIR/recover-fn-ptr-with-generics.rs:2:24 | LL |     type Predicate = fn<'a>(&'a str) -> bool; |                        ^^^^ | help: consider moving the lifetime parameter to a `for` parameter list | LL -     type Predicate = fn<'a>(&'a str) -> bool; LL +     type Predicate = for<'a> fn(&'a str) -> bool; | error: function pointer types may not have generic parameters --> $DIR/recover-fn-ptr-with-generics.rs:5:23 | LL |     type Identity = fn<T>(T) -> T; |                       ^^^ error: function pointer types may not have generic parameters --> $DIR/recover-fn-ptr-with-generics.rs:10:14 | LL |     let _: fn<const N: usize, 'e, Q, 'f>(); |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider moving the lifetime parameters to a `for` parameter list | LL -     let _: fn<const N: usize, 'e, Q, 'f>(); LL +     let _: for<'e, 'f> fn(); | error: function pointer types may not have generic parameters --> $DIR/recover-fn-ptr-with-generics.rs:13:26 | LL |     let _: for<'outer> fn<'inner>(); |                          ^^^^^^^^ | help: consider moving the lifetime parameter to the `for` parameter list | LL -     let _: for<'outer> fn<'inner>(); LL +     let _: for<'outer, 'inner> fn(); | error: function pointer types may not have generic parameters --> $DIR/recover-fn-ptr-with-generics.rs:16:20 | LL |     let _: for<> fn<'r>(); |                    ^^^^ | help: consider moving the lifetime parameter to the `for` parameter list | LL -     let _: for<> fn<'r>(); LL +     let _: for<'r> fn(); | error: function pointer types may not have generic parameters --> $DIR/recover-fn-ptr-with-generics.rs:19:18 | LL |     type Hmm = fn<>(); |                  ^^ error: function pointer types may not have generic parameters --> $DIR/recover-fn-ptr-with-generics.rs:22:21 | LL |     let _: extern fn<'a: 'static>(); |                     ^^^^^^^^^^^^^ | help: consider moving the lifetime parameter to a `for` parameter list | LL -     let _: extern fn<'a: 'static>(); LL +     let _: for<'a> extern fn(); | error: function pointer types may not have generic parameters --> $DIR/recover-fn-ptr-with-generics.rs:26:35 | LL |     let _: for<'any> extern "C" fn<'u>(); |                                   ^^^^ | help: consider moving the lifetime parameter to the `for` parameter list | LL -     let _: for<'any> extern "C" fn<'u>(); LL +     let _: for<'any, 'u> extern "C" fn(); | error: expected identifier, found `>` --> $DIR/recover-fn-ptr-with-generics.rs:29:32 | LL |     type QuiteBroken = fn<const>(); |                                ^ expected identifier error: lifetime bounds cannot be used in this context --> $DIR/recover-fn-ptr-with-generics.rs:22:26 | LL |     let _: extern fn<'a: 'static>(); |                          ^^^^^^^ error[E0412]: cannot find type `T` in this scope --> $DIR/recover-fn-ptr-with-generics.rs:5:27 | LL |     type Identity = fn<T>(T) -> T; |                           ^ not found in this scope error[E0412]: cannot find type `T` in this scope --> $DIR/recover-fn-ptr-with-generics.rs:5:33 | LL |     type Identity = fn<T>(T) -> T; |                                 ^ not found in this scope error: aborting due to 12 previous errors For more information about this error, try `rustc --explain E0412`. </ins>

Discussion:
Newcomers might attempt to write a “generic” function pointer like . In such case, the compiler should provide a better error message. Inspired by a recent Reddit thread I sadly cannot find anymore. Given the following code: The compiler should mention that function pointers may not be generic or […] may not have generic parameters, suggest to move the lifetime(s) to a parameter list (this should be machine-applicable in my judgement) and be able to recover: For later reference, the current output is: Given the following code: The compiler should mention that function pointers may not be generic or […] may not have generic parameters and be able to recover emitting two diagnostics, one for each line. The compiler could also suggest moving the generic parameter list further up to the owning function, struct, etc. if available. Note that this might not be what the user intended (since there is a semantic difference between hypothetical higher-ranked generics and normal ones) and therefore shouldn't be machine-applicable. For later reference, the current output is: label A-parser A-suggestion-diagnostics D-newcomer-roadblock <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim