rust/compiler/rustc_parse/src/parser
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
..
attr.rs Migrate all diagnostics 2022-10-23 10:09:44 +02:00
attr_wrapper.rs Add delay_span_bug to AttrWrapper::take_for_recovery 2022-11-13 13:09:23 +00:00
diagnostics.rs Rollup merge of #103468 - chenyukang:yukang/fix-103435-extra-parentheses, r=estebank 2022-11-11 12:12:29 -05:00
expr.rs Add delay_span_bug to AttrWrapper::take_for_recovery 2022-11-13 13:09:23 +00:00
generics.rs fix #102182, recover from impl Trait in type param bound 2022-10-08 06:47:26 +08:00
item.rs Auto merge of #99918 - WaffleLapkin:fnFnfun, r=estebank 2022-11-11 02:07:52 +00:00
mod.rs Auto merge of #99918 - WaffleLapkin:fnFnfun, r=estebank 2022-11-11 02:07:52 +00:00
nonterminal.rs slight vertical formatting 2022-09-15 23:51:43 +08:00
pat.rs Recover unclosed char literal being parsed as lifetime 2022-10-22 06:57:12 +00:00
path.rs Introduce ExprKind::IncludedBytes 2022-11-11 16:31:32 +00:00
stmt.rs Add delay_span_bug to AttrWrapper::take_for_recovery 2022-11-13 13:09:23 +00:00
ty.rs Recover from fn ptr tys with generic param list 2022-11-11 13:42:40 +01:00