@@ -2603,6 +2603,92 @@ pub(crate) struct UnexpectedExpressionInPattern {
26032603 pub is_bound : bool ,
26042604}
26052605
2606+ #[ derive( Subdiagnostic ) ]
2607+ pub ( crate ) enum UnexpectedExpressionInPatternSugg {
2608+ #[ multipart_suggestion(
2609+ parse_unexpected_expr_in_pat_remove_let_sugg,
2610+ applicability = "maybe-incorrect" ,
2611+ style = "verbose"
2612+ ) ]
2613+ RemoveLet {
2614+ /// The span of the `let` keyword.
2615+ #[ suggestion_part( code = "" ) ]
2616+ let_span : Span ,
2617+ /// The span of the type annotation.
2618+ #[ suggestion_part( code = "" ) ]
2619+ ty_span : Option < Span > ,
2620+ /// `true` iff the `let` statement has an initializer.
2621+ has_initializer : bool ,
2622+ } ,
2623+
2624+ #[ multipart_suggestion(
2625+ parse_unexpected_expr_in_pat_create_guard_sugg,
2626+ applicability = "maybe-incorrect"
2627+ ) ]
2628+ CreateGuard {
2629+ /// The span of the `PatKind:Err` to be transformed into a `PatKind::Ident`.
2630+ #[ suggestion_part( code = "{ident}" ) ]
2631+ ident_span : Span ,
2632+ /// The end of the match arm's pattern.
2633+ #[ suggestion_part( code = " if {ident} == {expr}" ) ]
2634+ pat_hi : Span ,
2635+ /// The suggested identifier.
2636+ ident : String ,
2637+ /// `ident_span`'s snippet.
2638+ expr : String ,
2639+ } ,
2640+
2641+ #[ multipart_suggestion(
2642+ parse_unexpected_expr_in_pat_update_guard_sugg,
2643+ applicability = "maybe-incorrect"
2644+ ) ]
2645+ UpdateGuard {
2646+ /// The span of the `PatKind:Err` to be transformed into a `PatKind::Ident`.
2647+ #[ suggestion_part( code = "{ident}" ) ]
2648+ ident_span : Span ,
2649+ /// The beginning of the match arm guard's expression.
2650+ #[ suggestion_part( code = "(" ) ]
2651+ guard_lo : Span ,
2652+ /// The end of the match arm guard's expression.
2653+ #[ suggestion_part( code = ") && {ident} == {expr}" ) ]
2654+ guard_hi : Span ,
2655+ /// The suggested identifier.
2656+ ident : String ,
2657+ /// `ident_span`'s snippet.
2658+ expr : String ,
2659+ } ,
2660+
2661+ #[ multipart_suggestion(
2662+ parse_unexpected_expr_in_pat_const_sugg,
2663+ applicability = "has-placeholders"
2664+ ) ]
2665+ Const {
2666+ /// The beginning of statement's line.
2667+ #[ suggestion_part( code = "{indentation}const {ident}: _ = {expr};\n " ) ]
2668+ stmt_lo : Span ,
2669+ /// The span of the `PatKind:Err` to be transformed into a `PatKind::Ident`.
2670+ #[ suggestion_part( code = "{ident}" ) ]
2671+ ident_span : Span ,
2672+ /// The suggested identifier.
2673+ ident : String ,
2674+ /// `ident_span`'s snippet.
2675+ expr : String ,
2676+ /// The statement's block's indentation.
2677+ indentation : String ,
2678+ } ,
2679+
2680+ #[ multipart_suggestion(
2681+ parse_unexpected_expr_in_pat_inline_const_sugg,
2682+ applicability = "maybe-incorrect"
2683+ ) ]
2684+ InlineConst {
2685+ #[ suggestion_part( code = "const {{ " ) ]
2686+ start_span : Span ,
2687+ #[ suggestion_part( code = " }}" ) ]
2688+ end_span : Span ,
2689+ } ,
2690+ }
2691+
26062692#[ derive( Diagnostic ) ]
26072693#[ diag( parse_unexpected_paren_in_range_pat) ]
26082694pub ( crate ) struct UnexpectedParenInRangePat {
0 commit comments