@@ -2424,6 +2424,92 @@ pub(crate) struct UnexpectedExpressionInPattern {
24242424 pub is_bound : bool ,
24252425}
24262426
2427+ #[ derive( Subdiagnostic ) ]
2428+ pub ( crate ) enum UnexpectedExpressionInPatternSugg {
2429+ #[ multipart_suggestion(
2430+ parse_unexpected_expr_in_pat_remove_let_sugg,
2431+ applicability = "maybe-incorrect" ,
2432+ style = "verbose"
2433+ ) ]
2434+ RemoveLet {
2435+ /// The span of the `let` keyword.
2436+ #[ suggestion_part( code = "" ) ]
2437+ let_span : Span ,
2438+ /// The span of the type annotation.
2439+ #[ suggestion_part( code = "" ) ]
2440+ ty_span : Option < Span > ,
2441+ /// `true` iff the `let` statement has an initializer.
2442+ has_initializer : bool ,
2443+ } ,
2444+
2445+ #[ multipart_suggestion(
2446+ parse_unexpected_expr_in_pat_create_guard_sugg,
2447+ applicability = "maybe-incorrect"
2448+ ) ]
2449+ CreateGuard {
2450+ /// The span of the `PatKind:Err` to be transformed into a `PatKind::Ident`.
2451+ #[ suggestion_part( code = "{ident}" ) ]
2452+ ident_span : Span ,
2453+ /// The end of the match arm's pattern.
2454+ #[ suggestion_part( code = " if {ident} == {expr}" ) ]
2455+ pat_hi : Span ,
2456+ /// The suggested identifier.
2457+ ident : String ,
2458+ /// `ident_span`'s snippet.
2459+ expr : String ,
2460+ } ,
2461+
2462+ #[ multipart_suggestion(
2463+ parse_unexpected_expr_in_pat_update_guard_sugg,
2464+ applicability = "maybe-incorrect"
2465+ ) ]
2466+ UpdateGuard {
2467+ /// The span of the `PatKind:Err` to be transformed into a `PatKind::Ident`.
2468+ #[ suggestion_part( code = "{ident}" ) ]
2469+ ident_span : Span ,
2470+ /// The beginning of the match arm guard's expression.
2471+ #[ suggestion_part( code = "(" ) ]
2472+ guard_lo : Span ,
2473+ /// The end of the match arm guard's expression.
2474+ #[ suggestion_part( code = ") && {ident} == {expr}" ) ]
2475+ guard_hi : Span ,
2476+ /// The suggested identifier.
2477+ ident : String ,
2478+ /// `ident_span`'s snippet.
2479+ expr : String ,
2480+ } ,
2481+
2482+ #[ multipart_suggestion(
2483+ parse_unexpected_expr_in_pat_const_sugg,
2484+ applicability = "has-placeholders"
2485+ ) ]
2486+ Const {
2487+ /// The beginning of statement's line.
2488+ #[ suggestion_part( code = "{indentation}const {ident}: _ = {expr};\n " ) ]
2489+ stmt_lo : Span ,
2490+ /// The span of the `PatKind:Err` to be transformed into a `PatKind::Ident`.
2491+ #[ suggestion_part( code = "{ident}" ) ]
2492+ ident_span : Span ,
2493+ /// The suggested identifier.
2494+ ident : String ,
2495+ /// `ident_span`'s snippet.
2496+ expr : String ,
2497+ /// The statement's block's indentation.
2498+ indentation : String ,
2499+ } ,
2500+
2501+ #[ multipart_suggestion(
2502+ parse_unexpected_expr_in_pat_inline_const_sugg,
2503+ applicability = "maybe-incorrect"
2504+ ) ]
2505+ InlineConst {
2506+ #[ suggestion_part( code = "const {{ " ) ]
2507+ start_span : Span ,
2508+ #[ suggestion_part( code = " }}" ) ]
2509+ end_span : Span ,
2510+ } ,
2511+ }
2512+
24272513#[ derive( Diagnostic ) ]
24282514#[ diag( parse_unexpected_paren_in_range_pat) ]
24292515pub ( crate ) struct UnexpectedParenInRangePat {
0 commit comments