rust/compiler/rustc_error_messages
Matthias Krüger a86bdb4c50
Rollup merge of #104223 - fmease:recover-fn-ptr-with-generics, r=estebank
Recover from function pointer types with generic parameter list

Give a more helpful error when encountering function pointer types with a generic parameter list like `fn<'a>(&'a str) -> bool` or `fn<T>(T) -> T` and suggest moving lifetime parameters to a `for<>` parameter list.

I've added a bunch of extra code to properly handle (unlikely?) corner cases like `for<'a> fn<'b>()` (where there already exists a `for<>` parameter list) correctly suggesting `for<'a, 'b> fn()` (merging the lists). If you deem this useless, I can simplify the code by suggesting nothing at all in this case.

I am quite open to suggestions regarding the wording of the diagnostic messages.

Fixes #103487.
``@rustbot`` label A-diagnostics
r? diagnostics
2022-11-14 19:26:16 +01:00
..
locales/en-US Rollup merge of #104223 - fmease:recover-fn-ptr-with-generics, r=estebank 2022-11-14 19:26:16 +01:00
src Rollup merge of #104217 - Nilstrieb:funny-dollar-syntax, r=TaKO8Ki 2022-11-11 20:51:41 +05:30
Cargo.toml Remove from compiler/ crates 2022-09-29 16:49:04 +09:00